fix: Enhance UI setup across multiple boards (#1753)
* chore: Update component versions and enhance UI setup across multiple boards - Bumped uart-eth-modem version from ~0.3.2 to ~0.3.3 in idf_component.yml. - Added SetupUI method to various display classes to ensure proper UI initialization before usage. - Improved error handling in display classes to prevent issues when UI is not set up. - Ensured UI customization is performed in SetupUI rather than constructors for better reliability. * remove pm config code
This commit is contained in:
@ -14,13 +14,33 @@
|
||||
#define TAG "OttoEmojiDisplay"
|
||||
OttoEmojiDisplay::OttoEmojiDisplay(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)
|
||||
: SpiLcdDisplay(panel_io, panel, width, height, offset_x, offset_y, mirror_x, mirror_y, swap_xy) {
|
||||
InitializeOttoEmojis();
|
||||
SetupPreviewImage();
|
||||
SetTheme(LvglThemeManager::GetInstance().GetTheme("dark"));
|
||||
}
|
||||
|
||||
void OttoEmojiDisplay::SetupUI() {
|
||||
// Prevent duplicate calls - parent SetupUI() will also check, but check here for early return
|
||||
if (setup_ui_called_) {
|
||||
ESP_LOGW(TAG, "SetupUI() called multiple times, skipping duplicate call");
|
||||
return;
|
||||
}
|
||||
|
||||
// Call parent SetupUI() first to create all lvgl objects
|
||||
SpiLcdDisplay::SetupUI();
|
||||
|
||||
// Setup preview image after UI is initialized
|
||||
DisplayLockGuard lock(this);
|
||||
lv_obj_set_size(preview_image_, width_ , height_ );
|
||||
|
||||
// Set default emotion after UI is initialized
|
||||
SetEmotion("staticstate");
|
||||
}
|
||||
|
||||
void OttoEmojiDisplay::SetupPreviewImage() {
|
||||
DisplayLockGuard lock(this);
|
||||
if (preview_image_ == nullptr) {
|
||||
ESP_LOGW(TAG, "SetupPreviewImage called but preview_image_ is nullptr (UI not initialized yet)");
|
||||
return;
|
||||
}
|
||||
lv_obj_set_size(preview_image_, width_ , height_ );
|
||||
}
|
||||
|
||||
@ -28,9 +48,7 @@ void OttoEmojiDisplay::InitializeOttoEmojis() {
|
||||
ESP_LOGI(TAG, "Otto表情初始化将由Assets系统处理");
|
||||
// 表情初始化已移至assets系统,通过DEFAULT_EMOJI_COLLECTION=otto-gif配置
|
||||
// assets.cc会从assets分区加载GIF表情并设置到theme
|
||||
|
||||
// 设置默认表情为staticstate
|
||||
SetEmotion("staticstate");
|
||||
// Note: Default emotion is now set in SetupUI() after LVGL objects are created
|
||||
}
|
||||
|
||||
LV_FONT_DECLARE(OTTO_ICON_FONT);
|
||||
|
||||
@ -16,6 +16,7 @@ class OttoEmojiDisplay : public SpiLcdDisplay {
|
||||
virtual ~OttoEmojiDisplay() = default;
|
||||
virtual void SetStatus(const char* status) override;
|
||||
virtual void SetPreviewImage(std::unique_ptr<LvglImage> image) override;
|
||||
virtual void SetupUI() override;
|
||||
|
||||
private:
|
||||
void InitializeOttoEmojis();
|
||||
|
||||
Reference in New Issue
Block a user