electron_emoji_display.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #include <libs/gif/lv_gif.h>
  3. #include "display/lcd_display.h"
  4. // Electron Bot表情GIF声明 - 使用与Otto相同的6个表情
  5. LV_IMAGE_DECLARE(staticstate); // 静态状态/中性表情
  6. LV_IMAGE_DECLARE(sad); // 悲伤
  7. LV_IMAGE_DECLARE(happy); // 开心
  8. LV_IMAGE_DECLARE(scare); // 惊吓/惊讶
  9. LV_IMAGE_DECLARE(buxue); // 不学/困惑
  10. LV_IMAGE_DECLARE(anger); // 愤怒
  11. /**
  12. * @brief Electron Bot GIF表情显示类
  13. * 继承LcdDisplay,添加GIF表情支持
  14. */
  15. class ElectronEmojiDisplay : public SpiLcdDisplay {
  16. public:
  17. /**
  18. * @brief 构造函数,参数与SpiLcdDisplay相同
  19. */
  20. ElectronEmojiDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel,
  21. int width, int height, int offset_x, int offset_y, bool mirror_x,
  22. bool mirror_y, bool swap_xy, DisplayFonts fonts);
  23. virtual ~ElectronEmojiDisplay() = default;
  24. // 重写表情设置方法
  25. virtual void SetEmotion(const char* emotion) override;
  26. // 重写聊天消息设置方法
  27. virtual void SetChatMessage(const char* role, const char* content) override;
  28. // 重写图标设置方法
  29. virtual void SetIcon(const char* icon) override;
  30. private:
  31. void SetupGifContainer();
  32. lv_obj_t* emotion_gif_; ///< GIF表情组件
  33. // 表情映射
  34. struct EmotionMap {
  35. const char* name;
  36. const lv_image_dsc_t* gif;
  37. };
  38. static const EmotionMap emotion_maps_[];
  39. };