Skip to content

Commit 3f17654

Browse files
authored
Merge pull request #200 from baba-dev/codex/fix-ui-freeze-and-orientation-issues
fix: guard LVGL usage and enable diagnostics on Tab5
2 parents 460b467 + 8ada687 commit 3f17654

File tree

4 files changed

+52
-19
lines changed

4 files changed

+52
-19
lines changed

custom/integration/settings_controller.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,10 @@ namespace custom::integration
727727

728728
void SettingsController::Impl::apply_current_theme()
729729
{
730-
settings_ui_apply(&config_, &ui_runtime_);
730+
{
731+
LvglLockGuard lock;
732+
settings_ui_apply(&config_, &ui_runtime_);
733+
}
731734
ui_page_settings_apply_theme_state(config_.ui.theme == APP_CFG_UI_THEME_DARK,
732735
current_variant_id().c_str());
733736
}

lv_conf.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@
261261
*-----------*/
262262

263263
/*Enable the log module*/
264-
#define LV_USE_LOG 0
264+
#define LV_USE_LOG 1
265265
#if LV_USE_LOG
266266

267267
/*How important log should be added:
@@ -271,11 +271,11 @@
271271
*LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail
272272
*LV_LOG_LEVEL_USER Only logs added by the user
273273
*LV_LOG_LEVEL_NONE Do not log anything*/
274-
#define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
274+
#define LV_LOG_LEVEL LV_LOG_LEVEL_INFO
275275

276276
/*1: Print the log with 'printf';
277277
*0: User need to register a callback with `lv_log_register_print_cb()`*/
278-
#define LV_LOG_PRINTF 0
278+
#define LV_LOG_PRINTF 1
279279

280280
/*Set callback to print the logs.
281281
*E.g `my_print`. The prototype should be `void my_print(lv_log_level_t level, const char * buf)`

platforms/tab5/components/m5stack_tab5/m5stack_tab5.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,8 +1644,8 @@ static void lvgl_read_cb(lv_indev_t* indev, lv_indev_data_t* data)
16441644
{
16451645
ESP_LOGI(TAG,
16461646
"Touch rotation check: right edge press mapped to (%d,%d)",
1647-
transformed_x,
1648-
transformed_y);
1647+
(int)transformed_x,
1648+
(int)transformed_y);
16491649
logged_right_edge_ok = true;
16501650
}
16511651
}

platforms/tab5/main/hal/hal_esp32.cpp

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -172,26 +172,58 @@ void HalEsp32::init()
172172
.buff_spiram = true,
173173
.sw_rotate = true,
174174
}};
175-
lvDisp = bsp_display_start_with_config(&cfg);
176-
lv_display_set_rotation(lvDisp, LV_DISPLAY_ROTATION_90);
175+
lvDisp = bsp_display_start_with_config(&cfg);
176+
bool display_locked = false;
177+
if (lvDisp == nullptr)
178+
{
179+
mclog::tagError(_tag, "Failed to start LVGL display");
180+
}
181+
else
182+
{
183+
display_locked = bsp_display_lock(0);
184+
if (!display_locked)
185+
{
186+
mclog::tagError(_tag, "Failed to lock LVGL port during display init");
187+
}
188+
else
189+
{
190+
lv_display_set_rotation(lvDisp, LV_DISPLAY_ROTATION_90);
191+
mclog::tagInfo(_tag, "Display rotation set to 90 degrees");
192+
}
193+
}
194+
177195
bsp_display_backlight_on();
178196

179197
lvTouchpad = bsp_display_get_input_dev();
180-
if (lvTouchpad == nullptr)
198+
if (display_locked)
181199
{
182-
mclog::tagWarn(_tag, "LVGL touch input not provided by BSP; creating fallback driver");
183-
184-
lvTouchpad = lv_indev_create();
185-
if (lvTouchpad == nullptr)
200+
if (lvTouchpad != nullptr)
186201
{
187-
mclog::tagError(_tag, "Failed to allocate LVGL touch input device");
202+
lv_indev_set_display(lvTouchpad, lvDisp);
188203
}
189204
else
190205
{
191-
lv_indev_set_type(lvTouchpad, LV_INDEV_TYPE_POINTER);
192-
lv_indev_set_read_cb(lvTouchpad, lvgl_read_cb);
193-
lv_indev_set_display(lvTouchpad, lvDisp);
206+
mclog::tagWarn(_tag, "LVGL touch input not provided by BSP; creating fallback driver");
207+
208+
lvTouchpad = lv_indev_create();
209+
if (lvTouchpad == nullptr)
210+
{
211+
mclog::tagError(_tag, "Failed to allocate LVGL touch input device");
212+
}
213+
else
214+
{
215+
lv_indev_set_type(lvTouchpad, LV_INDEV_TYPE_POINTER);
216+
lv_indev_set_read_cb(lvTouchpad, lvgl_read_cb);
217+
lv_indev_set_display(lvTouchpad, lvDisp);
218+
}
194219
}
220+
221+
bsp_display_unlock();
222+
display_locked = false;
223+
}
224+
else if (lvTouchpad == nullptr)
225+
{
226+
mclog::tagError(_tag, "Touch input unavailable and LVGL lock not taken");
195227
}
196228

197229
mclog::tagInfo(_tag, "usb host init");
@@ -205,8 +237,6 @@ void HalEsp32::init()
205237

206238
mclog::tagInfo(_tag, "set gpio output capability");
207239
set_gpio_output_capability();
208-
209-
bsp_display_unlock();
210240
}
211241

212242
void HalEsp32::set_gpio_output_capability()

0 commit comments

Comments
 (0)