From 12a9839420266e3136f66185697f5ee17b001b37 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Tue, 21 Jan 2025 21:55:54 +0100 Subject: [PATCH] Various fixes and improvements (#177) - Remove custom `ESP_TARGET` and use `ESP_PLATFORM` everywhere - Add `Loader` service functionality to `tt::app::` namespace - Make `Loader` `PubSub` usable by exposing the messages - Add board type to crash log - Don't show SD card in Files app when it's not mounted - Set default SPI frequency for SD cards - Move TT_VERSION to scope that works for sim too - Log Tactility version and board on boot - Rename "Yellow Board" to "CYD 2432S024C" --- .github/workflows/build-firmware.yml | 4 ++-- .github/workflows/build-sdk.yml | 2 +- App/CMakeLists.txt | 2 +- App/Kconfig | 11 ++++++--- App/Source/Boards.h | 6 ++--- .../CMakeLists.txt | 0 .../Source/Boot.cpp | 0 .../Source/CYD2432S024C.cpp} | 4 ++-- .../Source/CYD2432S024C.h} | 2 +- .../Source/Lvgl.cpp | 0 .../Source/YellowConfig.h | 0 .../Source/hal/YellowDisplay.cpp | 0 .../Source/hal/YellowDisplay.h | 0 .../Source/hal/YellowDisplayConstants.h | 0 .../Source/hal/YellowSdCard.cpp | 2 -- .../Source/hal/YellowSdCard.h | 0 .../Source/hal/YellowTouch.cpp | 0 .../Source/hal/YellowTouch.h | 0 .../Source/hal/YellowTouchConstants.h | 0 Boards/LilygoTdeck/Source/hal/TdeckSdCard.cpp | 2 -- .../M5stackCore2/Source/hal/Core2SdCard.cpp | 2 -- .../M5stackCoreS3/Source/hal/CoreS3SdCard.cpp | 2 -- Boards/UnPhone/Source/hal/UnPhoneSdCard.cpp | 2 -- Buildscripts/CMake/TactilitySDK.cmake | 2 -- CMakeLists.txt | 13 +++++----- Documentation/ideas.md | 7 ------ Tactility/Private/service/loader/Loader_i.h | 16 ------------- Tactility/Source/Tactility.cpp | 2 +- Tactility/Source/app/App.cpp | 22 +++++++++++++++++ Tactility/Source/app/App.h | 17 +++++++++++++ .../app/crashdiagnostics/CrashDiagnostics.cpp | 2 +- .../app/crashdiagnostics/CrashDiagnostics.h | 2 +- .../Source/app/crashdiagnostics/QrUrl.cpp | 5 +++- Tactility/Source/app/files/State.cpp | 24 ++++++++++++++----- Tactility/Source/service/loader/Loader.cpp | 4 ++-- Tactility/Source/service/loader/Loader.h | 16 +++++++++++-- TactilityCore/Source/Check.cpp | 2 +- TactilityCore/Source/CoreDefines.h | 2 +- TactilityCore/Source/Log.h | 6 ++--- TactilityHeadless/Private/EspInit.h | 4 ++-- TactilityHeadless/Private/EspPartitions_i.h | 4 ++-- TactilityHeadless/Source/PartitionsEsp.cpp | 4 ++-- .../Source/TactilityHeadless.cpp | 1 + .../Source/TactilityHeadlessEsp.cpp | 2 +- TactilityHeadless/Source/hal/SpiSdCard.cpp | 2 +- TactilityHeadless/Source/hal/SpiSdCard.h | 8 +++---- TactilityHeadless/Source/hal/i2c/I2c.cpp | 2 +- TactilityHeadless/Source/hal/i2c/I2cCompat.h | 2 +- TactilityHeadless/Source/hal/i2c/I2cMock.cpp | 2 +- .../Source/service/wifi/WifiEsp.cpp | 4 ++-- .../Source/service/wifi/WifiMock.cpp | 4 ++-- .../Source/service/wifi/WifiSettingsEsp.cpp | 4 ++-- .../Source/service/wifi/WifiSettingsMock.cpp | 4 ++-- ...low-board => sdkconfig.board.cyd-2432S024c | 4 +++- sdkconfig.board.lilygo-tdeck | 4 +++- sdkconfig.board.m5stack-core2 | 4 +++- sdkconfig.board.m5stack-cores3 | 4 +++- sdkconfig.board.unphone | 2 ++ 58 files changed, 147 insertions(+), 101 deletions(-) rename Boards/{YellowBoard => CYD-2432S024C}/CMakeLists.txt (100%) rename Boards/{YellowBoard => CYD-2432S024C}/Source/Boot.cpp (100%) rename Boards/{YellowBoard/Source/YellowBoard.cpp => CYD-2432S024C/Source/CYD2432S024C.cpp} (94%) rename Boards/{YellowBoard/Source/YellowBoard.h => CYD-2432S024C/Source/CYD2432S024C.h} (61%) rename Boards/{YellowBoard => CYD-2432S024C}/Source/Lvgl.cpp (100%) rename Boards/{YellowBoard => CYD-2432S024C}/Source/YellowConfig.h (100%) rename Boards/{YellowBoard => CYD-2432S024C}/Source/hal/YellowDisplay.cpp (100%) rename Boards/{YellowBoard => CYD-2432S024C}/Source/hal/YellowDisplay.h (100%) rename Boards/{YellowBoard => CYD-2432S024C}/Source/hal/YellowDisplayConstants.h (100%) rename Boards/{YellowBoard => CYD-2432S024C}/Source/hal/YellowSdCard.cpp (90%) rename Boards/{YellowBoard => CYD-2432S024C}/Source/hal/YellowSdCard.h (100%) rename Boards/{YellowBoard => CYD-2432S024C}/Source/hal/YellowTouch.cpp (100%) rename Boards/{YellowBoard => CYD-2432S024C}/Source/hal/YellowTouch.h (100%) rename Boards/{YellowBoard => CYD-2432S024C}/Source/hal/YellowTouchConstants.h (100%) create mode 100644 Tactility/Source/app/App.cpp rename sdkconfig.board.yellow-board => sdkconfig.board.cyd-2432S024c (93%) diff --git a/.github/workflows/build-firmware.yml b/.github/workflows/build-firmware.yml index 73883e53..66d8cd84 100644 --- a/.github/workflows/build-firmware.yml +++ b/.github/workflows/build-firmware.yml @@ -4,14 +4,14 @@ on: [push] permissions: read-all jobs: - yellow-board: + cyd-2432S024c: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: "Build" uses: ./.github/actions/build-firmware with: - board_id: yellow-board + board_id: cyd-2432S024c arch: esp32 lilygo-tdeck: runs-on: ubuntu-latest diff --git a/.github/workflows/build-sdk.yml b/.github/workflows/build-sdk.yml index 6f482bc4..495af5be 100644 --- a/.github/workflows/build-sdk.yml +++ b/.github/workflows/build-sdk.yml @@ -11,7 +11,7 @@ jobs: - name: "Build" uses: ./.github/actions/build-sdk with: - board_id: yellow-board + board_id: cyd-2432S024c arch: esp32 esp32s3: runs-on: ubuntu-latest diff --git a/App/CMakeLists.txt b/App/CMakeLists.txt index 1b3d133d..9ddae03c 100644 --- a/App/CMakeLists.txt +++ b/App/CMakeLists.txt @@ -5,7 +5,7 @@ if (DEFINED ENV{ESP_IDF_VERSION}) if("${IDF_TARGET}" STREQUAL "esp32") list(APPEND BOARD_COMPONENTS - YellowBoard + CYD-2432S024C M5stackCore2 ) endif() diff --git a/App/Kconfig b/App/Kconfig index 4c773242..0e392139 100644 --- a/App/Kconfig +++ b/App/Kconfig @@ -1,13 +1,18 @@ # Kconfig file for Tactility example app menu "Tactility App" + config TT_BOARD_NAME + string "Board Name" + default "" + config TT_BOARD_ID + string "Board ID" + default "" choice prompt "Board" default TT_BOARD_CUSTOM - config TT_BOARD_CUSTOM bool "Custom" - config TT_BOARD_YELLOW_BOARD_24_CAP - bool "Yellow Board (2.4\" capacitive)" + config TT_BOARD_CYD_2432S024C + bool "CYD 2432S024C" config TT_BOARD_LILYGO_TDECK bool "LilyGo T-Deck" config TT_BOARD_M5STACK_CORE2 diff --git a/App/Source/Boards.h b/App/Source/Boards.h index 5273f7dc..f4a6ab82 100644 --- a/App/Source/Boards.h +++ b/App/Source/Boards.h @@ -7,9 +7,9 @@ #if defined(CONFIG_TT_BOARD_LILYGO_TDECK) #include "LilygoTdeck.h" #define TT_BOARD_HARDWARE &lilygo_tdeck -#elif defined(CONFIG_TT_BOARD_YELLOW_BOARD_24_CAP) -#include "YellowBoard.h" -#define TT_BOARD_HARDWARE &yellow_board_24inch_cap +#elif defined(CONFIG_TT_BOARD_CYD_2432S024C) +#include "CYD2432S024C.h" +#define TT_BOARD_HARDWARE &cyd_2432S024c_config #elif defined(CONFIG_TT_BOARD_M5STACK_CORE2) #include "M5stackCore2.h" #define TT_BOARD_HARDWARE &m5stack_core2 diff --git a/Boards/YellowBoard/CMakeLists.txt b/Boards/CYD-2432S024C/CMakeLists.txt similarity index 100% rename from Boards/YellowBoard/CMakeLists.txt rename to Boards/CYD-2432S024C/CMakeLists.txt diff --git a/Boards/YellowBoard/Source/Boot.cpp b/Boards/CYD-2432S024C/Source/Boot.cpp similarity index 100% rename from Boards/YellowBoard/Source/Boot.cpp rename to Boards/CYD-2432S024C/Source/Boot.cpp diff --git a/Boards/YellowBoard/Source/YellowBoard.cpp b/Boards/CYD-2432S024C/Source/CYD2432S024C.cpp similarity index 94% rename from Boards/YellowBoard/Source/YellowBoard.cpp rename to Boards/CYD-2432S024C/Source/CYD2432S024C.cpp index 8a8aa9d5..728efa55 100644 --- a/Boards/YellowBoard/Source/YellowBoard.cpp +++ b/Boards/CYD-2432S024C/Source/CYD2432S024C.cpp @@ -1,11 +1,11 @@ -#include "YellowBoard.h" +#include "CYD2432S024C.h" #include "hal/YellowDisplay.h" #include "hal/YellowSdCard.h" bool twodotfour_lvgl_init(); bool twodotfour_boot(); -const tt::hal::Configuration yellow_board_24inch_cap = { +const tt::hal::Configuration cyd_2432S024c_config = { .initBoot = &twodotfour_boot, .initLvgl = &twodotfour_lvgl_init, .createDisplay = createDisplay, diff --git a/Boards/YellowBoard/Source/YellowBoard.h b/Boards/CYD-2432S024C/Source/CYD2432S024C.h similarity index 61% rename from Boards/YellowBoard/Source/YellowBoard.h rename to Boards/CYD-2432S024C/Source/CYD2432S024C.h index 03abb453..f9b4cff5 100644 --- a/Boards/YellowBoard/Source/YellowBoard.h +++ b/Boards/CYD-2432S024C/Source/CYD2432S024C.h @@ -3,4 +3,4 @@ #include "hal/Configuration.h" // Capacitive touch version of the 2.4" yellow board -extern const tt::hal::Configuration yellow_board_24inch_cap; +extern const tt::hal::Configuration cyd_2432S024c_config; diff --git a/Boards/YellowBoard/Source/Lvgl.cpp b/Boards/CYD-2432S024C/Source/Lvgl.cpp similarity index 100% rename from Boards/YellowBoard/Source/Lvgl.cpp rename to Boards/CYD-2432S024C/Source/Lvgl.cpp diff --git a/Boards/YellowBoard/Source/YellowConfig.h b/Boards/CYD-2432S024C/Source/YellowConfig.h similarity index 100% rename from Boards/YellowBoard/Source/YellowConfig.h rename to Boards/CYD-2432S024C/Source/YellowConfig.h diff --git a/Boards/YellowBoard/Source/hal/YellowDisplay.cpp b/Boards/CYD-2432S024C/Source/hal/YellowDisplay.cpp similarity index 100% rename from Boards/YellowBoard/Source/hal/YellowDisplay.cpp rename to Boards/CYD-2432S024C/Source/hal/YellowDisplay.cpp diff --git a/Boards/YellowBoard/Source/hal/YellowDisplay.h b/Boards/CYD-2432S024C/Source/hal/YellowDisplay.h similarity index 100% rename from Boards/YellowBoard/Source/hal/YellowDisplay.h rename to Boards/CYD-2432S024C/Source/hal/YellowDisplay.h diff --git a/Boards/YellowBoard/Source/hal/YellowDisplayConstants.h b/Boards/CYD-2432S024C/Source/hal/YellowDisplayConstants.h similarity index 100% rename from Boards/YellowBoard/Source/hal/YellowDisplayConstants.h rename to Boards/CYD-2432S024C/Source/hal/YellowDisplayConstants.h diff --git a/Boards/YellowBoard/Source/hal/YellowSdCard.cpp b/Boards/CYD-2432S024C/Source/hal/YellowSdCard.cpp similarity index 90% rename from Boards/YellowBoard/Source/hal/YellowSdCard.cpp rename to Boards/CYD-2432S024C/Source/hal/YellowSdCard.cpp index 4806d784..7465b57e 100644 --- a/Boards/YellowBoard/Source/hal/YellowSdCard.cpp +++ b/Boards/CYD-2432S024C/Source/hal/YellowSdCard.cpp @@ -7,11 +7,9 @@ #define SDCARD_SPI_HOST SPI3_HOST #define SDCARD_PIN_CS GPIO_NUM_5 -#define SDCARD_SPI_FREQUENCY 20000000U std::shared_ptr createYellowSdCard() { auto* configuration = new tt::hal::SpiSdCard::Config( - SDCARD_SPI_FREQUENCY, SDCARD_PIN_CS, GPIO_NUM_NC, GPIO_NUM_NC, diff --git a/Boards/YellowBoard/Source/hal/YellowSdCard.h b/Boards/CYD-2432S024C/Source/hal/YellowSdCard.h similarity index 100% rename from Boards/YellowBoard/Source/hal/YellowSdCard.h rename to Boards/CYD-2432S024C/Source/hal/YellowSdCard.h diff --git a/Boards/YellowBoard/Source/hal/YellowTouch.cpp b/Boards/CYD-2432S024C/Source/hal/YellowTouch.cpp similarity index 100% rename from Boards/YellowBoard/Source/hal/YellowTouch.cpp rename to Boards/CYD-2432S024C/Source/hal/YellowTouch.cpp diff --git a/Boards/YellowBoard/Source/hal/YellowTouch.h b/Boards/CYD-2432S024C/Source/hal/YellowTouch.h similarity index 100% rename from Boards/YellowBoard/Source/hal/YellowTouch.h rename to Boards/CYD-2432S024C/Source/hal/YellowTouch.h diff --git a/Boards/YellowBoard/Source/hal/YellowTouchConstants.h b/Boards/CYD-2432S024C/Source/hal/YellowTouchConstants.h similarity index 100% rename from Boards/YellowBoard/Source/hal/YellowTouchConstants.h rename to Boards/CYD-2432S024C/Source/hal/YellowTouchConstants.h diff --git a/Boards/LilygoTdeck/Source/hal/TdeckSdCard.cpp b/Boards/LilygoTdeck/Source/hal/TdeckSdCard.cpp index 5fe269bc..f6631f80 100644 --- a/Boards/LilygoTdeck/Source/hal/TdeckSdCard.cpp +++ b/Boards/LilygoTdeck/Source/hal/TdeckSdCard.cpp @@ -6,14 +6,12 @@ #include #include -#define TDECK_SDCARD_SPI_FREQUENCY 20000000U #define TDECK_SDCARD_PIN_CS GPIO_NUM_39 #define TDECK_LCD_PIN_CS GPIO_NUM_12 #define TDECK_RADIO_PIN_CS GPIO_NUM_9 std::shared_ptr createTdeckSdCard() { auto* configuration = new tt::hal::SpiSdCard::Config( - TDECK_SDCARD_SPI_FREQUENCY, TDECK_SDCARD_PIN_CS, GPIO_NUM_NC, GPIO_NUM_NC, diff --git a/Boards/M5stackCore2/Source/hal/Core2SdCard.cpp b/Boards/M5stackCore2/Source/hal/Core2SdCard.cpp index e59ce3ba..e1460377 100644 --- a/Boards/M5stackCore2/Source/hal/Core2SdCard.cpp +++ b/Boards/M5stackCore2/Source/hal/Core2SdCard.cpp @@ -5,13 +5,11 @@ #include -#define CORE2_SDCARD_SPI_FREQUENCY 20000000U #define CORE2_SDCARD_PIN_CS GPIO_NUM_4 #define CORE2_LCD_PIN_CS GPIO_NUM_5 std::shared_ptr createSdCard() { auto* configuration = new tt::hal::SpiSdCard::Config( - CORE2_SDCARD_SPI_FREQUENCY, CORE2_SDCARD_PIN_CS, GPIO_NUM_NC, GPIO_NUM_NC, diff --git a/Boards/M5stackCoreS3/Source/hal/CoreS3SdCard.cpp b/Boards/M5stackCoreS3/Source/hal/CoreS3SdCard.cpp index 4a5181d4..e8a4a8dc 100644 --- a/Boards/M5stackCoreS3/Source/hal/CoreS3SdCard.cpp +++ b/Boards/M5stackCoreS3/Source/hal/CoreS3SdCard.cpp @@ -5,13 +5,11 @@ #include -#define CORES3_SDCARD_SPI_FREQUENCY 20000000U #define CORES3_SDCARD_PIN_CS GPIO_NUM_4 #define CORES3_LCD_PIN_CS GPIO_NUM_3 std::shared_ptr createSdCard() { auto* configuration = new tt::hal::SpiSdCard::Config( - CORES3_SDCARD_SPI_FREQUENCY, CORES3_SDCARD_PIN_CS, GPIO_NUM_NC, GPIO_NUM_NC, diff --git a/Boards/UnPhone/Source/hal/UnPhoneSdCard.cpp b/Boards/UnPhone/Source/hal/UnPhoneSdCard.cpp index bbf6b82b..340e1dca 100644 --- a/Boards/UnPhone/Source/hal/UnPhoneSdCard.cpp +++ b/Boards/UnPhone/Source/hal/UnPhoneSdCard.cpp @@ -5,7 +5,6 @@ #include -#define UNPHONE_SDCARD_SPI_FREQUENCY 20000000U #define UNPHONE_SDCARD_PIN_CS GPIO_NUM_43 #define UNPHONE_LCD_PIN_CS GPIO_NUM_48 #define UNPHONE_LORA_PIN_CS GPIO_NUM_44 @@ -13,7 +12,6 @@ std::shared_ptr createUnPhoneSdCard() { auto* configuration = new tt::hal::SpiSdCard::Config( - UNPHONE_SDCARD_SPI_FREQUENCY, UNPHONE_SDCARD_PIN_CS, GPIO_NUM_NC, GPIO_NUM_NC, diff --git a/Buildscripts/CMake/TactilitySDK.cmake b/Buildscripts/CMake/TactilitySDK.cmake index 346d50cf..71afdc00 100644 --- a/Buildscripts/CMake/TactilitySDK.cmake +++ b/Buildscripts/CMake/TactilitySDK.cmake @@ -6,8 +6,6 @@ endfunction() macro(tactility_project project_name) set(TACTILITY_SKIP_SPIFFS 1) - add_definitions(-DESP_TARGET) - add_compile_definitions(ESP_TARGET) include("${TACTILITY_SDK_PATH}/Libraries/elf_loader/elf_loader.cmake") project_elf($project_name) diff --git a/CMakeLists.txt b/CMakeLists.txt index f1da537c..dde496e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,13 +8,13 @@ set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_CXX_COMPILER_TARGET}") include("Buildscripts/logo.cmake") +file(READ version.txt TACTILITY_VERSION) +add_compile_definitions(TT_VERSION="${TACTILITY_VERSION}") + if (DEFINED ENV{ESP_IDF_VERSION}) message("Building with ESP-IDF v$ENV{ESP_IDF_VERSION}") include($ENV{IDF_PATH}/tools/cmake/project.cmake) - add_definitions(-DESP_TARGET) - add_compile_definitions(ESP_TARGET) - set(COMPONENTS App) set(EXTRA_COMPONENT_DIRS "Boards" @@ -34,7 +34,7 @@ if (DEFINED ENV{ESP_IDF_VERSION}) # Non-ESP32 boards if(NOT "${IDF_TARGET}" STREQUAL "esp32") - set(EXCLUDE_COMPONENTS "YellowBoard") + set(EXCLUDE_COMPONENTS "CYD-2432S024C") set(EXCLUDE_COMPONENTS "M5stackCore2") endif() @@ -53,11 +53,10 @@ if (DEFINED ENV{ESP_IDF_VERSION}) add_compile_definitions(LV_CONF_PATH="${LVGL_CONFIG_FULL_PATH}/lv_conf_kconfig.h") idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=esp_panic_handler" APPEND) idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=esp_log_write" APPEND) - - file(READ version.txt TACTILITY_VERSION) - add_compile_definitions(TT_VERSION="${TACTILITY_VERSION}") else() message("Building for sim target") + add_compile_definitions(CONFIG_TT_BOARD_ID="simulator") + add_compile_definitions(CONFIG_TT_BOARD_NAME="Simulator") endif() project(Tactility) diff --git a/Documentation/ideas.md b/Documentation/ideas.md index 3c94332c..cec638fa 100644 --- a/Documentation/ideas.md +++ b/Documentation/ideas.md @@ -10,18 +10,12 @@ - Show error in WiFi screen (e.g. AlertDialog when SPI is not enabled and available memory is below a certain amount) - Clean up static_cast when casting to base class. - EventFlag: Fix return value of set/get/wait (the errors are weirdly mixed in) -- tt_check() failure during app argument bundle nullptr check seems to trigger SIGSEGV - Fix bug in T-Deck/etc: esp_lvgl_port settings has a large stack size (~9kB) to fix an issue where the T-Deck would get a stackoverflow. This sometimes happens when WiFi is auto-enabled and you open the app while it is still connecting. - M5Stack Core only shows 4MB of SPIRAM in use -- Try to improve Core2 and CoreS3 performance by setting swap_bytes of display driver to false (this is a software operation on the display buffer!) and use 24 bit colour mode if needed -- Files app: When SD card is not mounted, don't show it -- Crash log must mention board type - Oops crashlog site: Add copy-pasteable addr2line command (e.g. xtensa-esp32s3-elf-addr2line -pfiaC -e Tactility.elf 00000000) # TODOs - Experiment with what happens when using C++ code in an external app (without using standard library!) -- Get rid of "ESP_TARGET" and use official "ESP_PLATFORM" -- SpiSdCard should use SDMMC_FREQ_DEFAULT by default - Boards' CMakeLists.txt manually declare each source folder. Update them all to do a recursive search of all folders. - We currently build all boards for a given platform (e.g. ESP32S3), but it's better to filter all irrelevant ones based on the Kconfig board settings: Projects will load and compile faster as it won't compile all the dependencies of all these other boards @@ -43,7 +37,6 @@ - Explore LVGL9's FreeRTOS functionality - External app loading: Check version of Tactility and check ESP target hardware, to check for compatibility. - Scanning SD card for external apps and auto-register them (in a temporary register?) -- tt::app::start() and similar functions as proxies for Loader app start/stop/etc. - Support hot-plugging SD card # Nice-to-haves diff --git a/Tactility/Private/service/loader/Loader_i.h b/Tactility/Private/service/loader/Loader_i.h index 625f3875..35bb4405 100644 --- a/Tactility/Private/service/loader/Loader_i.h +++ b/Tactility/Private/service/loader/Loader_i.h @@ -14,22 +14,6 @@ namespace tt::service::loader { - -// region LoaderEvent - -typedef enum { - LoaderEventTypeApplicationStarted, - LoaderEventTypeApplicationShowing, - LoaderEventTypeApplicationHiding, - LoaderEventTypeApplicationStopped -} LoaderEventType; - -struct LoaderEvent { - LoaderEventType type; -}; - -// endregion LoaderEvent - // region LoaderMessage class LoaderMessageAppStart { diff --git a/Tactility/Source/Tactility.cpp b/Tactility/Source/Tactility.cpp index 18051e0e..7c9baafc 100644 --- a/Tactility/Source/Tactility.cpp +++ b/Tactility/Source/Tactility.cpp @@ -141,7 +141,7 @@ static void register_and_start_user_services(const std::vector _Nullable parameters) { + service::loader::startApp(id, std::move(parameters)); +} + +void stop() { + service::loader::stopApp(); +} + +std::shared_ptr _Nullable getCurrentAppContext() { + return service::loader::getCurrentAppContext(); +} + +std::shared_ptr _Nullable getCurrentApp() { + return service::loader::getCurrentApp(); +} + +} diff --git a/Tactility/Source/app/App.h b/Tactility/Source/app/App.h index 9d85caeb..b04d94ee 100644 --- a/Tactility/Source/app/App.h +++ b/Tactility/Source/app/App.h @@ -3,6 +3,7 @@ #include "AppContext.h" #include "Bundle.h" #include +#include // Forward declarations typedef struct _lv_obj_t lv_obj_t; @@ -75,4 +76,20 @@ public: template std::shared_ptr create() { return std::shared_ptr(new T); } +/** + * @brief Start an app + * @param[in] id application name or id + * @param[in] parameters optional parameters to pass onto the application + */ +void start(const std::string& id, std::shared_ptr _Nullable parameters = nullptr); + +/** @brief Stop the currently showing app. Show the previous app if any app was still running. */ +void stop(); + +/** @return the currently running app context (it is only ever null before the splash screen is shown) */ +std::shared_ptr _Nullable getCurrentAppContext(); + +/** @return the currently running app (it is only ever null before the splash screen is shown) */ +std::shared_ptr _Nullable getCurrentApp(); + } diff --git a/Tactility/Source/app/crashdiagnostics/CrashDiagnostics.cpp b/Tactility/Source/app/crashdiagnostics/CrashDiagnostics.cpp index 552f9872..699daebc 100644 --- a/Tactility/Source/app/crashdiagnostics/CrashDiagnostics.cpp +++ b/Tactility/Source/app/crashdiagnostics/CrashDiagnostics.cpp @@ -1,4 +1,4 @@ -#ifdef ESP_TARGET +#ifdef ESP_PLATFORM #include "app/crashdiagnostics/QrHelpers.h" #include "app/crashdiagnostics/QrUrl.h" diff --git a/Tactility/Source/app/crashdiagnostics/CrashDiagnostics.h b/Tactility/Source/app/crashdiagnostics/CrashDiagnostics.h index ebea78e0..9ffa03b0 100644 --- a/Tactility/Source/app/crashdiagnostics/CrashDiagnostics.h +++ b/Tactility/Source/app/crashdiagnostics/CrashDiagnostics.h @@ -1,6 +1,6 @@ #pragma once -#ifdef ESP_TARGET +#ifdef ESP_PLATFORM namespace tt::app::crashdiagnostics { diff --git a/Tactility/Source/app/crashdiagnostics/QrUrl.cpp b/Tactility/Source/app/crashdiagnostics/QrUrl.cpp index f74204f3..1c774f74 100644 --- a/Tactility/Source/app/crashdiagnostics/QrUrl.cpp +++ b/Tactility/Source/app/crashdiagnostics/QrUrl.cpp @@ -1,4 +1,4 @@ -#ifdef ESP_TARGET +#ifdef ESP_PLATFORM #include "app/crashdiagnostics/QrUrl.h" @@ -8,6 +8,8 @@ #include #include +#include + std::string getUrlFromCrashData() { auto crash_data = getRtcCrashData(); auto* stack_buffer = (uint32_t*) malloc(crash_data.callstackLength * 2 * sizeof(uint32_t)); @@ -28,6 +30,7 @@ std::string getUrlFromCrashData() { stream << "https://oops.tactility.one"; stream << "?v=" << TT_VERSION; // Version stream << "&a=" << CONFIG_IDF_TARGET; // Architecture + stream << "&b=" << CONFIG_TT_BOARD_ID; // Board identifier stream << "&s="; // Stacktrace for (int i = crash_data.callstackLength - 1; i >= 0; --i) { diff --git a/Tactility/Source/app/files/State.cpp b/Tactility/Source/app/files/State.cpp index 46881aeb..bcbac3eb 100644 --- a/Tactility/Source/app/files/State.cpp +++ b/Tactility/Source/app/files/State.cpp @@ -1,10 +1,11 @@ #include "app/files/State.h" #include "app/files/FileUtils.h" -#include "kernel/Kernel.h" #include "Log.h" #include "Partitions.h" +#include "TactilityHeadless.h" #include "hal/SdCard.h" +#include "kernel/Kernel.h" #include @@ -61,11 +62,22 @@ bool State::setEntriesForPath(const std::string& path) { .d_type = TT_DT_DIR, .d_name = DATA_PARTITION_NAME }); - dir_entries.push_back({ - .d_ino = 2, - .d_type = TT_DT_DIR, - .d_name = TT_SDCARD_MOUNT_NAME - }); + +#ifndef TT_SCREENSHOT_MODE + auto sdcard = tt::hal::getConfiguration()->sdcard; + if (sdcard != nullptr) { + auto state = sdcard->getState(); + if (state == hal::SdCard::State::Mounted) { +#endif + dir_entries.push_back({ + .d_ino = 2, + .d_type = TT_DT_DIR, + .d_name = TT_SDCARD_MOUNT_NAME + }); +#ifndef TT_SCREENSHOT_MODE + } + } +#endif current_path = path; selected_child_entry = ""; diff --git a/Tactility/Source/service/loader/Loader.cpp b/Tactility/Source/service/loader/Loader.cpp index c962d0c0..6099486c 100644 --- a/Tactility/Source/service/loader/Loader.cpp +++ b/Tactility/Source/service/loader/Loader.cpp @@ -49,10 +49,10 @@ static void loader_free() { loader_singleton = nullptr; } -void startApp(const std::string& id, const std::shared_ptr& parameters) { +void startApp(const std::string& id, std::shared_ptr parameters) { TT_LOG_I(TAG, "Start app %s", id.c_str()); tt_assert(loader_singleton); - auto message = std::make_shared(id, parameters); + auto message = std::make_shared(id, std::move(parameters)); loader_singleton->dispatcherThread->dispatch(onStartAppMessage, message); } diff --git a/Tactility/Source/service/loader/Loader.h b/Tactility/Source/service/loader/Loader.h index d74387b3..5e1dba69 100644 --- a/Tactility/Source/service/loader/Loader.h +++ b/Tactility/Source/service/loader/Loader.h @@ -8,15 +8,27 @@ namespace tt::service::loader { -typedef struct Loader Loader; +// region LoaderEvent for PubSub +typedef enum { + LoaderEventTypeApplicationStarted, + LoaderEventTypeApplicationShowing, + LoaderEventTypeApplicationHiding, + LoaderEventTypeApplicationStopped +} LoaderEventType; + +struct LoaderEvent { + LoaderEventType type; +}; + +// endregion LoaderEvent for PubSub /** * @brief Start an app * @param[in] id application name or id * @param[in] parameters optional parameters to pass onto the application */ -void startApp(const std::string& id, const std::shared_ptr& _Nullable parameters = nullptr); +void startApp(const std::string& id, std::shared_ptr _Nullable parameters = nullptr); /** @brief Stop the currently showing app. Show the previous app if any app was still running. */ void stopApp(); diff --git a/TactilityCore/Source/Check.cpp b/TactilityCore/Source/Check.cpp index 855ed8b2..1ce4f128 100644 --- a/TactilityCore/Source/Check.cpp +++ b/TactilityCore/Source/Check.cpp @@ -31,7 +31,7 @@ TT_NORETURN void _crash() { logTaskInfo(); logMemoryInfo(); // TODO: Add breakpoint when debugger is attached. -#ifdef ESP_TARGET +#ifdef ESP_PLATFORM esp_system_abort("System halted. Connect debugger for more info."); #endif __builtin_unreachable(); diff --git a/TactilityCore/Source/CoreDefines.h b/TactilityCore/Source/CoreDefines.h index f8313cf2..27ca7d9b 100644 --- a/TactilityCore/Source/CoreDefines.h +++ b/TactilityCore/Source/CoreDefines.h @@ -22,7 +22,7 @@ #define TT_ALIGN(n) __attribute__((aligned(n))) // Used by portENABLE_INTERRUPTS and portDISABLE_INTERRUPTS? -#ifdef ESP_TARGET +#ifdef ESP_PLATFORM #define TT_IS_IRQ_MODE() (xPortInIsrContext() == pdTRUE) #else #define TT_IS_IRQ_MODE() false diff --git a/TactilityCore/Source/Log.h b/TactilityCore/Source/Log.h index 4ee78c59..fa3470a2 100644 --- a/TactilityCore/Source/Log.h +++ b/TactilityCore/Source/Log.h @@ -2,7 +2,7 @@ #include "LogMessages.h" -#ifdef ESP_TARGET +#ifdef ESP_PLATFORM #include #else #include @@ -43,7 +43,7 @@ LogEntry* copyLogEntries(unsigned int& outIndex); } // namespace tt -#ifdef ESP_TARGET +#ifdef ESP_PLATFORM #define TT_LOG_E(tag, format, ...) \ ESP_LOGE(tag, format, ##__VA_ARGS__) @@ -75,4 +75,4 @@ void log(LogLevel level, const char* tag, const char* format, ...); #define TT_LOG_V(tag, format, ...) \ tt::log(tt::LogLevel::Trace, tag, format, ##__VA_ARGS__) -#endif // ESP_TARGET +#endif // ESP_PLATFORM diff --git a/TactilityHeadless/Private/EspInit.h b/TactilityHeadless/Private/EspInit.h index 73c3240d..af649ca4 100644 --- a/TactilityHeadless/Private/EspInit.h +++ b/TactilityHeadless/Private/EspInit.h @@ -1,6 +1,6 @@ #pragma once -#ifdef ESP_TARGET +#ifdef ESP_PLATFORM namespace tt { @@ -8,4 +8,4 @@ void initEsp(); } // namespace -#endif // ESP_TARGET \ No newline at end of file +#endif // ESP_PLATFORM \ No newline at end of file diff --git a/TactilityHeadless/Private/EspPartitions_i.h b/TactilityHeadless/Private/EspPartitions_i.h index fb2abe52..45e2298c 100644 --- a/TactilityHeadless/Private/EspPartitions_i.h +++ b/TactilityHeadless/Private/EspPartitions_i.h @@ -1,6 +1,6 @@ #pragma once -#ifdef ESP_TARGET +#ifdef ESP_PLATFORM #include "esp_err.h" @@ -10,4 +10,4 @@ esp_err_t initPartitionsEsp(); } // namespace -#endif // ESP_TARGET \ No newline at end of file +#endif // ESP_PLATFORM \ No newline at end of file diff --git a/TactilityHeadless/Source/PartitionsEsp.cpp b/TactilityHeadless/Source/PartitionsEsp.cpp index 0ba83ae3..ca415f6c 100644 --- a/TactilityHeadless/Source/PartitionsEsp.cpp +++ b/TactilityHeadless/Source/PartitionsEsp.cpp @@ -1,4 +1,4 @@ -#ifdef ESP_TARGET +#ifdef ESP_PLATFORM #include "EspPartitions_i.h" #include "Log.h" @@ -51,4 +51,4 @@ esp_err_t initPartitionsEsp() { } // namespace -#endif // ESP_TARGET +#endif // ESP_PLATFORM diff --git a/TactilityHeadless/Source/TactilityHeadless.cpp b/TactilityHeadless/Source/TactilityHeadless.cpp index 2f8afe53..bed67ea6 100644 --- a/TactilityHeadless/Source/TactilityHeadless.cpp +++ b/TactilityHeadless/Source/TactilityHeadless.cpp @@ -38,6 +38,7 @@ static void register_and_start_system_services() { } void initHeadless(const hal::Configuration& config) { + TT_LOG_I(TAG, "Tactility v%s on %s (%s)", TT_VERSION, CONFIG_TT_BOARD_NAME, CONFIG_TT_BOARD_ID); #ifdef ESP_PLATFORM initEsp(); #endif diff --git a/TactilityHeadless/Source/TactilityHeadlessEsp.cpp b/TactilityHeadless/Source/TactilityHeadlessEsp.cpp index 3fe800a6..63b44dfc 100644 --- a/TactilityHeadless/Source/TactilityHeadlessEsp.cpp +++ b/TactilityHeadless/Source/TactilityHeadlessEsp.cpp @@ -1,4 +1,4 @@ -#ifdef ESP_TARGET +#ifdef ESP_PLATFORM #include "TactilityCore.h" #include "EspPartitions_i.h" diff --git a/TactilityHeadless/Source/hal/SpiSdCard.cpp b/TactilityHeadless/Source/hal/SpiSdCard.cpp index 8976c2d3..1b08bff3 100644 --- a/TactilityHeadless/Source/hal/SpiSdCard.cpp +++ b/TactilityHeadless/Source/hal/SpiSdCard.cpp @@ -74,7 +74,7 @@ bool SpiSdCard::mountInternal(const char* mountPoint) { // The following value is from T-Deck repo's UnitTest.ino project: // https://github.com/Xinyuan-LilyGO/T-Deck/blob/master/examples/UnitTest/UnitTest.ino // Observation: Using this automatically sets the bus to 20MHz - host.max_freq_khz = config->spiFrequency / 1000U; + host.max_freq_khz = config->spiFrequencyKhz; host.slot = config->spiHost; esp_err_t result = esp_vfs_fat_sdspi_mount(mountPoint, &host, &slot_config, &mount_config, &card); diff --git a/TactilityHeadless/Source/hal/SpiSdCard.h b/TactilityHeadless/Source/hal/SpiSdCard.h index c7067e18..12bc26f8 100644 --- a/TactilityHeadless/Source/hal/SpiSdCard.h +++ b/TactilityHeadless/Source/hal/SpiSdCard.h @@ -19,7 +19,6 @@ class SpiSdCard : public tt::hal::SdCard { public: struct Config { Config( - int spiFrequency, gpio_num_t spiPinCs, gpio_num_t spiPinCd, gpio_num_t spiPinWp, @@ -27,8 +26,9 @@ public: MountBehaviour mountBehaviourAtBoot, std::shared_ptr lockable = nullptr, std::vector csPinWorkAround = std::vector(), - spi_host_device_t spiHost = SPI2_HOST - ) : spiFrequency(spiFrequency), + spi_host_device_t spiHost = SPI2_HOST, + int spiFrequencyKhz = SDMMC_FREQ_DEFAULT + ) : spiFrequencyKhz(spiFrequencyKhz), spiPinCs(spiPinCs), spiPinCd(spiPinCd), spiPinWp(spiPinWp), @@ -39,7 +39,7 @@ public: spiHost(spiHost) {} - int spiFrequency; + int spiFrequencyKhz; gpio_num_t spiPinCs; // Clock gpio_num_t spiPinCd; // Card detect gpio_num_t spiPinWp; // Write-protect diff --git a/TactilityHeadless/Source/hal/i2c/I2c.cpp b/TactilityHeadless/Source/hal/i2c/I2c.cpp index 825de98a..3490c1eb 100644 --- a/TactilityHeadless/Source/hal/i2c/I2c.cpp +++ b/TactilityHeadless/Source/hal/i2c/I2c.cpp @@ -1,4 +1,4 @@ -#ifdef ESP_TARGET +#ifdef ESP_PLATFORM #include "I2c.h" #include "Log.h" diff --git a/TactilityHeadless/Source/hal/i2c/I2cCompat.h b/TactilityHeadless/Source/hal/i2c/I2cCompat.h index 04fae41f..a7b4e189 100644 --- a/TactilityHeadless/Source/hal/i2c/I2cCompat.h +++ b/TactilityHeadless/Source/hal/i2c/I2cCompat.h @@ -1,6 +1,6 @@ #pragma once -#ifdef ESP_TARGET +#ifdef ESP_PLATFORM #include #include #else diff --git a/TactilityHeadless/Source/hal/i2c/I2cMock.cpp b/TactilityHeadless/Source/hal/i2c/I2cMock.cpp index e122652e..ad511dd7 100644 --- a/TactilityHeadless/Source/hal/i2c/I2cMock.cpp +++ b/TactilityHeadless/Source/hal/i2c/I2cMock.cpp @@ -1,4 +1,4 @@ -#ifndef ESP_TARGET +#ifndef ESP_PLATFORM /** * This code is based on i2c_manager from https://github.com/ropg/i2c_manager/blob/master/i2c_manager/i2c_manager.c (original has MIT license) diff --git a/TactilityHeadless/Source/service/wifi/WifiEsp.cpp b/TactilityHeadless/Source/service/wifi/WifiEsp.cpp index 75089b4b..d9b6d59c 100644 --- a/TactilityHeadless/Source/service/wifi/WifiEsp.cpp +++ b/TactilityHeadless/Source/service/wifi/WifiEsp.cpp @@ -1,4 +1,4 @@ -#ifdef ESP_TARGET +#ifdef ESP_PLATFORM #include "Wifi.h" @@ -970,4 +970,4 @@ extern const ServiceManifest manifest = { } // namespace -#endif // ESP_TARGET +#endif // ESP_PLATFORM diff --git a/TactilityHeadless/Source/service/wifi/WifiMock.cpp b/TactilityHeadless/Source/service/wifi/WifiMock.cpp index e19c46e9..4eade964 100644 --- a/TactilityHeadless/Source/service/wifi/WifiMock.cpp +++ b/TactilityHeadless/Source/service/wifi/WifiMock.cpp @@ -1,6 +1,6 @@ #include "Wifi.h" -#ifndef ESP_TARGET +#ifndef ESP_PLATFORM #include "Check.h" #include "Log.h" @@ -160,4 +160,4 @@ extern const ServiceManifest manifest = { } // namespace -#endif // ESP_TARGET \ No newline at end of file +#endif // ESP_PLATFORM \ No newline at end of file diff --git a/TactilityHeadless/Source/service/wifi/WifiSettingsEsp.cpp b/TactilityHeadless/Source/service/wifi/WifiSettingsEsp.cpp index 061fc30a..b5ab84ae 100644 --- a/TactilityHeadless/Source/service/wifi/WifiSettingsEsp.cpp +++ b/TactilityHeadless/Source/service/wifi/WifiSettingsEsp.cpp @@ -1,4 +1,4 @@ -#ifdef ESP_TARGET +#ifdef ESP_PLATFORM #include "WifiGlobals.h" #include "WifiSettings.h" @@ -144,4 +144,4 @@ bool remove(const char* ssid) { } // nemespace -#endif // ESP_TARGET \ No newline at end of file +#endif // ESP_PLATFORM \ No newline at end of file diff --git a/TactilityHeadless/Source/service/wifi/WifiSettingsMock.cpp b/TactilityHeadless/Source/service/wifi/WifiSettingsMock.cpp index 3c3860e2..58c7a403 100644 --- a/TactilityHeadless/Source/service/wifi/WifiSettingsMock.cpp +++ b/TactilityHeadless/Source/service/wifi/WifiSettingsMock.cpp @@ -1,4 +1,4 @@ -#ifndef ESP_TARGET +#ifndef ESP_PLATFORM #include "WifiSettings.h" #include "Log.h" @@ -25,4 +25,4 @@ bool remove(const char* ssid) { } // namespace -#endif // ESP_TARGET \ No newline at end of file +#endif // ESP_PLATFORM \ No newline at end of file diff --git a/sdkconfig.board.yellow-board b/sdkconfig.board.cyd-2432S024c similarity index 93% rename from sdkconfig.board.yellow-board rename to sdkconfig.board.cyd-2432S024c index 462c8799..0a7be86e 100644 --- a/sdkconfig.board.yellow-board +++ b/sdkconfig.board.cyd-2432S024c @@ -29,7 +29,9 @@ CONFIG_FATFS_LFN_HEAP=y CONFIG_FATFS_VOLUME_COUNT=3 # Hardware: Main -CONFIG_TT_BOARD_YELLOW_BOARD_24_CAP=y +CONFIG_TT_BOARD_CYD_2432S024C=y +CONFIG_TT_BOARD_NAME="CYD 2432S024C" +CONFIG_TT_BOARD_ID="cyd-2432S024c" CONFIG_IDF_TARGET="esp32" CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y diff --git a/sdkconfig.board.lilygo-tdeck b/sdkconfig.board.lilygo-tdeck index b5fecce8..01b9acf9 100644 --- a/sdkconfig.board.lilygo-tdeck +++ b/sdkconfig.board.lilygo-tdeck @@ -29,8 +29,10 @@ CONFIG_FATFS_LFN_HEAP=y CONFIG_FATFS_VOLUME_COUNT=3 # Hardware: Main -CONFIG_IDF_EXPERIMENTAL_FEATURES=y CONFIG_TT_BOARD_LILYGO_TDECK=y +CONFIG_TT_BOARD_NAME="LilyGo T-Deck" +CONFIG_TT_BOARD_ID="lilygo-tdeck" +CONFIG_IDF_EXPERIMENTAL_FEATURES=y CONFIG_IDF_TARGET="esp32s3" CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y diff --git a/sdkconfig.board.m5stack-core2 b/sdkconfig.board.m5stack-core2 index 1872fff6..5dd02e0e 100644 --- a/sdkconfig.board.m5stack-core2 +++ b/sdkconfig.board.m5stack-core2 @@ -29,8 +29,10 @@ CONFIG_FATFS_LFN_HEAP=y CONFIG_FATFS_VOLUME_COUNT=3 # Hardware: Main -CONFIG_IDF_EXPERIMENTAL_FEATURES=y CONFIG_TT_BOARD_M5STACK_CORE2=y +CONFIG_TT_BOARD_NAME="M5Stack Core2" +CONFIG_TT_BOARD_ID="m5stack-core2" +CONFIG_IDF_EXPERIMENTAL_FEATURES=y CONFIG_IDF_TARGET="esp32" CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y diff --git a/sdkconfig.board.m5stack-cores3 b/sdkconfig.board.m5stack-cores3 index 0de20431..c3eefef5 100644 --- a/sdkconfig.board.m5stack-cores3 +++ b/sdkconfig.board.m5stack-cores3 @@ -29,8 +29,10 @@ CONFIG_FATFS_LFN_HEAP=y CONFIG_FATFS_VOLUME_COUNT=3 # Hardware: Main -CONFIG_IDF_EXPERIMENTAL_FEATURES=y CONFIG_TT_BOARD_M5STACK_CORES3=y +CONFIG_TT_BOARD_NAME="M5Stack CoreS3" +CONFIG_TT_BOARD_ID="m5stack-cores3" +CONFIG_IDF_EXPERIMENTAL_FEATURES=y CONFIG_IDF_TARGET="esp32s3" CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y diff --git a/sdkconfig.board.unphone b/sdkconfig.board.unphone index bb114820..855555e6 100644 --- a/sdkconfig.board.unphone +++ b/sdkconfig.board.unphone @@ -30,6 +30,8 @@ CONFIG_FATFS_VOLUME_COUNT=3 # Hardware: Main CONFIG_TT_BOARD_UNPHONE=y +CONFIG_TT_BOARD_NAME="unPhone" +CONFIG_TT_BOARD_ID="unphone" CONFIG_IDF_TARGET="esp32s3" CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y