From a05a6afaaffe0704063ed18a1c97b2f69e03966a Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Fri, 3 Oct 2025 22:12:55 +0200 Subject: [PATCH] Path fixes for simulator (#357) --- Boards/Simulator/Source/FreeRTOSConfig.h | 4 ++-- Boards/Simulator/Source/LvglTask.cpp | 1 + Libraries/SDL | 2 +- Tactility/Include/Tactility/Assets.h | 5 +++++ Tactility/Include/Tactility/lvgl/Lvgl.h | 8 ++++++++ Tactility/Source/app/boot/Boot.cpp | 4 +++- Tactility/Source/app/imageviewer/ImageViewer.cpp | 3 ++- Tactility/Source/app/launcher/Launcher.cpp | 7 ++++--- Tactility/Source/app/localesettings/LocaleSettings.cpp | 8 +++++++- Tactility/Source/app/screenshot/Screenshot.cpp | 5 +++-- Tactility/Source/app/timezone/TimeZone.cpp | 3 ++- 11 files changed, 38 insertions(+), 12 deletions(-) diff --git a/Boards/Simulator/Source/FreeRTOSConfig.h b/Boards/Simulator/Source/FreeRTOSConfig.h index d03bc412..c99efc7a 100644 --- a/Boards/Simulator/Source/FreeRTOSConfig.h +++ b/Boards/Simulator/Source/FreeRTOSConfig.h @@ -7,7 +7,7 @@ extern void vAssertCalled(unsigned long line, const char* const file); #define configUSE_TICKLESS_IDLE 0 #define configTICK_RATE_HZ 1000 // Must be the same as ESP32! #define configMAX_PRIORITIES 10 -#define configMINIMAL_STACK_SIZE 128 +#define configMINIMAL_STACK_SIZE 2048 #define configMAX_TASK_NAME_LEN 16 #define configUSE_16_BIT_TICKS 0 #define configIDLE_SHOULD_YIELD 1 @@ -57,7 +57,7 @@ extern void vAssertCalled(unsigned long line, const char* const file); #define configUSE_TIMERS 1 #define configTIMER_TASK_PRIORITY 3 #define configTIMER_QUEUE_LENGTH 10 -#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE +#define configTIMER_TASK_STACK_DEPTH 10240 /* Define to trap errors during development. */ #define configASSERT(x) if( ( x ) == 0 ) vAssertCalled(__LINE__, __FILE__) diff --git a/Boards/Simulator/Source/LvglTask.cpp b/Boards/Simulator/Source/LvglTask.cpp index cb1274b7..06074c6f 100644 --- a/Boards/Simulator/Source/LvglTask.cpp +++ b/Boards/Simulator/Source/LvglTask.cpp @@ -102,5 +102,6 @@ static void lvgl_task(TT_UNUSED void* arg) { lv_disp_remove(displayHandle); displayHandle = nullptr; + vTaskDelete(nullptr); } diff --git a/Libraries/SDL b/Libraries/SDL index 52146cf0..39a0fab4 160000 --- a/Libraries/SDL +++ b/Libraries/SDL @@ -1 +1 @@ -Subproject commit 52146cf067ae950b1d431a84766fc7d0501f536a +Subproject commit 39a0fab4d79ccd622512d6028ea3733bd4085455 diff --git a/Tactility/Include/Tactility/Assets.h b/Tactility/Include/Tactility/Assets.h index 01bd4e52..b3efa797 100644 --- a/Tactility/Include/Tactility/Assets.h +++ b/Tactility/Include/Tactility/Assets.h @@ -1,6 +1,11 @@ #pragma once +/** + * Deprecated list of LVGL asset folder paths> + */ + #define TT_ASSET_FOLDER "A:/system/" + #define TT_ASSET(file) TT_ASSET_FOLDER file // UI diff --git a/Tactility/Include/Tactility/lvgl/Lvgl.h b/Tactility/Include/Tactility/lvgl/Lvgl.h index e9872f6a..6e8bfbec 100644 --- a/Tactility/Include/Tactility/lvgl/Lvgl.h +++ b/Tactility/Include/Tactility/lvgl/Lvgl.h @@ -2,6 +2,14 @@ namespace tt::lvgl { +#ifdef ESP_PLATFORM +static constexpr auto* PATH_PREFIX = "A:"; +#else +// PC paths are relative, unlike ESP paths. +// LVGL paths require a `/` prefix, so we have to add it here: +static constexpr auto* PATH_PREFIX = "A:/"; +#endif + bool isStarted(); void start(); diff --git a/Tactility/Source/app/boot/Boot.cpp b/Tactility/Source/app/boot/Boot.cpp index 78af021e..db5f3c9d 100644 --- a/Tactility/Source/app/boot/Boot.cpp +++ b/Tactility/Source/app/boot/Boot.cpp @@ -1,3 +1,5 @@ +#include "Tactility/lvgl/Lvgl.h" + #include #include #include @@ -169,7 +171,7 @@ public: } else { logo = hal::usb::isUsbBootMode() ? "logo_usb.png" : "logo.png"; } - const auto logo_path = "A:" + paths->getAssetsPath(logo); + const auto logo_path = lvgl::PATH_PREFIX + paths->getAssetsPath(logo); TT_LOG_I(TAG, "%s", logo_path.c_str()); lv_image_set_src(image, logo_path.c_str()); } diff --git a/Tactility/Source/app/imageviewer/ImageViewer.cpp b/Tactility/Source/app/imageviewer/ImageViewer.cpp index eb9edfba..1922239f 100644 --- a/Tactility/Source/app/imageviewer/ImageViewer.cpp +++ b/Tactility/Source/app/imageviewer/ImageViewer.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -47,7 +48,7 @@ class ImageViewerApp final : public App { tt_check(bundle != nullptr, "Parameters not set"); std::string file_argument; if (bundle->optString(IMAGE_VIEWER_FILE_ARGUMENT, file_argument)) { - std::string prefixed_path = "A:" + file_argument; + std::string prefixed_path = lvgl::PATH_PREFIX + file_argument; TT_LOG_I(TAG, "Opening %s", prefixed_path.c_str()); lv_img_set_src(image, prefixed_path.c_str()); auto path = string::getLastPathSegment(file_argument); diff --git a/Tactility/Source/app/launcher/Launcher.cpp b/Tactility/Source/app/launcher/Launcher.cpp index c1192082..6eba6729 100644 --- a/Tactility/Source/app/launcher/Launcher.cpp +++ b/Tactility/Source/app/launcher/Launcher.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -113,9 +114,9 @@ public: const int32_t margin = is_landscape_display ? std::min(available_width / 16, button_size) : 0; const auto paths = app.getPaths(); - const auto apps_icon_path = "A:" + paths->getAssetsPath("icon_apps.png"); - const auto files_icon_path = "A:" + paths->getAssetsPath("icon_files.png"); - const auto settings_icon_path = "A:" + paths->getAssetsPath("icon_settings.png"); + const auto apps_icon_path = lvgl::PATH_PREFIX + paths->getAssetsPath("icon_apps.png"); + const auto files_icon_path = lvgl::PATH_PREFIX + paths->getAssetsPath("icon_files.png"); + const auto settings_icon_path = lvgl::PATH_PREFIX + paths->getAssetsPath("icon_settings.png"); createAppButton(buttons_wrapper, ui_scale, apps_icon_path.c_str(), "AppList", margin); createAppButton(buttons_wrapper, ui_scale, files_icon_path.c_str(), "Files", margin); diff --git a/Tactility/Source/app/localesettings/LocaleSettings.cpp b/Tactility/Source/app/localesettings/LocaleSettings.cpp index 6a67607f..8a01bf53 100644 --- a/Tactility/Source/app/localesettings/LocaleSettings.cpp +++ b/Tactility/Source/app/localesettings/LocaleSettings.cpp @@ -16,10 +16,16 @@ namespace tt::app::localesettings { constexpr auto* TAG = "LocaleSettings"; +#ifdef ESP_PLATFORM +constexpr auto* TEXT_RESOURCE_PATH = "/system/app/LocaleSettings/i18n"; +#else +constexpr auto* TEXT_RESOURCE_PATH = "system/app/LocaleSettings/i18n"; +#endif + extern const AppManifest manifest; class LocaleSettingsApp final : public App { - tt::i18n::TextResources textResources = tt::i18n::TextResources("/system/app/LocaleSettings/i18n"); + tt::i18n::TextResources textResources = tt::i18n::TextResources(TEXT_RESOURCE_PATH); Mutex mutex = Mutex(Mutex::Type::Recursive); lv_obj_t* timeZoneLabel = nullptr; lv_obj_t* regionLabel = nullptr; diff --git a/Tactility/Source/app/screenshot/Screenshot.cpp b/Tactility/Source/app/screenshot/Screenshot.cpp index a2068b2b..e005e368 100644 --- a/Tactility/Source/app/screenshot/Screenshot.cpp +++ b/Tactility/Source/app/screenshot/Screenshot.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -204,13 +205,13 @@ void ScreenshotApp::createFilePathWidgets(lv_obj_t* parent) { TT_LOG_W(TAG, "Found multiple SD card devices - picking first"); } if (!sdcard_devices.empty() && sdcard_devices.front()->isMounted()) { - std::string lvgl_mount_path = "A:" + sdcard_devices.front()->getMountPath(); + std::string lvgl_mount_path = lvgl::PATH_PREFIX + sdcard_devices.front()->getMountPath(); lv_textarea_set_text(pathTextArea, lvgl_mount_path.c_str()); } else { lv_textarea_set_text(pathTextArea, "Error: no SD card"); } } else { // PC - lv_textarea_set_text(pathTextArea, "A:"); + lv_textarea_set_text(pathTextArea, lvgl::PATH_PREFIX); } } diff --git a/Tactility/Source/app/timezone/TimeZone.cpp b/Tactility/Source/app/timezone/TimeZone.cpp index b7da873e..c1c597dc 100644 --- a/Tactility/Source/app/timezone/TimeZone.cpp +++ b/Tactility/Source/app/timezone/TimeZone.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -200,7 +201,7 @@ public: lv_obj_set_style_image_recolor_opa(icon, 255, 0); lv_obj_set_style_image_recolor(icon, lv_theme_get_color_primary(parent), 0); - std::string icon_path = "A:" + app.getPaths()->getAssetsPath("search.png"); + std::string icon_path = lvgl::PATH_PREFIX + app.getPaths()->getAssetsPath("search.png"); lv_image_set_src(icon, icon_path.c_str()); lv_obj_set_style_image_recolor(icon, lv_theme_get_color_primary(parent), 0);