From c0ed8f0a4494d9e8f1ab21be7fd1e69eed0d7fa2 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sat, 6 Sep 2025 14:44:41 +0200 Subject: [PATCH] Merge develop into main (#318) - Disable `DisplayDriver` for `St7701Display` (on CYD 4848) - Improve `GraphicsDemo`: check for feature capability and show alert dialog if there's an issue - `DevelopmentService` installs to `/data` instead of `/sdcard` - Fixed `tt_app_get_data_directory()` and `tt_app_get_data_directory_lvgl()` (C++ to C) - `tt_kernel.h` now defines `MAX_TICKS` - `tt_init.cpp` now exports `esp_log()` which is required since ESP-IDF 5.5 --- .../Source/devices/St7701Display.h | 3 ++ Documentation/ideas.md | 7 ++- Drivers/EspLcdCompat/Source/EspLcdDisplay.h | 2 +- .../GraphicsDemo/main/Source/Main.cpp | 45 ++++++++++++++++--- .../development/DevelopmentService.cpp | 2 +- TactilityC/Include/tt_app.h | 4 +- TactilityC/Include/tt_kernel.h | 2 + TactilityC/Source/tt_app.cpp | 22 ++++----- TactilityC/Source/tt_init.cpp | 1 + 9 files changed, 66 insertions(+), 22 deletions(-) diff --git a/Boards/CYD-4848S040C/Source/devices/St7701Display.h b/Boards/CYD-4848S040C/Source/devices/St7701Display.h index 58a75c90..c2ee8e29 100644 --- a/Boards/CYD-4848S040C/Source/devices/St7701Display.h +++ b/Boards/CYD-4848S040C/Source/devices/St7701Display.h @@ -32,4 +32,7 @@ public: void setBacklightDuty(uint8_t backlightDuty) override; bool supportsBacklightDuty() const override { return true; } + + // TODO: Find out why it crashes + bool supportsDisplayDriver() const override { return false; } }; diff --git a/Documentation/ideas.md b/Documentation/ideas.md index 1a7a270f..6c256004 100644 --- a/Documentation/ideas.md +++ b/Documentation/ideas.md @@ -5,14 +5,17 @@ - Fix Development service: when no SD card is present, the app fails to install. Consider installing to `/data` Note: Change app install to "transfer file" functionality. We can have a proper install when we have app packaging. Note: Consider installation path option in interface -- Update ILI934x to v2.0.1 - External app loading: Check the version of Tactility and check ESP target hardware to check for compatibility. - Make a URL handler. Use it for handling local files. Match file types with apps. Create some kind of "intent" handler like on Android. The intent can have an action (e.g. view), a URL and an optional bundle. The manifest can provide the intent handler -- App packaging - Bug: GraphicsDemo should check if display supports the DisplayDriver interface (and same for touch) and show an AlertDialog error if there's a problem +- Update ILI934x to v2.0.1 +- App packaging +- Create an "app install paths" settings app to add/remove paths. + Scan these paths on startup. + Make the AppList use the scan results. ## Lower Priority diff --git a/Drivers/EspLcdCompat/Source/EspLcdDisplay.h b/Drivers/EspLcdCompat/Source/EspLcdDisplay.h index 099c2138..c2eb4980 100644 --- a/Drivers/EspLcdCompat/Source/EspLcdDisplay.h +++ b/Drivers/EspLcdCompat/Source/EspLcdDisplay.h @@ -56,7 +56,7 @@ public: // endregion - // region NativeDisplay + // region DisplayDriver bool supportsDisplayDriver() const override { return true; } diff --git a/ExternalApps/GraphicsDemo/main/Source/Main.cpp b/ExternalApps/GraphicsDemo/main/Source/Main.cpp index d25007ca..4b5a8d2c 100644 --- a/ExternalApps/GraphicsDemo/main/Source/Main.cpp +++ b/ExternalApps/GraphicsDemo/main/Source/Main.cpp @@ -5,22 +5,55 @@ #include #include +#include #include constexpr auto TAG = "Main"; -static void onCreate(AppHandle appHandle, void* data) { +/** Find a DisplayDevice that supports the DisplayDriver interface */ +static bool findUsableDisplay(DeviceId& deviceId) { uint16_t display_count = 0; + if (!tt_hal_device_find(DEVICE_TYPE_DISPLAY, &deviceId, &display_count, 1)) { + ESP_LOGE(TAG, "No display device found"); + return false; + } + + if (!tt_hal_display_driver_supported(deviceId)) { + ESP_LOGE(TAG, "Display doesn't support driver mode"); + return false; + } + + return true; +} + +/** Find a TouchDevice that supports the TouchDriver interface */ +static bool findUsableTouch(DeviceId& deviceId) { + uint16_t touch_count = 0; + if (!tt_hal_device_find(DEVICE_TYPE_TOUCH, &deviceId, &touch_count, 1)) { + ESP_LOGE(TAG, "No touch device found"); + return false; + } + + if (!tt_hal_touch_driver_supported(deviceId)) { + ESP_LOGE(TAG, "Touch doesn't support driver mode"); + return false; + } + + return true; +} + +static void onCreate(AppHandle appHandle, void* data) { DeviceId display_id; - if (!tt_hal_device_find(DEVICE_TYPE_DISPLAY, &display_id, &display_count, 1)) { - ESP_LOGI(TAG, "No display device found"); + if (!findUsableDisplay(display_id)) { + tt_app_stop(); + tt_app_alertdialog_start("Error", "The display doesn't support the required features.", nullptr, 0); return; } - uint16_t touch_count = 0; DeviceId touch_id; - if (!tt_hal_device_find(DEVICE_TYPE_TOUCH, &touch_id, &touch_count, 1)) { - ESP_LOGI(TAG, "No touch device found"); + if (!findUsableTouch(touch_id)) { + tt_app_stop(); + tt_app_alertdialog_start("Error", "The touch driver doesn't support the required features.", nullptr, 0); return; } diff --git a/Tactility/Source/service/development/DevelopmentService.cpp b/Tactility/Source/service/development/DevelopmentService.cpp index 90f0df12..b4edf0f2 100644 --- a/Tactility/Source/service/development/DevelopmentService.cpp +++ b/Tactility/Source/service/development/DevelopmentService.cpp @@ -251,7 +251,7 @@ esp_err_t DevelopmentService::handleAppInstall(httpd_req_t* request) { content_left -= content_read; // Write file - auto file_path = std::format("/sdcard/{}", filename_entry->second); + auto file_path = std::format("/data/{}", filename_entry->second); auto* file = fopen(file_path.c_str(), "wb"); auto file_bytes_written = fwrite(buffer.get(), 1, file_size, file); fclose(file); diff --git a/TactilityC/Include/tt_app.h b/TactilityC/Include/tt_app.h index 03bfdd3b..371dd529 100644 --- a/TactilityC/Include/tt_app.h +++ b/TactilityC/Include/tt_app.h @@ -29,7 +29,7 @@ bool tt_app_has_result(AppHandle handle); * @param[out] buffer the output buffer (recommended size is 256 bytes) * @param[inout] size used as input for maximum buffer size (including null terminator) and is set with the path string length by this function */ -void tt_app_get_data_directory(AppPathsHandle handle, char* buffer, size_t& size); +void tt_app_get_data_directory(AppPathsHandle handle, char* buffer, size_t* size); /** Get the path to the data directory of this app, with LVGL drive letter prefix applied. * The recommended buffer size is 256 bytes. @@ -37,7 +37,7 @@ void tt_app_get_data_directory(AppPathsHandle handle, char* buffer, size_t& size * @param[out] buffer the output buffer (recommended size is 256 bytes) * @param[inout] size used as input for maximum buffer size (including null terminator) and is set with the path string length by this function */ -void tt_app_get_data_directory_lvgl(AppPathsHandle handle, char* buffer, size_t& size); +void tt_app_get_data_directory_lvgl(AppPathsHandle handle, char* buffer, size_t* size); /** * Start an app by id. diff --git a/TactilityC/Include/tt_kernel.h b/TactilityC/Include/tt_kernel.h index c399b200..0777c706 100644 --- a/TactilityC/Include/tt_kernel.h +++ b/TactilityC/Include/tt_kernel.h @@ -8,6 +8,8 @@ extern "C" { typedef unsigned long TickType; +#define MAX_TICKS INT32_MAX + /** * Stall the current task for the specified amount of time. * @param milliseconds the time in milliseconds to stall. diff --git a/TactilityC/Source/tt_app.cpp b/TactilityC/Source/tt_app.cpp index ad152b36..e1b4a204 100644 --- a/TactilityC/Source/tt_app.cpp +++ b/TactilityC/Source/tt_app.cpp @@ -33,38 +33,40 @@ void tt_app_stop() { tt::app::stop(); } -void tt_app_get_data_directory(AppPathsHandle handle, char* buffer, size_t& size) { +void tt_app_get_data_directory(AppPathsHandle handle, char* buffer, size_t* size) { assert(buffer != nullptr); - assert(size > 0); + assert(size != nullptr); + assert(*size > 0); auto paths = HANDLE_AS_APP_CONTEXT(handle)->getPaths(); auto data_path = paths->getDataDirectory(); auto expected_length = data_path.length() + 1; - if (size < expected_length) { + if (*size < expected_length) { TT_LOG_E(TAG, "Path buffer not large enough (%d < %d)", size, expected_length); - size = 0; + *size = 0; buffer[0] = 0; return; } strcpy(buffer, data_path.c_str()); - size = data_path.length(); + *size = data_path.length(); } -void tt_app_get_data_directory_lvgl(AppPathsHandle handle, char* buffer, size_t& size) { +void tt_app_get_data_directory_lvgl(AppPathsHandle handle, char* buffer, size_t* size) { assert(buffer != nullptr); - assert(size > 0); + assert(size != nullptr); + assert(*size > 0); auto paths = HANDLE_AS_APP_CONTEXT(handle)->getPaths(); auto data_path = paths->getDataDirectoryLvgl(); auto expected_length = data_path.length() + 1; - if (size < expected_length) { + if (*size < expected_length) { TT_LOG_E(TAG, "Path buffer not large enough (%d < %d)", size, expected_length); - size = 0; + *size = 0; buffer[0] = 0; return; } strcpy(buffer, data_path.c_str()); - size = data_path.length(); + *size = data_path.length(); } } \ No newline at end of file diff --git a/TactilityC/Source/tt_init.cpp b/TactilityC/Source/tt_init.cpp index d741108c..08fc354f 100644 --- a/TactilityC/Source/tt_init.cpp +++ b/TactilityC/Source/tt_init.cpp @@ -105,6 +105,7 @@ const esp_elfsym elf_symbols[] { ESP_ELFSYM_EXPORT(tolower), ESP_ELFSYM_EXPORT(toupper), // ESP-IDF + ESP_ELFSYM_EXPORT(esp_log), ESP_ELFSYM_EXPORT(esp_log_write), ESP_ELFSYM_EXPORT(esp_log_timestamp), // Tactility