diff --git a/custom/integration/settings_controller.cpp b/custom/integration/settings_controller.cpp index 8e74b90a..06a310ca 100644 --- a/custom/integration/settings_controller.cpp +++ b/custom/integration/settings_controller.cpp @@ -727,7 +727,10 @@ namespace custom::integration void SettingsController::Impl::apply_current_theme() { - settings_ui_apply(&config_, &ui_runtime_); + { + LvglLockGuard lock; + settings_ui_apply(&config_, &ui_runtime_); + } ui_page_settings_apply_theme_state(config_.ui.theme == APP_CFG_UI_THEME_DARK, current_variant_id().c_str()); } diff --git a/lv_conf.h b/lv_conf.h index 13aac588..730fb9bb 100644 --- a/lv_conf.h +++ b/lv_conf.h @@ -261,7 +261,7 @@ *-----------*/ /*Enable the log module*/ -#define LV_USE_LOG 0 +#define LV_USE_LOG 1 #if LV_USE_LOG /*How important log should be added: @@ -271,11 +271,11 @@ *LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail *LV_LOG_LEVEL_USER Only logs added by the user *LV_LOG_LEVEL_NONE Do not log anything*/ - #define LV_LOG_LEVEL LV_LOG_LEVEL_WARN + #define LV_LOG_LEVEL LV_LOG_LEVEL_INFO /*1: Print the log with 'printf'; *0: User need to register a callback with `lv_log_register_print_cb()`*/ - #define LV_LOG_PRINTF 0 + #define LV_LOG_PRINTF 1 /*Set callback to print the logs. *E.g `my_print`. The prototype should be `void my_print(lv_log_level_t level, const char * buf)` diff --git a/platforms/tab5/components/m5stack_tab5/m5stack_tab5.c b/platforms/tab5/components/m5stack_tab5/m5stack_tab5.c index 16ec99df..3c52337a 100644 --- a/platforms/tab5/components/m5stack_tab5/m5stack_tab5.c +++ b/platforms/tab5/components/m5stack_tab5/m5stack_tab5.c @@ -1644,8 +1644,8 @@ static void lvgl_read_cb(lv_indev_t* indev, lv_indev_data_t* data) { ESP_LOGI(TAG, "Touch rotation check: right edge press mapped to (%d,%d)", - transformed_x, - transformed_y); + (int)transformed_x, + (int)transformed_y); logged_right_edge_ok = true; } } diff --git a/platforms/tab5/main/hal/hal_esp32.cpp b/platforms/tab5/main/hal/hal_esp32.cpp index 11a51502..5a07814f 100644 --- a/platforms/tab5/main/hal/hal_esp32.cpp +++ b/platforms/tab5/main/hal/hal_esp32.cpp @@ -172,26 +172,58 @@ void HalEsp32::init() .buff_spiram = true, .sw_rotate = true, }}; - lvDisp = bsp_display_start_with_config(&cfg); - lv_display_set_rotation(lvDisp, LV_DISPLAY_ROTATION_90); + lvDisp = bsp_display_start_with_config(&cfg); + bool display_locked = false; + if (lvDisp == nullptr) + { + mclog::tagError(_tag, "Failed to start LVGL display"); + } + else + { + display_locked = bsp_display_lock(0); + if (!display_locked) + { + mclog::tagError(_tag, "Failed to lock LVGL port during display init"); + } + else + { + lv_display_set_rotation(lvDisp, LV_DISPLAY_ROTATION_90); + mclog::tagInfo(_tag, "Display rotation set to 90 degrees"); + } + } + bsp_display_backlight_on(); lvTouchpad = bsp_display_get_input_dev(); - if (lvTouchpad == nullptr) + if (display_locked) { - mclog::tagWarn(_tag, "LVGL touch input not provided by BSP; creating fallback driver"); - - lvTouchpad = lv_indev_create(); - if (lvTouchpad == nullptr) + if (lvTouchpad != nullptr) { - mclog::tagError(_tag, "Failed to allocate LVGL touch input device"); + lv_indev_set_display(lvTouchpad, lvDisp); } else { - lv_indev_set_type(lvTouchpad, LV_INDEV_TYPE_POINTER); - lv_indev_set_read_cb(lvTouchpad, lvgl_read_cb); - lv_indev_set_display(lvTouchpad, lvDisp); + mclog::tagWarn(_tag, "LVGL touch input not provided by BSP; creating fallback driver"); + + lvTouchpad = lv_indev_create(); + if (lvTouchpad == nullptr) + { + mclog::tagError(_tag, "Failed to allocate LVGL touch input device"); + } + else + { + lv_indev_set_type(lvTouchpad, LV_INDEV_TYPE_POINTER); + lv_indev_set_read_cb(lvTouchpad, lvgl_read_cb); + lv_indev_set_display(lvTouchpad, lvDisp); + } } + + bsp_display_unlock(); + display_locked = false; + } + else if (lvTouchpad == nullptr) + { + mclog::tagError(_tag, "Touch input unavailable and LVGL lock not taken"); } mclog::tagInfo(_tag, "usb host init"); @@ -205,8 +237,6 @@ void HalEsp32::init() mclog::tagInfo(_tag, "set gpio output capability"); set_gpio_output_capability(); - - bsp_display_unlock(); } void HalEsp32::set_gpio_output_capability()