From 8c72727455b8e3529d68d60c74d4311bdfcf9785 Mon Sep 17 00:00:00 2001 From: Timo Niemann Date: Wed, 1 Jul 2026 16:07:08 +0200 Subject: [PATCH] added safety guard to not open image browser until app is not ready --- main/include/lcd/ui.h | 1 + main/lcd/ui.c | 11 +++++++++++ main/main.c | 1 + 3 files changed, 13 insertions(+) diff --git a/main/include/lcd/ui.h b/main/include/lcd/ui.h index 1a69cd7..ccd85b6 100644 --- a/main/include/lcd/ui.h +++ b/main/include/lcd/ui.h @@ -10,4 +10,5 @@ typedef enum { void create_log_ui(void); void create_image_browser_ui(void); +void ui_app_ready_for_image_browser(void); void ui_switch_view_to(ui_view_t view); \ No newline at end of file diff --git a/main/lcd/ui.c b/main/lcd/ui.c index 0f103d8..42f2738 100644 --- a/main/lcd/ui.c +++ b/main/lcd/ui.c @@ -78,6 +78,12 @@ void create_image_browser_ui(void){ ui_log_appendf("Image browser UI created with %u images", image_count); } +static bool app_ready_for_image_browser = false; + +void ui_app_ready_for_image_browser(void){ + app_ready_for_image_browser = true; +} + void ui_switch_view_to(ui_view_t view){ if(view == current_view) return; @@ -88,6 +94,11 @@ void ui_switch_view_to(ui_view_t view){ lvgl_port_unlock(); break; case UI_VIEW_IMAGE_BROWSER: + if(!app_ready_for_image_browser){ + ESP_LOGW(TAG, "Cannot switch to image browser view, app not ready"); + ui_log_append("Cannot switch to image browser view, app not ready"); + return; + } lvgl_port_lock(0); ui_build_image_browser_view_locked(); lvgl_port_unlock(); diff --git a/main/main.c b/main/main.c index bb24991..ac18b27 100644 --- a/main/main.c +++ b/main/main.c @@ -37,6 +37,7 @@ void app_main(void){ } ui_log_append("Done listing files in root directory"); + ui_app_ready_for_image_browser(); ui_log_append("\nSwitching to image browser UI"); ESP_LOGI(TAG, "Switching to image browser UI");