lcd_display.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #ifndef LCD_DISPLAY_H
  2. #define LCD_DISPLAY_H
  3. #include "display.h"
  4. #include <esp_lcd_panel_io.h>
  5. #include <esp_lcd_panel_ops.h>
  6. #include <font_emoji.h>
  7. #include <atomic>
  8. // Theme color structure
  9. struct ThemeColors {
  10. lv_color_t background;
  11. lv_color_t text;
  12. lv_color_t chat_background;
  13. lv_color_t user_bubble;
  14. lv_color_t assistant_bubble;
  15. lv_color_t system_bubble;
  16. lv_color_t system_text;
  17. lv_color_t border;
  18. lv_color_t low_battery;
  19. };
  20. class LcdDisplay : public Display {
  21. protected:
  22. esp_lcd_panel_io_handle_t panel_io_ = nullptr;
  23. esp_lcd_panel_handle_t panel_ = nullptr;
  24. lv_draw_buf_t draw_buf_;
  25. lv_obj_t* status_bar_ = nullptr;
  26. lv_obj_t* content_ = nullptr;
  27. lv_obj_t* container_ = nullptr;
  28. lv_obj_t* side_bar_ = nullptr;
  29. lv_obj_t* preview_image_ = nullptr;
  30. DisplayFonts fonts_;
  31. ThemeColors current_theme_;
  32. void SetupUI();
  33. virtual bool Lock(int timeout_ms = 0) override;
  34. virtual void Unlock() override;
  35. protected:
  36. // 添加protected构造函数
  37. LcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel, DisplayFonts fonts, int width, int height);
  38. public:
  39. ~LcdDisplay();
  40. virtual void SetEmotion(const char* emotion) override;
  41. virtual void SetIcon(const char* icon) override;
  42. virtual void SetPreviewImage(const lv_img_dsc_t* img_dsc) override;
  43. #if CONFIG_USE_WECHAT_MESSAGE_STYLE
  44. virtual void SetChatMessage(const char* role, const char* content) override;
  45. #endif
  46. // Add theme switching function
  47. virtual void SetTheme(const std::string& theme_name) override;
  48. };
  49. // RGB LCD显示器
  50. class RgbLcdDisplay : public LcdDisplay {
  51. public:
  52. RgbLcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel,
  53. int width, int height, int offset_x, int offset_y,
  54. bool mirror_x, bool mirror_y, bool swap_xy,
  55. DisplayFonts fonts);
  56. };
  57. // MIPI LCD显示器
  58. class MipiLcdDisplay : public LcdDisplay {
  59. public:
  60. MipiLcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel,
  61. int width, int height, int offset_x, int offset_y,
  62. bool mirror_x, bool mirror_y, bool swap_xy,
  63. DisplayFonts fonts);
  64. };
  65. // // SPI LCD显示器
  66. class SpiLcdDisplay : public LcdDisplay {
  67. public:
  68. SpiLcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel,
  69. int width, int height, int offset_x, int offset_y,
  70. bool mirror_x, bool mirror_y, bool swap_xy,
  71. DisplayFonts fonts);
  72. };
  73. // QSPI LCD显示器
  74. class QspiLcdDisplay : public LcdDisplay {
  75. public:
  76. QspiLcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel,
  77. int width, int height, int offset_x, int offset_y,
  78. bool mirror_x, bool mirror_y, bool swap_xy,
  79. DisplayFonts fonts);
  80. };
  81. // MCU8080 LCD显示器
  82. class Mcu8080LcdDisplay : public LcdDisplay {
  83. public:
  84. Mcu8080LcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel,
  85. int width, int height, int offset_x, int offset_y,
  86. bool mirror_x, bool mirror_y, bool swap_xy,
  87. DisplayFonts fonts);
  88. };
  89. #endif // LCD_DISPLAY_H