From 5fef25fb139c1b64568a851bf1cfaa5dbb472d49 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sat, 17 Feb 2024 17:41:56 +0100 Subject: [PATCH] Various improvements (#46) - Specify IDF SDK version in a safer way - Fix for crash when polling SD card presence (Need to implement a universal locking mechanism later on) - Updated `ideas.md` - SD card task prio set to low --- app-esp/idf_component.yml | 2 +- boards/lilygo_tdeck/sdcard.c | 14 +++++++++++++- docs/ideas.md | 5 ++++- tactility/src/services/sdcard/sdcard.c | 1 + 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app-esp/idf_component.yml b/app-esp/idf_component.yml index 0756af3e..753e2e10 100644 --- a/app-esp/idf_component.yml +++ b/app-esp/idf_component.yml @@ -3,4 +3,4 @@ dependencies: espressif/esp_lcd_touch_cst816s: "^1.0.3" espressif/esp_lcd_touch_gt911: "^1.0.0" espressif/esp_lcd_touch: "1.1.1" - idf: '>=5.1.2' + idf: '~5.1.2' diff --git a/boards/lilygo_tdeck/sdcard.c b/boards/lilygo_tdeck/sdcard.c index b8fa7e03..54ea05d6 100644 --- a/boards/lilygo_tdeck/sdcard.c +++ b/boards/lilygo_tdeck/sdcard.c @@ -5,6 +5,7 @@ #include "esp_vfs_fat.h" #include "sdmmc_cmd.h" +#include "ui/lvgl_sync.h" #define TAG "tdeck_sdcard" @@ -126,7 +127,18 @@ static void sdcard_unmount(void* context) { static bool sdcard_is_mounted(void* context) { MountData* data = (MountData*)context; - return (data != NULL) && (sdmmc_get_status(data->card) == ESP_OK); + /** + * The SD card and the screen are on the same SPI bus. + * Writing and reading to the bus from 2 devices at the same time causes crashes. + * This work-around ensures that this check is only happening when LVGL isn't rendering. + */ + if (tt_lvgl_lock(100)) { + bool result = (data != NULL) && (sdmmc_get_status(data->card) == ESP_OK); + tt_lvgl_unlock(); + return result; + } else { + return false; + } } const SdCard tdeck_sdcard = { diff --git a/docs/ideas.md b/docs/ideas.md index 52c7179e..539bd4c8 100644 --- a/docs/ideas.md +++ b/docs/ideas.md @@ -9,6 +9,9 @@ - Wi-Fi connect app should show info about connection result - Check service/app id on registration to see if it is a duplicate id - Fix screenshot app on ESP32: it currently blocks when allocating memory +- Localisation of texts +- Portrait support for GPIO app +- App lifecycle docs mention on_create/on_destroy but app lifecycle is on_start/on_stop # Core Ideas - Make a HAL? It would mainly be there to support PC development. It's a lot of effort for supporting what's effectively a dev-only feature. @@ -17,7 +20,7 @@ - 2 wire speaker support - tt_app_start() and similar functions as proxies for Loader app start/stop/etc. - tt_app_set_result() for apps that need to return data to other apps (e.g. file selection) -- Make a statusbar service that apps can register icons to. Gui can observe its status changes? +- Introduce co-routines for calling wifi/lvgl/etc functionality. # App Improvement Ideas - Sort desktop apps by name. diff --git a/tactility/src/services/sdcard/sdcard.c b/tactility/src/services/sdcard/sdcard.c index 807a6f7a..a5d1fd03 100644 --- a/tactility/src/services/sdcard/sdcard.c +++ b/tactility/src/services/sdcard/sdcard.c @@ -33,6 +33,7 @@ static ServiceData* service_data_alloc() { .statusbar_icon_id = tt_statusbar_icon_add(NULL), .interrupted = false }; + tt_thread_set_priority(data->thread, ThreadPriorityLow); return data; }