表情

[English]

  • 组件注册表: espressif/brookesia_expression_emote

  • 辅助头文件: #include "brookesia/service_helper/expression/emote.hpp"

  • 辅助类: esp_brookesia::service::helper::ExpressionEmote

概述

brookesia_expression_emote 是 ESP-Brookesia 表情管理组件,基于 ESP-Brookesia 服务框架实现,提供:

  • 资源管理:支持加载和管理表情/动画资源,灵活配置资源。

  • 表情控制:支持设置和管理表情符号(emoji),用于表达不同的情感状态。

  • 动画控制:支持动画播放控制,包括等待动画帧完成、停止动画等操作。

  • 二维码:支持设置和隐藏二维码,实现二维码的显示和隐藏。

  • 事件消息:支持设置事件消息,实现事件消息的显示和隐藏。

服务接口

函数

SetConfig

描述

Set emote config.

执行要求
  • 是否需要调度器: 不需要

参数
  • Config

    • 类型: Object

    • 是否必填: 必填

    • 描述: Config. Example: {“h_res”:320,”v_res”:240,”buf_pixels”:7680,”fps”:30,”task_priority”:5,”task_stack”:4096,”task_affinity”:0,”task_stack_in_ext”:true,”flag_swap_color_bytes”:false,”flag_double_buffer”:false,”flag_buff_dma”:false,”flag_buff_spiram”:true}

Schema JSON
展开查看 JSON

{
  "name": "SetConfig",
  "description": "Set emote config.",
  "require_scheduler": false,
  "parameters": [
    {
      "name": "Config",
      "description": "Config. Example: {\"h_res\":320,\"v_res\":240,\"buf_pixels\":7680,\"fps\":30,\"task_priority\":5,\"task_stack\":4096,\"task_affinity\":0,\"task_stack_in_ext\":true,\"flag_swap_color_bytes\":false,\"flag_double_buffer\":false,\"flag_buff_dma\":false,\"flag_buff_spiram\":true}",
      "type": "Object",
      "required": true,
      "default_value": null
    }
  ]
}
CLI 命令
svc_call Emote SetConfig {"Config":null}

LoadAssetsSource

描述

Load assets from the specified source.

执行要求
  • 是否需要调度器: 不需要

参数
  • Source

    • 类型: Object

    • 是否必填: 必填

    • 描述: Asset source as a JSON object. Example: {“source”:”anim_icon”,”type”:”PartitionLabel”,”flag_enable_mmap”:false}

Schema JSON
展开查看 JSON

{
  "name": "LoadAssetsSource",
  "description": "Load assets from the specified source.",
  "require_scheduler": false,
  "parameters": [
    {
      "name": "Source",
      "description": "Asset source as a JSON object. Example: {\"source\":\"anim_icon\",\"type\":\"PartitionLabel\",\"flag_enable_mmap\":false}",
      "type": "Object",
      "required": true,
      "default_value": null
    }
  ]
}
CLI 命令
svc_call Emote LoadAssetsSource {"Source":null}

SetEmoji

描述

Set emoji and hide animation immediately.

执行要求
  • 是否需要调度器: 不需要

参数
  • Emoji

    • 类型: String

    • 是否必填: 必填

    • 描述: Emoji name.

Schema JSON
展开查看 JSON

{
  "name": "SetEmoji",
  "description": "Set emoji and hide animation immediately.",
  "require_scheduler": false,
  "parameters": [
    {
      "name": "Emoji",
      "description": "Emoji name.",
      "type": "String",
      "required": true,
      "default_value": null
    }
  ]
}
CLI 命令
svc_call Emote SetEmoji {"Emoji":null}

HideEmoji

描述

Hide current emoji.

执行要求
  • 是否需要调度器: 不需要

参数
  • 无。

Schema JSON
展开查看 JSON

{
  "name": "HideEmoji",
  "description": "Hide current emoji.",
  "require_scheduler": false,
  "parameters": []
}
CLI 命令
svc_call Emote HideEmoji

SetAnimation

描述

Set animation and hide emoji immediately.

执行要求
  • 是否需要调度器: 不需要

参数
  • Animation

    • 类型: String

    • 是否必填: 必填

    • 描述: Animation name.

Schema JSON
展开查看 JSON

{
  "name": "SetAnimation",
  "description": "Set animation and hide emoji immediately.",
  "require_scheduler": false,
  "parameters": [
    {
      "name": "Animation",
      "description": "Animation name.",
      "type": "String",
      "required": true,
      "default_value": null
    }
  ]
}
CLI 命令
svc_call Emote SetAnimation {"Animation":null}

InsertAnimation

描述

Insert animation; it hides immediately and shows after the duration.

执行要求
  • 是否需要调度器: 不需要

参数
  • Animation

    • 类型: String

    • 是否必填: 必填

    • 描述: Animation name.

  • DurationMs

    • 类型: Number

    • 是否必填: 必填

    • 描述: Animation duration in milliseconds. Stops automatically after this duration.

Schema JSON
展开查看 JSON

{
  "name": "InsertAnimation",
  "description": "Insert animation; it hides immediately and shows after the duration.",
  "require_scheduler": false,
  "parameters": [
    {
      "name": "Animation",
      "description": "Animation name.",
      "type": "String",
      "required": true,
      "default_value": null
    },
    {
      "name": "DurationMs",
      "description": "Animation duration in milliseconds. Stops automatically after this duration.",
      "type": "Number",
      "required": true,
      "default_value": null
    }
  ]
}
CLI 命令
svc_call Emote InsertAnimation {"Animation":null,"DurationMs":null}

StopAnimation

描述

Stop current animation and hide it immediately.

执行要求
  • 是否需要调度器: 不需要

参数
  • 无。

Schema JSON
展开查看 JSON

{
  "name": "StopAnimation",
  "description": "Stop current animation and hide it immediately.",
  "require_scheduler": false,
  "parameters": []
}
CLI 命令
svc_call Emote StopAnimation

WaitAnimationFrameDone

描述

Wait for each animation frame to finish.

执行要求
  • 是否需要调度器: 不需要

参数
  • TimeoutMs

    • 类型: Number

    • 是否必填: 可选

    • 默认值: 0E0

    • 描述: Timeout in milliseconds. 0 means wait forever.

Schema JSON
展开查看 JSON

{
  "name": "WaitAnimationFrameDone",
  "description": "Wait for each animation frame to finish.",
  "require_scheduler": false,
  "parameters": [
    {
      "name": "TimeoutMs",
      "description": "Timeout in milliseconds. `0` means wait forever.",
      "type": "Number",
      "required": false,
      "default_value": 0.0
    }
  ]
}
CLI 命令
svc_call Emote WaitAnimationFrameDone {"TimeoutMs":null}

SetEventMessage

描述

Set message for a specified emote event.

执行要求
  • 是否需要调度器: 不需要

参数
  • Event

    • 类型: String

    • 是否必填: 必填

    • 描述: Event type. Allowed values: [Idle, Speak, Listen, System, User, Battery]

  • Message

    • 类型: String

    • 是否必填: 可选

    • 默认值: ""

    • 描述: Message text.

Schema JSON
展开查看 JSON

{
  "name": "SetEventMessage",
  "description": "Set message for a specified emote event.",
  "require_scheduler": false,
  "parameters": [
    {
      "name": "Event",
      "description": "Event type. Allowed values: [Idle, Speak, Listen, System, User, Battery]",
      "type": "String",
      "required": true,
      "default_value": null
    },
    {
      "name": "Message",
      "description": "Message text.",
      "type": "String",
      "required": false,
      "default_value": ""
    }
  ]
}
CLI 命令
svc_call Emote SetEventMessage {"Event":null,"Message":null}

HideEventMessage

描述

Hide current event message.

执行要求
  • 是否需要调度器: 不需要

参数
  • 无。

Schema JSON
展开查看 JSON

{
  "name": "HideEventMessage",
  "description": "Hide current event message.",
  "require_scheduler": false,
  "parameters": []
}
CLI 命令
svc_call Emote HideEventMessage

SetQrcode

描述

Set QR code and hide emoji and animation immediately.

执行要求
  • 是否需要调度器: 不需要

参数
  • Qrcode

    • 类型: String

    • 是否必填: 必填

    • 描述: QR code content.

Schema JSON
展开查看 JSON

{
  "name": "SetQrcode",
  "description": "Set QR code and hide emoji and animation immediately.",
  "require_scheduler": false,
  "parameters": [
    {
      "name": "Qrcode",
      "description": "QR code content.",
      "type": "String",
      "required": true,
      "default_value": null
    }
  ]
}
CLI 命令
svc_call Emote SetQrcode {"Qrcode":null}

HideQrcode

描述

Hide current QR code and show emoji immediately.

执行要求
  • 是否需要调度器: 不需要

参数
  • 无。

Schema JSON
展开查看 JSON

{
  "name": "HideQrcode",
  "description": "Hide current QR code and show emoji immediately.",
  "require_scheduler": false,
  "parameters": []
}
CLI 命令
svc_call Emote HideQrcode

NotifyFlushFinished

描述

Notify emote flush finished.

执行要求
  • 是否需要调度器: 不需要

参数
  • 无。

Schema JSON
展开查看 JSON

{
  "name": "NotifyFlushFinished",
  "description": "Notify emote flush finished.",
  "require_scheduler": false,
  "parameters": []
}
CLI 命令
svc_call Emote NotifyFlushFinished

RefreshAll

描述

Refresh the screen.

执行要求
  • 是否需要调度器: 不需要

参数
  • 无。

Schema JSON
展开查看 JSON

{
  "name": "RefreshAll",
  "description": "Refresh the screen.",
  "require_scheduler": false,
  "parameters": []
}
CLI 命令
svc_call Emote RefreshAll

事件

FlushReady

描述

Emitted when emote flush is ready.

执行要求
  • 是否需要调度器: 不需要

参数
  • Param

    • 类型: Object

    • 描述: Flush-ready parameter as a JSON object. Example: {“x_start”:0,”y_start”:0,”x_end”:100,”y_end”:100,”data”:”@0x12345678”}

Schema JSON
展开查看 JSON

{
  "name": "FlushReady",
  "description": "Emitted when emote flush is ready.",
  "require_scheduler": false,
  "items": [
    {
      "name": "Param",
      "description": "Flush-ready parameter as a JSON object. Example: {\"x_start\":0,\"y_start\":0,\"x_end\":100,\"y_end\":100,\"data\":\"@0x12345678\"}",
      "type": "Object"
    }
  ]
}
CLI 命令
svc_subscribe Emote FlushReady