lcd_display.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 gray_edge;
  11. lv_color_t background;
  12. lv_color_t text;
  13. lv_color_t chat_background;
  14. lv_color_t user_bubble;
  15. lv_color_t assistant_bubble;
  16. lv_color_t system_bubble;
  17. lv_color_t system_text;
  18. lv_color_t border;
  19. lv_color_t low_battery;
  20. };
  21. class LcdDisplay : public Display {
  22. protected:
  23. esp_lcd_panel_io_handle_t panel_io_ = nullptr;
  24. esp_lcd_panel_handle_t panel_ = nullptr;
  25. lv_draw_buf_t draw_buf_;
  26. lv_obj_t* status_bar_ = nullptr;
  27. lv_obj_t* content_ = nullptr;
  28. lv_obj_t* container_ = nullptr;
  29. lv_obj_t* side_bar_ = nullptr;
  30. lv_obj_t* preview_image_ = nullptr;
  31. lv_obj_t* home_container_ = nullptr;
  32. lv_obj_t* timer_container_ = nullptr;
  33. lv_obj_t* time_digits_[5] = {nullptr}; // 时间数字图片对象数组
  34. lv_obj_t* time_label_ = nullptr;
  35. // lv_obj_t* date_label_ = nullptr;
  36. lv_obj_t* battery_home_label_ = nullptr;
  37. lv_obj_t* weather_label_ = nullptr; // 可选:天气信息
  38. bool is_home_screen_active_ = false;
  39. DisplayFonts fonts_;
  40. ThemeColors current_theme_;
  41. //倒计时相关
  42. lv_obj_t* countdown_container_=nullptr;
  43. lv_obj_t* countdown_label_;
  44. lv_obj_t* countdown_circle_;
  45. lv_anim_t countdown_anim_;
  46. void SetupUI();
  47. virtual bool Lock(int timeout_ms = 0) override;
  48. virtual void Unlock() override;
  49. protected:
  50. // 添加protected构造函数
  51. LcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel, DisplayFonts fonts, int width, int height);
  52. void SetupHomeScreen(); // 设置主界面UI
  53. void CleanupCountdownScreen();
  54. public:
  55. ~LcdDisplay();
  56. void ShowHomeScreen() override;
  57. void HideHomeScreen() override;
  58. void UpdateHomeTime() override;
  59. virtual void SetEmotion(const char* emotion) override;
  60. virtual void SetIcon(const char* icon) override;
  61. virtual void SetPreviewImage(const lv_img_dsc_t* img_dsc) override;
  62. #if CONFIG_USE_WECHAT_MESSAGE_STYLE
  63. virtual void SetChatMessage(const char* role, const char* content) override;
  64. #endif
  65. // 显示倒计时界面
  66. void ShowCountdownScreen(int seconds, int rotation_angle);
  67. // 更新倒计时显示
  68. void UpdateCountdown(int seconds);
  69. // 显示倒计时结束界面
  70. void ShowCountdownEndScreen();
  71. void ResetScreenRotation();
  72. // Add theme switching function
  73. virtual void SetTheme(const std::string& theme_name) override;
  74. };
  75. // RGB LCD显示器
  76. class RgbLcdDisplay : public LcdDisplay {
  77. public:
  78. RgbLcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel,
  79. int width, int height, int offset_x, int offset_y,
  80. bool mirror_x, bool mirror_y, bool swap_xy,
  81. DisplayFonts fonts);
  82. };
  83. // MIPI LCD显示器
  84. class MipiLcdDisplay : public LcdDisplay {
  85. public:
  86. MipiLcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel,
  87. int width, int height, int offset_x, int offset_y,
  88. bool mirror_x, bool mirror_y, bool swap_xy,
  89. DisplayFonts fonts);
  90. };
  91. // // SPI LCD显示器
  92. class SpiLcdDisplay : public LcdDisplay {
  93. public:
  94. SpiLcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel,
  95. int width, int height, int offset_x, int offset_y,
  96. bool mirror_x, bool mirror_y, bool swap_xy,
  97. DisplayFonts fonts);
  98. };
  99. // QSPI LCD显示器
  100. class QspiLcdDisplay : public LcdDisplay {
  101. public:
  102. QspiLcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel,
  103. int width, int height, int offset_x, int offset_y,
  104. bool mirror_x, bool mirror_y, bool swap_xy,
  105. DisplayFonts fonts);
  106. };
  107. // MCU8080 LCD显示器
  108. class Mcu8080LcdDisplay : public LcdDisplay {
  109. public:
  110. Mcu8080LcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel,
  111. int width, int height, int offset_x, int offset_y,
  112. bool mirror_x, bool mirror_y, bool swap_xy,
  113. DisplayFonts fonts);
  114. };
  115. #endif // LCD_DISPLAY_H