#ifndef LCD_DISPLAY_H #define LCD_DISPLAY_H #include "display.h" #include #include #include #include #include #include #include #include #include // Theme color structure struct ThemeColors { lv_color_t background; lv_color_t text; lv_color_t chat_background; lv_color_t user_bubble; lv_color_t assistant_bubble; lv_color_t system_bubble; lv_color_t system_text; lv_color_t border; lv_color_t low_battery; }; class LcdDisplay : public Display { protected: esp_lcd_panel_io_handle_t panel_io_ = nullptr; esp_lcd_panel_handle_t panel_ = nullptr; lv_draw_buf_t draw_buf_; lv_obj_t* status_bar_ = nullptr; lv_obj_t* content_ = nullptr; lv_obj_t* container_ = nullptr; lv_obj_t* side_bar_ = nullptr; lv_obj_t* preview_image_ = nullptr; DisplayFonts fonts_; ThemeColors current_theme_; void SetupUI(); virtual bool Lock(int timeout_ms = 0) override; virtual void Unlock() override; // FFT 绘制方法 void readAudioData(); virtual void clearScreen() override; virtual void stopFft() override; // 停止FFT显示 // 定时任务方法 void periodicUpdateTask(); static void periodicUpdateTaskWrapper(void* arg); // LVGL变量 lv_obj_t* canvas_ = nullptr; uint16_t* canvas_buffer_ = nullptr; void create_canvas(); uint16_t get_bar_color(int x_pos); void draw_spectrum(float *power_spectrum,int fft_size); void draw_bar(int x,int y,int bar_width,int bar_height,uint16_t color,int bar_index); void draw_block(int x,int y,int block_x_size,int block_y_size,uint16_t color,int bar_index); int canvas_width_; int canvas_height_; int16_t* audio_data=nullptr; int16_t* frame_audio_data=nullptr; uint32_t last_fft_update = 0; bool fft_data_ready = false; float* spectrum_data=nullptr; // FFT 相关变量 int audio_display_last_update = 0; std::atomic fft_task_should_stop = false; // FFT任务停止标志 TaskHandle_t fft_task_handle = nullptr; // FFT任务句柄 float* fft_real; float* fft_imag; float* hanning_window_float; void compute(float* real, float* imag, int n, bool forward); // 添加缺少的方法声明 void drawSpectrumIfReady(); void MyUI(); protected: // 添加protected构造函数 LcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel, DisplayFonts fonts, int width, int height); public: ~LcdDisplay(); virtual void SetEmotion(const char* emotion) override; virtual void SetIcon(const char* icon) override; virtual void SetMusicInfo(const char* song_name) override; virtual void SetPreviewImage(const lv_img_dsc_t* img_dsc) override; #if CONFIG_USE_WECHAT_MESSAGE_STYLE virtual void SetChatMessage(const char* role, const char* content) override; #endif // Add theme switching function virtual void SetTheme(const std::string& theme_name) override; virtual void start() override; }; // RGB LCD显示器 class RgbLcdDisplay : public LcdDisplay { public: RgbLcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel, int width, int height, int offset_x, int offset_y, bool mirror_x, bool mirror_y, bool swap_xy, DisplayFonts fonts); }; // MIPI LCD显示器 class MipiLcdDisplay : public LcdDisplay { public: MipiLcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel, int width, int height, int offset_x, int offset_y, bool mirror_x, bool mirror_y, bool swap_xy, DisplayFonts fonts); }; // // SPI LCD显示器 class SpiLcdDisplay : public LcdDisplay { public: SpiLcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel, int width, int height, int offset_x, int offset_y, bool mirror_x, bool mirror_y, bool swap_xy, DisplayFonts fonts); }; // QSPI LCD显示器 class QspiLcdDisplay : public LcdDisplay { public: QspiLcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel, int width, int height, int offset_x, int offset_y, bool mirror_x, bool mirror_y, bool swap_xy, DisplayFonts fonts); }; // MCU8080 LCD显示器 class Mcu8080LcdDisplay : public LcdDisplay { public: Mcu8080LcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel, int width, int height, int offset_x, int offset_y, bool mirror_x, bool mirror_y, bool swap_xy, DisplayFonts fonts); }; #endif // LCD_DISPLAY_H