From faab6d825f096049cef5b6deca6ec2be7c9765eb Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Wed, 17 Sep 2025 23:42:49 +0200 Subject: [PATCH] Merge develop into main (#339) - Update ILI9341 driver to v2.0.1 - Lots of code cleanup for apps - Refactor app "type" into "category" and added flags to the manifest (for show/hide statusbar and for hidden apps) - Rename some ElfApp-related functionality and improved the way the static data was managed - Rename "filebrowser" to "files" - Added cstring functions to tt_init.cpp - Minor fix in Boot app - Updated external apps for SDK changes --- App/idf_component.yml | 2 +- CMakeLists.txt | 7 -- Documentation/ideas.md | 34 ++++++-- ExternalApps/Calculator/main/Source/main.cpp | 1 - ExternalApps/Calculator/manifest.properties | 2 +- ExternalApps/Calculator/tactility.py | 4 +- .../GraphicsDemo/main/Source/Main.cpp | 1 - ExternalApps/GraphicsDemo/manifest.properties | 2 +- ExternalApps/GraphicsDemo/tactility.py | 4 +- ExternalApps/HelloWorld/main/Source/main.c | 1 - ExternalApps/HelloWorld/manifest.properties | 2 +- ExternalApps/HelloWorld/tactility.py | 4 +- Tactility/Include/Tactility/app/App.h | 12 +-- Tactility/Include/Tactility/app/AppContext.h | 2 +- Tactility/Include/Tactility/app/AppManifest.h | 26 +++--- Tactility/Include/Tactility/app/ElfApp.h | 4 +- .../Include/Tactility/app/addgps/AddGps.h | 1 - .../Tactility/app/alertdialog/AlertDialog.h | 43 +++++----- .../Tactility/app/filebrowser/FileBrowser.h | 2 +- .../Tactility/app/inputdialog/InputDialog.h | 1 - .../app/selectiondialog/SelectionDialog.h | 15 ++-- Tactility/Private/Tactility/app/AppInstance.h | 8 +- .../app/{filebrowser => files}/State.h | 14 ++-- .../{filebrowser => files}/SupportedFiles.h | 2 +- .../app/{filebrowser => files}/View.h | 6 +- .../Tactility/app/fileselection/State.h | 2 +- .../Tactility/app/fileselection/View.h | 4 +- .../app/i2cscanner/I2cScannerPrivate.h | 7 -- .../Tactility/app/launcher/TextResources.h | 2 +- .../app/localesettings/TextResources.h | 2 +- .../Tactility/app/serialconsole/ConnectView.h | 16 ++-- .../Tactility/app/serialconsole/ConsoleView.h | 13 ++- .../Tactility/app/serialconsole/View.h | 2 - .../app/wifiapsettings/WifiApSettings.h | 4 +- .../Private/Tactility/app/wificonnect/State.h | 2 +- .../Private/Tactility/app/wificonnect/View.h | 4 +- .../Tactility/app/wificonnect/WifiConnect.h | 13 ++- .../Private/Tactility/app/wifimanage/State.h | 4 +- .../Private/Tactility/app/wifimanage/View.h | 8 +- .../app/wifimanage/WifiManagePrivate.h | 4 +- Tactility/Source/Tactility.cpp | 6 +- Tactility/Source/app/AppInstall.cpp | 2 +- Tactility/Source/app/ElfApp.cpp | 81 ++++++++++--------- Tactility/Source/app/addgps/AddGps.cpp | 3 +- .../Source/app/alertdialog/AlertDialog.cpp | 3 +- Tactility/Source/app/applist/AppList.cpp | 7 +- Tactility/Source/app/boot/Boot.cpp | 4 +- .../app/crashdiagnostics/CrashDiagnostics.cpp | 3 +- .../Source/app/development/Development.cpp | 2 +- Tactility/Source/app/display/Display.cpp | 2 +- .../FileBrowser.cpp => files/FilesApp.cpp} | 21 ++--- .../app/{filebrowser => files}/State.cpp | 10 +-- .../{filebrowser => files}/SupportedFiles.cpp | 4 +- .../app/{filebrowser => files}/View.cpp | 26 +++--- .../app/fileselection/FileSelection.cpp | 3 +- Tactility/Source/app/gpio/Gpio.cpp | 2 +- .../Source/app/gpssettings/GpsSettings.cpp | 12 +-- .../Source/app/i2cscanner/I2cScanner.cpp | 38 ++++----- .../Source/app/i2csettings/I2cSettings.cpp | 2 +- .../Source/app/imageviewer/ImageViewer.cpp | 3 +- .../Source/app/inputdialog/InputDialog.cpp | 3 +- Tactility/Source/app/launcher/Launcher.cpp | 2 +- .../app/localesettings/LocaleSettings.cpp | 2 +- Tactility/Source/app/log/Log.cpp | 2 +- Tactility/Source/app/power/Power.cpp | 2 +- .../Source/app/screenshot/Screenshot.cpp | 2 +- .../app/selectiondialog/SelectionDialog.cpp | 3 +- .../app/serialconsole/SerialConsole.cpp | 4 +- Tactility/Source/app/settings/Settings.cpp | 5 +- .../Source/app/systeminfo/SystemInfo.cpp | 2 +- .../app/timedatesettings/TimeDateSettings.cpp | 2 +- Tactility/Source/app/timezone/TimeZone.cpp | 32 +++----- .../Source/app/usbsettings/UsbSettings.cpp | 2 +- .../app/wifiapsettings/WifiApSettings.cpp | 23 +++--- .../Source/app/wificonnect/WifiConnect.cpp | 3 +- .../Source/app/wifimanage/WifiManage.cpp | 2 +- Tactility/Source/service/gui/GuiService.cpp | 7 +- Tactility/Source/service/loader/Loader.cpp | 4 +- .../Source/service/statusbar/Statusbar.cpp | 71 ++++++++-------- TactilityC/Include/tt_app_manifest.h | 4 - TactilityC/Source/tt_app_manifest.cpp | 8 +- TactilityC/Source/tt_init.cpp | 3 + 82 files changed, 349 insertions(+), 360 deletions(-) delete mode 100644 Tactility/Include/Tactility/app/addgps/AddGps.h rename Tactility/Private/Tactility/app/{filebrowser => files}/State.h (83%) rename Tactility/Private/Tactility/app/{filebrowser => files}/SupportedFiles.h (86%) rename Tactility/Private/Tactility/app/{filebrowser => files}/View.h (92%) rename Tactility/{Include => Private}/Tactility/app/serialconsole/ConnectView.h (94%) rename Tactility/{Include => Private}/Tactility/app/serialconsole/ConsoleView.h (98%) rename Tactility/{Include => Private}/Tactility/app/serialconsole/View.h (84%) rename Tactility/Source/app/{filebrowser/FileBrowser.cpp => files/FilesApp.cpp} (72%) rename Tactility/Source/app/{filebrowser => files}/State.cpp (94%) rename Tactility/Source/app/{filebrowser => files}/SupportedFiles.cpp (92%) rename Tactility/Source/app/{filebrowser => files}/View.cpp (95%) diff --git a/App/idf_component.yml b/App/idf_component.yml index 7911da66..1d33b876 100644 --- a/App/idf_component.yml +++ b/App/idf_component.yml @@ -1,5 +1,5 @@ dependencies: - espressif/esp_lcd_ili9341: "2.0.0" + espressif/esp_lcd_ili9341: "2.0.1" atanisoft/esp_lcd_ili9488: "1.0.10" espressif/esp_lcd_touch: "1.1.2" atanisoft/esp_lcd_touch_xpt2046: "1.0.5" diff --git a/CMakeLists.txt b/CMakeLists.txt index 59a74c62..7f44b7d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,13 +48,6 @@ if (DEFINED ENV{ESP_IDF_VERSION}) set(EXCLUDE_COMPONENTS "Simulator") - # LVGL -# set(LV_CONF_PATH Libraries/lvgl/src/lv_conf_kconfig.h) -# get_filename_component( -# LV_CONF_PATH Libraries/lvgl/src/lv_conf_kconfig.h ABSOLUTE -# ) -# add_compile_definitions(LV_CONF_PATH="${LVGL_CONFIG_FULL_PATH}") - idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=esp_panic_handler" APPEND) idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=esp_log_write" APPEND) idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=lv_button_create" APPEND) diff --git a/Documentation/ideas.md b/Documentation/ideas.md index 6f674894..816bdfe8 100644 --- a/Documentation/ideas.md +++ b/Documentation/ideas.md @@ -3,20 +3,18 @@ ## Higher Priority - Show a warning in the web installer when flashing CYD 28R board regarding v1/v2/v3 -- 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 - 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 -- Update ILI934x to v2.0.1 -- Apps with update timer in onCreate() should check `lvgl::isStarted()` - CrowPanel Basic 3.5": check why GraphicsDemo fails - CrowPanel Basic 3.5": check why System Info doesn't show storage info -- Update to LVGL v9.3 stable -- Create `app::getSettingsPath()` to get paths to properties files by first trying sd card and then trying `/data` +- When an SD card is detected, check if it has been initialized and assigned as data partition. + If the user choses to select it, then copy files from /data over to it. + Write the user choice to a file on the card. + File contains 3 statuses: ignore, data, .. initdata? + The latter is used for auto-selecting it as data partition. ## Medium Priority @@ -33,7 +31,6 @@ ## Lower Priority -- Rename `filebrowser` to `files` and `FileBrowser.cpp` to `Files.cpp` - Implement system suspend that turns off the screen - The boot button on some devices can be used as GPIO_NUM_0 at runtime - Localize all apps @@ -95,3 +92,24 @@ - Display touch calibration - RSS reader - Static file web server (with option to specify path and port) +- Diceware + +# App Store + +- Register user + - Name + - Company + - Email + - Password +- Create/destroy session +- List apps + - Install app + - App ID + - App version +- Add/remove API key +- Upload app + - Category + - File + - Name + - Description +- List apps \ No newline at end of file diff --git a/ExternalApps/Calculator/main/Source/main.cpp b/ExternalApps/Calculator/main/Source/main.cpp index dc56360e..6dc187d3 100644 --- a/ExternalApps/Calculator/main/Source/main.cpp +++ b/ExternalApps/Calculator/main/Source/main.cpp @@ -14,7 +14,6 @@ static void destroyApp(void* app) { } ExternalAppManifest manifest = { - .name = "Hello World", .createData = createApp, .destroyData = destroyApp, .onShow = onShow, diff --git a/ExternalApps/Calculator/manifest.properties b/ExternalApps/Calculator/manifest.properties index c193497f..ad8abb36 100644 --- a/ExternalApps/Calculator/manifest.properties +++ b/ExternalApps/Calculator/manifest.properties @@ -1,7 +1,7 @@ [manifest] version=0.1 [target] -sdk=0.5.0 +sdk=0.6.0-SNAPSHOT1 platforms=esp32,esp32s3 [app] id=com.bytewelder.calculator diff --git a/ExternalApps/Calculator/tactility.py b/ExternalApps/Calculator/tactility.py index 0f733e3a..292e61e9 100644 --- a/ExternalApps/Calculator/tactility.py +++ b/ExternalApps/Calculator/tactility.py @@ -14,7 +14,7 @@ import shutil import configparser ttbuild_path = ".tactility" -ttbuild_version = "2.1.0" +ttbuild_version = "2.1.1" ttbuild_cdn = "https://cdn.tactility.one" ttbuild_sdk_json_validity = 3600 # seconds ttport = 6666 @@ -618,7 +618,7 @@ if __name__ == "__main__": print_help() exit_with_error("Commandline parameter missing") uninstall_action(manifest, sys.argv[2]) - elif action_arg == "bir": + elif action_arg == "bir" or action_arg == "brrr": if len(sys.argv) < 3: print_help() exit_with_error("Commandline parameter missing") diff --git a/ExternalApps/GraphicsDemo/main/Source/Main.cpp b/ExternalApps/GraphicsDemo/main/Source/Main.cpp index 4b5a8d2c..c8f994cc 100644 --- a/ExternalApps/GraphicsDemo/main/Source/Main.cpp +++ b/ExternalApps/GraphicsDemo/main/Source/Main.cpp @@ -89,7 +89,6 @@ static void onDestroy(AppHandle appHandle, void* data) { } ExternalAppManifest manifest = { - .name = "Hello World", .onCreate = onCreate, .onDestroy = onDestroy }; diff --git a/ExternalApps/GraphicsDemo/manifest.properties b/ExternalApps/GraphicsDemo/manifest.properties index aa1ffef7..69374cbe 100644 --- a/ExternalApps/GraphicsDemo/manifest.properties +++ b/ExternalApps/GraphicsDemo/manifest.properties @@ -1,7 +1,7 @@ [manifest] version=0.1 [target] -sdk=0.5.0 +sdk=0.6.0-SNAPSHOT1 platforms=esp32,esp32s3 [app] id=com.bytewelder.graphicsdemo diff --git a/ExternalApps/GraphicsDemo/tactility.py b/ExternalApps/GraphicsDemo/tactility.py index 0f733e3a..292e61e9 100644 --- a/ExternalApps/GraphicsDemo/tactility.py +++ b/ExternalApps/GraphicsDemo/tactility.py @@ -14,7 +14,7 @@ import shutil import configparser ttbuild_path = ".tactility" -ttbuild_version = "2.1.0" +ttbuild_version = "2.1.1" ttbuild_cdn = "https://cdn.tactility.one" ttbuild_sdk_json_validity = 3600 # seconds ttport = 6666 @@ -618,7 +618,7 @@ if __name__ == "__main__": print_help() exit_with_error("Commandline parameter missing") uninstall_action(manifest, sys.argv[2]) - elif action_arg == "bir": + elif action_arg == "bir" or action_arg == "brrr": if len(sys.argv) < 3: print_help() exit_with_error("Commandline parameter missing") diff --git a/ExternalApps/HelloWorld/main/Source/main.c b/ExternalApps/HelloWorld/main/Source/main.c index f50e0407..4048adea 100644 --- a/ExternalApps/HelloWorld/main/Source/main.c +++ b/ExternalApps/HelloWorld/main/Source/main.c @@ -15,7 +15,6 @@ static void onShow(AppHandle app, void* data, lv_obj_t* parent) { } ExternalAppManifest manifest = { - .name = "Hello World", .onShow = onShow }; diff --git a/ExternalApps/HelloWorld/manifest.properties b/ExternalApps/HelloWorld/manifest.properties index beff38c7..8c1322b6 100644 --- a/ExternalApps/HelloWorld/manifest.properties +++ b/ExternalApps/HelloWorld/manifest.properties @@ -1,7 +1,7 @@ [manifest] version=0.1 [target] -sdk=0.5.0 +sdk=0.6.0-SNAPSHOT1 platforms=esp32,esp32s3 [app] id=com.bytewelder.helloworld diff --git a/ExternalApps/HelloWorld/tactility.py b/ExternalApps/HelloWorld/tactility.py index 0f733e3a..292e61e9 100644 --- a/ExternalApps/HelloWorld/tactility.py +++ b/ExternalApps/HelloWorld/tactility.py @@ -14,7 +14,7 @@ import shutil import configparser ttbuild_path = ".tactility" -ttbuild_version = "2.1.0" +ttbuild_version = "2.1.1" ttbuild_cdn = "https://cdn.tactility.one" ttbuild_sdk_json_validity = 3600 # seconds ttport = 6666 @@ -618,7 +618,7 @@ if __name__ == "__main__": print_help() exit_with_error("Commandline parameter missing") uninstall_action(manifest, sys.argv[2]) - elif action_arg == "bir": + elif action_arg == "bir" or action_arg == "brrr": if len(sys.argv) < 3: print_help() exit_with_error("Commandline parameter missing") diff --git a/Tactility/Include/Tactility/app/App.h b/Tactility/Include/Tactility/app/App.h index 701a3b44..cf98611b 100644 --- a/Tactility/Include/Tactility/app/App.h +++ b/Tactility/Include/Tactility/app/App.h @@ -64,14 +64,14 @@ public: auto lock = getMutex().asScopedLock(); lock.lock(); - if (resultHolder != nullptr) { - outResult = resultHolder->result; - outBundle = std::move(resultHolder->resultData); - resultHolder = nullptr; - return true; - } else { + if (resultHolder == nullptr) { return false; } + + outResult = resultHolder->result; + outBundle = std::move(resultHolder->resultData); + resultHolder = nullptr; + return true; } }; diff --git a/Tactility/Include/Tactility/app/AppContext.h b/Tactility/Include/Tactility/app/AppContext.h index 95eeb7b5..6f90b8fd 100644 --- a/Tactility/Include/Tactility/app/AppContext.h +++ b/Tactility/Include/Tactility/app/AppContext.h @@ -13,7 +13,7 @@ enum class Result; typedef union { struct { - bool showStatusbar : 1; + bool hideStatusbar : 1; }; unsigned char flags; } Flags; diff --git a/Tactility/Include/Tactility/app/AppManifest.h b/Tactility/Include/Tactility/app/AppManifest.h index 537cbc17..63f74d5f 100644 --- a/Tactility/Include/Tactility/app/AppManifest.h +++ b/Tactility/Include/Tactility/app/AppManifest.h @@ -1,6 +1,6 @@ #pragma once -#include "Tactility/app/AppRegistration.h" +#include #include @@ -10,13 +10,7 @@ class App; class AppContext; /** Application types */ -enum class Type { - /** Boot screen, shown before desktop is launched. */ - Boot, - /** A launcher app sits at the root of the app stack after the boot splash is finished */ - Launcher, - /** Apps that generally aren't started from the desktop (e.g. image viewer) */ - Hidden, +enum class Category { /** Standard apps, provided by the system. */ System, /** The apps that are launched/shown by the Settings app. The Settings app itself is of type AppTypeSystem. */ @@ -60,6 +54,15 @@ public: typedef std::shared_ptr(*CreateApp)(); struct AppManifest { + + struct Flags { + constexpr static uint32_t None = 0; + /** Don't show the statusbar */ + constexpr static uint32_t HideStatusBar = 1 << 0; + /** Hint to other systems to not show this app (e.g. in launcher or settings) */ + constexpr static uint32_t Hidden = 1 << 1; + }; + /** The identifier by which the app is launched by the system and other apps. */ std::string id = {}; @@ -69,12 +72,15 @@ struct AppManifest { /** Optional icon. */ std::string icon = {}; - /** App type affects launch behaviour. */ - Type type = Type::User; + /** App category helps with listing apps in Launcher, app list or settings apps. */ + Category category = Category::User; /** Where the app is located */ Location location = Location::internal(); + /** Controls various settings */ + uint32_t flags = Flags::None; + /** Create the instance of the app */ CreateApp createApp = nullptr; }; diff --git a/Tactility/Include/Tactility/app/ElfApp.h b/Tactility/Include/Tactility/app/ElfApp.h index d68e1b52..b1dd61f2 100644 --- a/Tactility/Include/Tactility/app/ElfApp.h +++ b/Tactility/Include/Tactility/app/ElfApp.h @@ -14,9 +14,7 @@ typedef void (*OnShow)(void* appContext, void* _Nullable data, lv_obj_t* parent) typedef void (*OnHide)(void* appContext, void* _Nullable data); typedef void (*OnResult)(void* appContext, void* _Nullable data, LaunchId launchId, Result result, Bundle* resultData); -void setElfAppManifest( - const char* name, - const char* _Nullable icon, +void setElfAppParameters( CreateData _Nullable createData, DestroyData _Nullable destroyData, OnCreate _Nullable onCreate, diff --git a/Tactility/Include/Tactility/app/addgps/AddGps.h b/Tactility/Include/Tactility/app/addgps/AddGps.h deleted file mode 100644 index 6f70f09b..00000000 --- a/Tactility/Include/Tactility/app/addgps/AddGps.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/Tactility/Include/Tactility/app/alertdialog/AlertDialog.h b/Tactility/Include/Tactility/app/alertdialog/AlertDialog.h index ff04a74e..10f38ee8 100644 --- a/Tactility/Include/Tactility/app/alertdialog/AlertDialog.h +++ b/Tactility/Include/Tactility/app/alertdialog/AlertDialog.h @@ -14,27 +14,28 @@ */ namespace tt::app::alertdialog { - /** - * Show a dialog with the provided title, message and 0, 1 or more buttons. - * @param[in] title the title to show in the toolbar - * @param[in] message the message to display - * @param[in] buttonLabels the buttons to show - * @return the launch id - */ - LaunchId start(const std::string& title, const std::string& message, const std::vector& buttonLabels); +/** + * Show a dialog with the provided title, message and 0, 1 or more buttons. + * @param[in] title the title to show in the toolbar + * @param[in] message the message to display + * @param[in] buttonLabels the buttons to show + * @return the launch id + */ +LaunchId start(const std::string& title, const std::string& message, const std::vector& buttonLabels); - /** - * Show a dialog with the provided title, message and an OK button - * @param[in] title the title to show in the toolbar - * @param[in] message the message to display - * @return the launch id - */ - LaunchId start(const std::string& title, const std::string& message); +/** + * Show a dialog with the provided title, message and an OK button + * @param[in] title the title to show in the toolbar + * @param[in] message the message to display + * @return the launch id + */ +LaunchId start(const std::string& title, const std::string& message); + +/** + * Get the index of the button that the user selected. + * + * @return a value greater than 0 when a selection was done, or -1 when the app was closed clicking one of the selection buttons. + */ +int32_t getResultIndex(const Bundle& bundle); - /** - * Get the index of the button that the user selected. - * - * @return a value greater than 0 when a selection was done, or -1 when the app was closed clicking one of the selection buttons. - */ - int32_t getResultIndex(const Bundle& bundle); } diff --git a/Tactility/Include/Tactility/app/filebrowser/FileBrowser.h b/Tactility/Include/Tactility/app/filebrowser/FileBrowser.h index 86fcf424..f0c2f88a 100644 --- a/Tactility/Include/Tactility/app/filebrowser/FileBrowser.h +++ b/Tactility/Include/Tactility/app/filebrowser/FileBrowser.h @@ -1,6 +1,6 @@ #pragma once -namespace tt::app::filebrowser { +namespace tt::app::files { void start(); diff --git a/Tactility/Include/Tactility/app/inputdialog/InputDialog.h b/Tactility/Include/Tactility/app/inputdialog/InputDialog.h index df0c8e84..44cf3325 100644 --- a/Tactility/Include/Tactility/app/inputdialog/InputDialog.h +++ b/Tactility/Include/Tactility/app/inputdialog/InputDialog.h @@ -3,7 +3,6 @@ #include #include -#include /** * Start the app by its ID and provide: diff --git a/Tactility/Include/Tactility/app/selectiondialog/SelectionDialog.h b/Tactility/Include/Tactility/app/selectiondialog/SelectionDialog.h index de964017..6eaf9134 100644 --- a/Tactility/Include/Tactility/app/selectiondialog/SelectionDialog.h +++ b/Tactility/Include/Tactility/app/selectiondialog/SelectionDialog.h @@ -15,12 +15,13 @@ */ namespace tt::app::selectiondialog { - void start(const std::string& title, const std::vector& items); +void start(const std::string& title, const std::vector& items); + +/** + * Get the index of the item that the user selected. + * + * @return a value greater than 0 when a selection was done, or -1 when the app was closed without selecting an item. + */ +int32_t getResultIndex(const Bundle& bundle); - /** - * Get the index of the item that the user selected. - * - * @return a value greater than 0 when a selection was done, or -1 when the app was closed without selecting an item. - */ - int32_t getResultIndex(const Bundle& bundle); } diff --git a/Tactility/Private/Tactility/app/AppInstance.h b/Tactility/Private/Tactility/app/AppInstance.h index f38cfb2b..7b1ce70d 100644 --- a/Tactility/Private/Tactility/app/AppInstance.h +++ b/Tactility/Private/Tactility/app/AppInstance.h @@ -1,8 +1,8 @@ #pragma once -#include "Tactility/app/AppContext.h" -#include "Tactility/app/AppManifest.h" -#include "Tactility/app/ElfApp.h" +#include +#include +#include #include #include @@ -29,7 +29,7 @@ class AppInstance : public AppContext { const std::shared_ptr manifest; State state = State::Initial; LaunchId launchId; - Flags flags = { .showStatusbar = true }; + Flags flags = { .hideStatusbar = true }; /** @brief Optional parameters to start the app with * When these are stored in the app struct, the struct takes ownership. * Do not mutate after app creation. diff --git a/Tactility/Private/Tactility/app/filebrowser/State.h b/Tactility/Private/Tactility/app/files/State.h similarity index 83% rename from Tactility/Private/Tactility/app/filebrowser/State.h rename to Tactility/Private/Tactility/app/files/State.h index 04308e3d..5f2deab5 100644 --- a/Tactility/Private/Tactility/app/filebrowser/State.h +++ b/Tactility/Private/Tactility/app/files/State.h @@ -6,9 +6,9 @@ #include #include -namespace tt::app::filebrowser { +namespace tt::app::files { -class State { +class State final { public: @@ -44,7 +44,7 @@ public: template &> Func> void withEntries(Func&& onEntries) const { - mutex.withLock([&]() { + mutex.withLock([&] { std::invoke(std::forward(onEntries), dir_entries); }); } @@ -61,13 +61,9 @@ public: std::string getSelectedChildPath() const; - PendingAction getPendingAction() const { - return action; - } + PendingAction getPendingAction() const { return action; } - void setPendingAction(PendingAction newAction) { - action = newAction; - } + void setPendingAction(PendingAction newAction) { action = newAction; } }; } diff --git a/Tactility/Private/Tactility/app/filebrowser/SupportedFiles.h b/Tactility/Private/Tactility/app/files/SupportedFiles.h similarity index 86% rename from Tactility/Private/Tactility/app/filebrowser/SupportedFiles.h rename to Tactility/Private/Tactility/app/files/SupportedFiles.h index 563d8bdd..b62dde77 100644 --- a/Tactility/Private/Tactility/app/filebrowser/SupportedFiles.h +++ b/Tactility/Private/Tactility/app/files/SupportedFiles.h @@ -2,7 +2,7 @@ #include -namespace tt::app::filebrowser { +namespace tt::app::files { bool isSupportedAppFile(const std::string& filename); bool isSupportedImageFile(const std::string& filename); diff --git a/Tactility/Private/Tactility/app/filebrowser/View.h b/Tactility/Private/Tactility/app/files/View.h similarity index 92% rename from Tactility/Private/Tactility/app/filebrowser/View.h rename to Tactility/Private/Tactility/app/files/View.h index 18e7915b..92fd5ffa 100644 --- a/Tactility/Private/Tactility/app/filebrowser/View.h +++ b/Tactility/Private/Tactility/app/files/View.h @@ -2,14 +2,14 @@ #include "./State.h" -#include "Tactility/app/AppManifest.h" +#include #include #include -namespace tt::app::filebrowser { +namespace tt::app::files { -class View { +class View final { std::shared_ptr state; lv_obj_t* dir_entry_list = nullptr; diff --git a/Tactility/Private/Tactility/app/fileselection/State.h b/Tactility/Private/Tactility/app/fileselection/State.h index 912f8466..15ad6f9f 100644 --- a/Tactility/Private/Tactility/app/fileselection/State.h +++ b/Tactility/Private/Tactility/app/fileselection/State.h @@ -8,7 +8,7 @@ namespace tt::app::fileselection { -class State { +class State final { Mutex mutex = Mutex(Mutex::Type::Recursive); std::vector dir_entries; diff --git a/Tactility/Private/Tactility/app/fileselection/View.h b/Tactility/Private/Tactility/app/fileselection/View.h index 4f8d2085..eb8f2c85 100644 --- a/Tactility/Private/Tactility/app/fileselection/View.h +++ b/Tactility/Private/Tactility/app/fileselection/View.h @@ -3,14 +3,14 @@ #include "./State.h" #include "./FileSelectionPrivate.h" -#include "Tactility/app/AppManifest.h" +#include #include #include namespace tt::app::fileselection { -class View { +class View final { std::shared_ptr state; lv_obj_t* dir_entry_list = nullptr; diff --git a/Tactility/Private/Tactility/app/i2cscanner/I2cScannerPrivate.h b/Tactility/Private/Tactility/app/i2cscanner/I2cScannerPrivate.h index 569975a2..a6183586 100644 --- a/Tactility/Private/Tactility/app/i2cscanner/I2cScannerPrivate.h +++ b/Tactility/Private/Tactility/app/i2cscanner/I2cScannerPrivate.h @@ -1,12 +1,5 @@ #pragma once -#include -#include -#include -#include -#include - -#include #include namespace tt::app::i2cscanner { diff --git a/Tactility/Private/Tactility/app/launcher/TextResources.h b/Tactility/Private/Tactility/app/launcher/TextResources.h index efb5acd9..0890ab8a 100644 --- a/Tactility/Private/Tactility/app/launcher/TextResources.h +++ b/Tactility/Private/Tactility/app/launcher/TextResources.h @@ -1,6 +1,6 @@ #pragma once -#include "Tactility/i18n/TextResources.h" +#include // WARNING: This file is auto-generated. Do not edit manually. diff --git a/Tactility/Private/Tactility/app/localesettings/TextResources.h b/Tactility/Private/Tactility/app/localesettings/TextResources.h index 08728900..e6c4bb05 100644 --- a/Tactility/Private/Tactility/app/localesettings/TextResources.h +++ b/Tactility/Private/Tactility/app/localesettings/TextResources.h @@ -1,6 +1,6 @@ #pragma once -#include "Tactility/i18n/TextResources.h" +#include // WARNING: This file is auto-generated. Do not edit manually. diff --git a/Tactility/Include/Tactility/app/serialconsole/ConnectView.h b/Tactility/Private/Tactility/app/serialconsole/ConnectView.h similarity index 94% rename from Tactility/Include/Tactility/app/serialconsole/ConnectView.h rename to Tactility/Private/Tactility/app/serialconsole/ConnectView.h index b34ec561..d3451f92 100644 --- a/Tactility/Include/Tactility/app/serialconsole/ConnectView.h +++ b/Tactility/Private/Tactility/app/serialconsole/ConnectView.h @@ -1,13 +1,13 @@ #pragma once -#include "./View.h" +#include "View.h" -#include "Tactility/Preferences.h" -#include "Tactility/Tactility.h" -#include "Tactility/app/alertdialog/AlertDialog.h" -#include "Tactility/hal/uart/Uart.h" -#include "Tactility/lvgl/LvglSync.h" -#include "Tactility/lvgl/Style.h" +#include +#include +#include +#include +#include +#include #include #include @@ -127,7 +127,7 @@ public: lv_obj_add_event_cb(connect_button, onConnectCallback, LV_EVENT_SHORT_CLICKED, this); } - void onStop() { + void onStop() override { int speed = getSpeedInput(); if (speed > 0) { preferences.putInt32("speed", speed); diff --git a/Tactility/Include/Tactility/app/serialconsole/ConsoleView.h b/Tactility/Private/Tactility/app/serialconsole/ConsoleView.h similarity index 98% rename from Tactility/Include/Tactility/app/serialconsole/ConsoleView.h rename to Tactility/Private/Tactility/app/serialconsole/ConsoleView.h index d824dc6b..ded396f6 100644 --- a/Tactility/Include/Tactility/app/serialconsole/ConsoleView.h +++ b/Tactility/Private/Tactility/app/serialconsole/ConsoleView.h @@ -1,21 +1,18 @@ #pragma once -#include "./View.h" -#include "Tactility/Timer.h" +#include +#include #include #include -#define TAG "SerialConsole" - namespace tt::app::serialconsole { +constexpr auto* TAG = "SerialConsole"; constexpr size_t receiveBufferSize = 512; constexpr size_t renderBufferSize = receiveBufferSize + 2; // Leave space for newline at split and null terminator at the end class ConsoleView final : public View { -private: - lv_obj_t* _Nullable parent = nullptr; lv_obj_t* _Nullable logTextarea = nullptr; lv_obj_t* _Nullable inputTextarea = nullptr; @@ -215,7 +212,7 @@ public: viewThread = std::make_unique( "SerConsView", 4096, - [this]() { + [this] { return this->viewThreadMain(); } ); @@ -276,7 +273,7 @@ public: startViews(parent); } - void onStop() final { + void onStop() override { stopViews(); stopLogic(); stopUart(); diff --git a/Tactility/Include/Tactility/app/serialconsole/View.h b/Tactility/Private/Tactility/app/serialconsole/View.h similarity index 84% rename from Tactility/Include/Tactility/app/serialconsole/View.h rename to Tactility/Private/Tactility/app/serialconsole/View.h index 58db8c9c..38ea46d8 100644 --- a/Tactility/Include/Tactility/app/serialconsole/View.h +++ b/Tactility/Private/Tactility/app/serialconsole/View.h @@ -1,7 +1,5 @@ #pragma once -#include - namespace tt::app::serialconsole { class View { diff --git a/Tactility/Private/Tactility/app/wifiapsettings/WifiApSettings.h b/Tactility/Private/Tactility/app/wifiapsettings/WifiApSettings.h index e16acb77..0f3335c9 100644 --- a/Tactility/Private/Tactility/app/wifiapsettings/WifiApSettings.h +++ b/Tactility/Private/Tactility/app/wifiapsettings/WifiApSettings.h @@ -1,8 +1,6 @@ #pragma once -#include -#include -#include +#include namespace tt::app::wifiapsettings { diff --git a/Tactility/Private/Tactility/app/wificonnect/State.h b/Tactility/Private/Tactility/app/wificonnect/State.h index e3e7ec55..0a591f6a 100644 --- a/Tactility/Private/Tactility/app/wificonnect/State.h +++ b/Tactility/Private/Tactility/app/wificonnect/State.h @@ -5,7 +5,7 @@ namespace tt::app::wificonnect { -class State { +class State final { Mutex lock; service::wifi::settings::WifiApSettings apSettings; bool connectionError = false; diff --git a/Tactility/Private/Tactility/app/wificonnect/View.h b/Tactility/Private/Tactility/app/wificonnect/View.h index a8196d4f..6f000750 100644 --- a/Tactility/Private/Tactility/app/wificonnect/View.h +++ b/Tactility/Private/Tactility/app/wificonnect/View.h @@ -3,7 +3,7 @@ #include "./Bindings.h" #include "./State.h" -#include "Tactility/app/AppContext.h" +#include #include @@ -11,7 +11,7 @@ namespace tt::app::wificonnect { class WifiConnect; -class View { +class View final { Bindings* bindings; State* state; diff --git a/Tactility/Private/Tactility/app/wificonnect/WifiConnect.h b/Tactility/Private/Tactility/app/wificonnect/WifiConnect.h index 5f4eea00..656c8f07 100644 --- a/Tactility/Private/Tactility/app/wificonnect/WifiConnect.h +++ b/Tactility/Private/Tactility/app/wificonnect/WifiConnect.h @@ -1,16 +1,16 @@ #pragma once -#include "Tactility/app/App.h" -#include "Tactility/app/wificonnect/Bindings.h" -#include "Tactility/app/wificonnect/State.h" -#include "Tactility/app/wificonnect/View.h" +#include +#include +#include +#include #include #include namespace tt::app::wificonnect { -class WifiConnect : public App { +class WifiConnect final : public App { Mutex mutex; State state; @@ -27,7 +27,7 @@ class WifiConnect : public App { public: WifiConnect(); - ~WifiConnect(); + ~WifiConnect() override; void lock(); void unlock(); @@ -39,7 +39,6 @@ public: Bindings& getBindings() { return bindings; } View& getView() { return view; } - void requestViewUpdate(); }; diff --git a/Tactility/Private/Tactility/app/wifimanage/State.h b/Tactility/Private/Tactility/app/wifimanage/State.h index e59ee301..dc41e3e5 100644 --- a/Tactility/Private/Tactility/app/wifimanage/State.h +++ b/Tactility/Private/Tactility/app/wifimanage/State.h @@ -8,7 +8,7 @@ namespace tt::app::wifimanage { /** * View's state */ -class State { +class State final { Mutex mutex = Mutex(Mutex::Type::Recursive); bool scanning = false; @@ -32,7 +32,7 @@ public: template &> Func> void withApRecords(Func&& onApRecords) const { - mutex.withLock([&]() { + mutex.withLock([&] { std::invoke(std::forward(onApRecords), apRecords); }); } diff --git a/Tactility/Private/Tactility/app/wifimanage/View.h b/Tactility/Private/Tactility/app/wifimanage/View.h index a5e3e54c..029a4f57 100644 --- a/Tactility/Private/Tactility/app/wifimanage/View.h +++ b/Tactility/Private/Tactility/app/wifimanage/View.h @@ -3,19 +3,17 @@ #include "./Bindings.h" #include "./State.h" -#include "Tactility/app/AppContext.h" +#include #include namespace tt::app::wifimanage { -class View { - -private: +class View final { Bindings* bindings; State* state; - std::unique_ptr paths; + std::unique_ptr paths; lv_obj_t* root = nullptr; lv_obj_t* enable_switch = nullptr; lv_obj_t* enable_on_boot_switch = nullptr; diff --git a/Tactility/Private/Tactility/app/wifimanage/WifiManagePrivate.h b/Tactility/Private/Tactility/app/wifimanage/WifiManagePrivate.h index 8d0f56d9..3c42b1d3 100644 --- a/Tactility/Private/Tactility/app/wifimanage/WifiManagePrivate.h +++ b/Tactility/Private/Tactility/app/wifimanage/WifiManagePrivate.h @@ -3,7 +3,7 @@ #include "./View.h" #include "./State.h" -#include "Tactility/app/App.h" +#include #include #include @@ -11,7 +11,7 @@ namespace tt::app::wifimanage { -class WifiManage : public App { +class WifiManage final : public App { PubSub::SubscriptionHandle wifiSubscription = nullptr; Mutex mutex; diff --git a/Tactility/Source/Tactility.cpp b/Tactility/Source/Tactility.cpp index 3e16832c..f56decf7 100644 --- a/Tactility/Source/Tactility.cpp +++ b/Tactility/Source/Tactility.cpp @@ -60,7 +60,7 @@ namespace app { namespace chat { extern const AppManifest manifest; } namespace development { extern const AppManifest manifest; } namespace display { extern const AppManifest manifest; } - namespace filebrowser { extern const AppManifest manifest; } + namespace files { extern const AppManifest manifest; } namespace fileselection { extern const AppManifest manifest; } namespace gpio { extern const AppManifest manifest; } namespace gpssettings { extern const AppManifest manifest; } @@ -102,7 +102,7 @@ static void registerSystemApps() { addApp(app::applist::manifest); addApp(app::calculator::manifest); addApp(app::display::manifest); - addApp(app::filebrowser::manifest); + addApp(app::files::manifest); addApp(app::fileselection::manifest); addApp(app::gpio::manifest); addApp(app::imageviewer::manifest); @@ -178,7 +178,7 @@ static void registerInstalledApp(std::string path) { app::addApp({ .id = app_id_entry->second, .name = app_name_entry->second, - .type = app::Type::User, + .category = app::Category::User, .location = app::Location::external(path) }); } diff --git a/Tactility/Source/app/AppInstall.cpp b/Tactility/Source/app/AppInstall.cpp index 15b84b59..61ee3f33 100644 --- a/Tactility/Source/app/AppInstall.cpp +++ b/Tactility/Source/app/AppInstall.cpp @@ -216,7 +216,7 @@ bool install(const std::string& path) { addApp({ .id = app_id_iterator->second, .name = app_name_entry->second, - .type = Type::User, + .category = Category::User, .location = Location::external(renamed_target_path) }); diff --git a/Tactility/Source/app/ElfApp.cpp b/Tactility/Source/app/ElfApp.cpp index a6dc9971..4f32e60d 100644 --- a/Tactility/Source/app/ElfApp.cpp +++ b/Tactility/Source/app/ElfApp.cpp @@ -1,41 +1,22 @@ #ifdef ESP_PLATFORM -#include "Tactility/app/ElfApp.h" -#include "Tactility/file/File.h" -#include "Tactility/file/FileLock.h" -#include "Tactility/service/loader/Loader.h" - +#include +#include +#include +#include #include +#include #include -#include "esp_elf.h" +#include #include #include -#include namespace tt::app { constexpr auto* TAG = "ElfApp"; -struct ElfManifest { - /** The user-readable name of the app. Used in UI. */ - std::string name; - /** Optional icon. */ - std::string icon; - CreateData _Nullable createData = nullptr; - DestroyData _Nullable destroyData = nullptr; - OnCreate _Nullable onCreate = nullptr; - OnDestroy _Nullable onDestroy = nullptr; - OnShow _Nullable onShow = nullptr; - OnHide _Nullable onHide = nullptr; - OnResult _Nullable onResult = nullptr; -}; - -static size_t elfManifestSetCount = 0; -static ElfManifest elfManifest; -static std::shared_ptr elfManifestLock = std::make_shared(); - static std::string getErrorCodeString(int error_code) { switch (error_code) { case ENOMEM: @@ -47,7 +28,30 @@ static std::string getErrorCodeString(int error_code) { } } -class ElfApp : public App { +class ElfApp final : public App { + +public: + + struct Parameters { + CreateData _Nullable createData = nullptr; + DestroyData _Nullable destroyData = nullptr; + OnCreate _Nullable onCreate = nullptr; + OnDestroy _Nullable onDestroy = nullptr; + OnShow _Nullable onShow = nullptr; + OnHide _Nullable onHide = nullptr; + OnResult _Nullable onResult = nullptr; + }; + + static void setParameters(const Parameters& parameters) { + staticParameters = parameters; + staticParametersSetCount++; + } + +private: + + static Parameters staticParameters; + static size_t staticParametersSetCount; + static std::shared_ptr staticParametersLock; const std::string appPath; std::unique_ptr elfFileData; @@ -60,7 +64,7 @@ class ElfApp : public App { .entry = nullptr }; bool shouldCleanupElf = false; // Whether we have to clean up the above "elf" object - std::unique_ptr manifest; + std::unique_ptr manifest; void* data = nullptr; std::string lastError = ""; @@ -128,10 +132,10 @@ public: void onCreate(AppContext& appContext) override { // Because we use global variables, we have to ensure that we are not starting 2 apps in parallel // We use a ScopedLock so we don't have to safeguard all branches - auto lock = elfManifestLock->asScopedLock(); + auto lock = staticParametersLock->asScopedLock(); lock.lock(); - elfManifestSetCount = 0; + staticParametersSetCount = 0; if (!startElf()) { service::loader::stopApp(); auto message = lastError.empty() ? "Application failed to start." : std::format("Application failed to start: {}", lastError); @@ -139,13 +143,13 @@ public: return; } - if (elfManifestSetCount == 0) { + if (staticParametersSetCount == 0) { service::loader::stopApp(); alertdialog::start("Error", "Application failed to start: application failed to register itself"); return; } - manifest = std::make_unique(elfManifest); + manifest = std::make_unique(staticParameters); lock.unlock(); if (manifest->createData != nullptr) { @@ -192,9 +196,11 @@ public: } }; -void setElfAppManifest( - const char* name, - const char* _Nullable icon, +ElfApp::Parameters ElfApp::staticParameters; +size_t ElfApp::staticParametersSetCount = 0; +std::shared_ptr ElfApp::staticParametersLock = std::make_shared(); + +void setElfAppParameters( CreateData _Nullable createData, DestroyData _Nullable destroyData, OnCreate _Nullable onCreate, @@ -203,9 +209,7 @@ void setElfAppManifest( OnHide _Nullable onHide, OnResult _Nullable onResult ) { - elfManifest = ElfManifest { - .name = name ? name : "", - .icon = icon ? icon : "", + ElfApp::setParameters({ .createData = createData, .destroyData = destroyData, .onCreate = onCreate, @@ -213,8 +217,7 @@ void setElfAppManifest( .onShow = onShow, .onHide = onHide, .onResult = onResult - }; - elfManifestSetCount++; + }); } std::shared_ptr createElfApp(const std::shared_ptr& manifest) { diff --git a/Tactility/Source/app/addgps/AddGps.cpp b/Tactility/Source/app/addgps/AddGps.cpp index 1c693958..235bfb64 100644 --- a/Tactility/Source/app/addgps/AddGps.cpp +++ b/Tactility/Source/app/addgps/AddGps.cpp @@ -175,7 +175,8 @@ extern const AppManifest manifest = { .id = "AddGps", .name = "Add GPS", .icon = LV_SYMBOL_GPS, - .type = Type::Hidden, + .category = Category::System, + .flags = AppManifest::Flags::Hidden, .createApp = create }; diff --git a/Tactility/Source/app/alertdialog/AlertDialog.cpp b/Tactility/Source/app/alertdialog/AlertDialog.cpp index 6b5a2387..fabf86fa 100644 --- a/Tactility/Source/app/alertdialog/AlertDialog.cpp +++ b/Tactility/Source/app/alertdialog/AlertDialog.cpp @@ -128,7 +128,8 @@ public: extern const AppManifest manifest = { .id = "AlertDialog", .name = "Alert Dialog", - .type = Type::Hidden, + .category = Category::System, + .flags = AppManifest::Flags::Hidden, .createApp = create }; diff --git a/Tactility/Source/app/applist/AppList.cpp b/Tactility/Source/app/applist/AppList.cpp index 37a8f2c6..9c232bc6 100644 --- a/Tactility/Source/app/applist/AppList.cpp +++ b/Tactility/Source/app/applist/AppList.cpp @@ -40,7 +40,9 @@ public: std::ranges::sort(manifests, SortAppManifestByName); for (const auto& manifest: manifests) { - if (manifest->type == Type::User || manifest->type == Type::System) { + bool is_valid_category = (manifest->category == Category::User) || (manifest->category == Category::System); + bool is_visible = (manifest->flags & AppManifest::Flags::Hidden) == 0u; + if (is_valid_category && is_visible) { createAppWidget(manifest, list); } } @@ -50,7 +52,8 @@ public: extern const AppManifest manifest = { .id = "AppList", .name = "Apps", - .type = Type::Hidden, + .category = Category::System, + .flags = AppManifest::Flags::Hidden, .createApp = create, }; diff --git a/Tactility/Source/app/boot/Boot.cpp b/Tactility/Source/app/boot/Boot.cpp index dcf1e164..b664b71c 100644 --- a/Tactility/Source/app/boot/Boot.cpp +++ b/Tactility/Source/app/boot/Boot.cpp @@ -124,7 +124,6 @@ class BootApp : public App { settings::BootSettings boot_properties; if (!settings::loadBootSettings(boot_properties) || boot_properties.launcherAppId.empty()) { TT_LOG_E(TAG, "Launcher not configured"); - stop(); return; } @@ -164,7 +163,8 @@ public: extern const AppManifest manifest = { .id = "Boot", .name = "Boot", - .type = Type::Boot, + .category = Category::System, + .flags = AppManifest::Flags::HideStatusBar | AppManifest::Flags::Hidden, .createApp = create }; diff --git a/Tactility/Source/app/crashdiagnostics/CrashDiagnostics.cpp b/Tactility/Source/app/crashdiagnostics/CrashDiagnostics.cpp index ea5a65d6..949d19eb 100644 --- a/Tactility/Source/app/crashdiagnostics/CrashDiagnostics.cpp +++ b/Tactility/Source/app/crashdiagnostics/CrashDiagnostics.cpp @@ -118,7 +118,8 @@ public: extern const AppManifest manifest = { .id = "CrashDiagnostics", .name = "Crash Diagnostics", - .type = Type::Hidden, + .category = Category::System, + .flags = AppManifest::Flags::Hidden, .createApp = create }; diff --git a/Tactility/Source/app/development/Development.cpp b/Tactility/Source/app/development/Development.cpp index ef7f9111..db8f763e 100644 --- a/Tactility/Source/app/development/Development.cpp +++ b/Tactility/Source/app/development/Development.cpp @@ -164,7 +164,7 @@ public: extern const AppManifest manifest = { .id = "Development", .name = "Development", - .type = Type::Settings, + .category = Category::Settings, .createApp = create }; diff --git a/Tactility/Source/app/display/Display.cpp b/Tactility/Source/app/display/Display.cpp index 2820d5ba..edf62f4f 100644 --- a/Tactility/Source/app/display/Display.cpp +++ b/Tactility/Source/app/display/Display.cpp @@ -167,7 +167,7 @@ extern const AppManifest manifest = { .id = "Display", .name = "Display", .icon = TT_ASSETS_APP_ICON_DISPLAY_SETTINGS, - .type = Type::Settings, + .category = Category::Settings, .createApp = create }; diff --git a/Tactility/Source/app/filebrowser/FileBrowser.cpp b/Tactility/Source/app/files/FilesApp.cpp similarity index 72% rename from Tactility/Source/app/filebrowser/FileBrowser.cpp rename to Tactility/Source/app/files/FilesApp.cpp index f74f7820..f2dd3415 100644 --- a/Tactility/Source/app/filebrowser/FileBrowser.cpp +++ b/Tactility/Source/app/files/FilesApp.cpp @@ -1,24 +1,24 @@ -#include "Tactility/app/filebrowser/View.h" -#include "Tactility/app/filebrowser/State.h" -#include "Tactility/app/AppContext.h" +#include +#include +#include #include #include #include -namespace tt::app::filebrowser { - -constexpr auto* TAG = "FileBrowser"; +namespace tt::app::files { extern const AppManifest manifest; -class FileBrowser : public App { +class FilesApp final : public App { + std::unique_ptr view; std::shared_ptr state; public: - FileBrowser() { + + FilesApp() { state = std::make_shared(); view = std::make_unique(state); } @@ -36,8 +36,9 @@ extern const AppManifest manifest = { .id = "Files", .name = "Files", .icon = TT_ASSETS_APP_ICON_FILES, - .type = Type::Hidden, - .createApp = create + .category = Category::System, + .flags = AppManifest::Flags::Hidden, + .createApp = create }; void start() { diff --git a/Tactility/Source/app/filebrowser/State.cpp b/Tactility/Source/app/files/State.cpp similarity index 94% rename from Tactility/Source/app/filebrowser/State.cpp rename to Tactility/Source/app/files/State.cpp index feda67a9..2933e21f 100644 --- a/Tactility/Source/app/filebrowser/State.cpp +++ b/Tactility/Source/app/files/State.cpp @@ -1,7 +1,8 @@ -#include "Tactility/app/filebrowser/State.h" +#include #include -#include "Tactility/hal/sdcard/SdCardDevice.h" +#include +#include #include #include #include @@ -10,11 +11,10 @@ #include #include #include -#include -namespace tt::app::filebrowser { +namespace tt::app::files { -constexpr auto* TAG = "FileBrowser"; +constexpr auto* TAG = "Files"; State::State() { if (kernel::getPlatform() == kernel::PlatformSimulator) { diff --git a/Tactility/Source/app/filebrowser/SupportedFiles.cpp b/Tactility/Source/app/files/SupportedFiles.cpp similarity index 92% rename from Tactility/Source/app/filebrowser/SupportedFiles.cpp rename to Tactility/Source/app/files/SupportedFiles.cpp index 09ad198a..9d914e24 100644 --- a/Tactility/Source/app/filebrowser/SupportedFiles.cpp +++ b/Tactility/Source/app/files/SupportedFiles.cpp @@ -1,9 +1,9 @@ #include #include -namespace tt::app::filebrowser { +namespace tt::app::files { -constexpr auto* TAG = "FileBrowser"; +constexpr auto* TAG = "Files"; bool isSupportedAppFile(const std::string& filename) { return filename.ends_with(".app"); diff --git a/Tactility/Source/app/filebrowser/View.cpp b/Tactility/Source/app/files/View.cpp similarity index 95% rename from Tactility/Source/app/filebrowser/View.cpp rename to Tactility/Source/app/files/View.cpp index ddfdbb53..88f27cf3 100644 --- a/Tactility/Source/app/filebrowser/View.cpp +++ b/Tactility/Source/app/files/View.cpp @@ -1,13 +1,13 @@ -#include "Tactility/app/filebrowser/View.h" -#include "Tactility/app/filebrowser/SupportedFiles.h" +#include +#include -#include "Tactility/app/alertdialog/AlertDialog.h" -#include "Tactility/app/imageviewer/ImageViewer.h" -#include "Tactility/app/inputdialog/InputDialog.h" -#include "Tactility/app/notes/Notes.h" -#include "Tactility/app/ElfApp.h" -#include "Tactility/lvgl/Toolbar.h" -#include "Tactility/lvgl/LvglSync.h" +#include +#include +#include +#include +#include +#include +#include #include #include @@ -19,17 +19,17 @@ #include #ifdef ESP_PLATFORM -#include "Tactility/service/loader/Loader.h" +#include #endif -namespace tt::app::filebrowser { +namespace tt::app::files { -constexpr auto* TAG = "FileBrowser"; +constexpr auto* TAG = "Files"; // region Callbacks static void dirEntryListScrollBeginCallback(lv_event_t* event) { - auto* view = static_cast(lv_event_get_user_data(event)); + auto* view = static_cast(lv_event_get_user_data(event)); view->onDirEntryListScrollBegin(); } diff --git a/Tactility/Source/app/fileselection/FileSelection.cpp b/Tactility/Source/app/fileselection/FileSelection.cpp index 05534696..3403a062 100644 --- a/Tactility/Source/app/fileselection/FileSelection.cpp +++ b/Tactility/Source/app/fileselection/FileSelection.cpp @@ -59,7 +59,8 @@ extern const AppManifest manifest = { .id = "FileSelection", .name = "File Selection", .icon = TT_ASSETS_APP_ICON_FILES, - .type = Type::Hidden, + .category = Category::System, + .flags = AppManifest::Flags::Hidden, .createApp = create }; diff --git a/Tactility/Source/app/gpio/Gpio.cpp b/Tactility/Source/app/gpio/Gpio.cpp index 14bc2d64..b27139e3 100644 --- a/Tactility/Source/app/gpio/Gpio.cpp +++ b/Tactility/Source/app/gpio/Gpio.cpp @@ -191,7 +191,7 @@ extern const AppManifest manifest = { .id = "Gpio", .name = "GPIO", .icon = TT_ASSETS_APP_ICON_GPIO, - .type = Type::System, + .category = Category::System, .createApp = create }; diff --git a/Tactility/Source/app/gpssettings/GpsSettings.cpp b/Tactility/Source/app/gpssettings/GpsSettings.cpp index 62a1d341..b55be040 100644 --- a/Tactility/Source/app/gpssettings/GpsSettings.cpp +++ b/Tactility/Source/app/gpssettings/GpsSettings.cpp @@ -19,12 +19,12 @@ extern AppManifest manifest; namespace tt::app::gpssettings { -constexpr const char* TAG = "GpsSettings"; - extern const AppManifest manifest; class GpsSettingsApp final : public App { + static constexpr auto* TAG = "GpsSettings"; + std::unique_ptr timer; std::shared_ptr appReference = std::make_shared(this); lv_obj_t* statusWrapper = nullptr; @@ -268,13 +268,13 @@ class GpsSettingsApp final : public App { public: GpsSettingsApp() { - timer = std::make_unique(Timer::Type::Periodic, [this]() { + timer = std::make_unique(Timer::Type::Periodic, [this] { updateViews(); }); service = service::gps::findGpsService(); } - void onShow(AppContext& app, lv_obj_t* parent) final { + void onShow(AppContext& app, lv_obj_t* parent) override { lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT); @@ -337,7 +337,7 @@ public: updateViews(); } - void onHide(AppContext& app) final { + void onHide(AppContext& app) override { service->getStatePubsub()->unsubscribe(serviceStateSubscription); serviceStateSubscription = nullptr; } @@ -347,7 +347,7 @@ extern const AppManifest manifest = { .id = "GpsSettings", .name = "GPS", .icon = LV_SYMBOL_GPS, - .type = Type::Settings, + .category = Category::Settings, .createApp = create }; diff --git a/Tactility/Source/app/i2cscanner/I2cScanner.cpp b/Tactility/Source/app/i2cscanner/I2cScanner.cpp index 8d05de5a..28c47dbf 100644 --- a/Tactility/Source/app/i2cscanner/I2cScanner.cpp +++ b/Tactility/Source/app/i2cscanner/I2cScanner.cpp @@ -1,13 +1,12 @@ -#include "Tactility/app/i2cscanner/I2cScannerPrivate.h" -#include "Tactility/app/i2cscanner/I2cScannerThread.h" -#include "Tactility/app/i2cscanner/I2cHelpers.h" +#include +#include -#include "Tactility/Preferences.h" -#include "Tactility/app/AppContext.h" -#include "Tactility/hal/i2c/I2cDevice.h" -#include "Tactility/lvgl/LvglSync.h" -#include "Tactility/lvgl/Toolbar.h" -#include "Tactility/service/loader/Loader.h" +#include +#include +#include +#include +#include +#include #include #include @@ -15,14 +14,14 @@ #include -#define START_SCAN_TEXT "Scan" -#define STOP_SCAN_TEXT "Stop scan" - namespace tt::app::i2cscanner { extern const AppManifest manifest; -class I2cScannerApp : public App { +class I2cScannerApp final : public App { + + static constexpr auto* START_SCAN_TEXT = "Scan"; + static constexpr auto* STOP_SCAN_TEXT = "Stop scan"; // Core Mutex mutex = Mutex(Mutex::Type::Recursive); @@ -181,13 +180,6 @@ void I2cScannerApp::onPressScanCallback(lv_event_t* event) { } } -void I2cScannerApp::onScanTimerCallback() { - auto app = optApp(); - if (app != nullptr) { - app->onScanTimer(); - } -} - // endregion Callbacks bool I2cScannerApp::getPort(i2c_port_t* outPort) { @@ -285,8 +277,8 @@ void I2cScannerApp::startScanning() { lv_obj_clean(scanListWidget); scanState = ScanStateScanning; - scanTimer = std::make_unique(Timer::Type::Once, []{ - onScanTimerCallback(); + scanTimer = std::make_unique(Timer::Type::Once, [this]{ + onScanTimer(); }); scanTimer->start(10); mutex.unlock(); @@ -414,7 +406,7 @@ extern const AppManifest manifest = { .id = "I2cScanner", .name = "I2C Scanner", .icon = TT_ASSETS_APP_ICON_I2C_SETTINGS, - .type = Type::System, + .category = Category::System, .createApp = create }; diff --git a/Tactility/Source/app/i2csettings/I2cSettings.cpp b/Tactility/Source/app/i2csettings/I2cSettings.cpp index 4de39ce5..f83491fc 100644 --- a/Tactility/Source/app/i2csettings/I2cSettings.cpp +++ b/Tactility/Source/app/i2csettings/I2cSettings.cpp @@ -96,7 +96,7 @@ extern const AppManifest manifest = { .id = "I2cSettings", .name = "I2C", .icon = TT_ASSETS_APP_ICON_I2C_SETTINGS, - .type = Type::Settings, + .category = Category::Settings, .createApp = create }; diff --git a/Tactility/Source/app/imageviewer/ImageViewer.cpp b/Tactility/Source/app/imageviewer/ImageViewer.cpp index dae0fa12..511891db 100644 --- a/Tactility/Source/app/imageviewer/ImageViewer.cpp +++ b/Tactility/Source/app/imageviewer/ImageViewer.cpp @@ -62,7 +62,8 @@ class ImageViewerApp : public App { extern const AppManifest manifest = { .id = "ImageViewer", .name = "Image Viewer", - .type = Type::Hidden, + .category = Category::System, + .flags = AppManifest::Flags::Hidden, .createApp = create }; diff --git a/Tactility/Source/app/inputdialog/InputDialog.cpp b/Tactility/Source/app/inputdialog/InputDialog.cpp index 44d6e63e..7f453120 100644 --- a/Tactility/Source/app/inputdialog/InputDialog.cpp +++ b/Tactility/Source/app/inputdialog/InputDialog.cpp @@ -120,7 +120,8 @@ public: extern const AppManifest manifest = { .id = "InputDialog", .name = "Input Dialog", - .type = Type::Hidden, + .category = Category::System, + .flags = AppManifest::Flags::Hidden, .createApp = create }; diff --git a/Tactility/Source/app/launcher/Launcher.cpp b/Tactility/Source/app/launcher/Launcher.cpp index c717b570..a9ba137a 100644 --- a/Tactility/Source/app/launcher/Launcher.cpp +++ b/Tactility/Source/app/launcher/Launcher.cpp @@ -138,7 +138,7 @@ public: extern const AppManifest manifest = { .id = "Launcher", .name = "Launcher", - .type = Type::Launcher, + .category = Category::System, .createApp = create }; diff --git a/Tactility/Source/app/localesettings/LocaleSettings.cpp b/Tactility/Source/app/localesettings/LocaleSettings.cpp index 9004f688..bbedddc7 100644 --- a/Tactility/Source/app/localesettings/LocaleSettings.cpp +++ b/Tactility/Source/app/localesettings/LocaleSettings.cpp @@ -165,7 +165,7 @@ extern const AppManifest manifest = { .id = "LocaleSettings", .name = "Region & Language", .icon = TT_ASSETS_APP_ICON_TIME_DATE_SETTINGS, - .type = Type::Settings, + .category = Category::Settings, .createApp = create }; diff --git a/Tactility/Source/app/log/Log.cpp b/Tactility/Source/app/log/Log.cpp index 9aa33b4e..d3815f08 100644 --- a/Tactility/Source/app/log/Log.cpp +++ b/Tactility/Source/app/log/Log.cpp @@ -123,7 +123,7 @@ extern const AppManifest manifest = { .id = "Log", .name = "Log", .icon = LV_SYMBOL_LIST, - .type = Type::System, + .category = Category::System, .createApp = create }; diff --git a/Tactility/Source/app/power/Power.cpp b/Tactility/Source/app/power/Power.cpp index e5511a6c..7116da80 100644 --- a/Tactility/Source/app/power/Power.cpp +++ b/Tactility/Source/app/power/Power.cpp @@ -192,7 +192,7 @@ extern const AppManifest manifest = { .id = "Power", .name = "Power", .icon = TT_ASSETS_APP_ICON_POWER_SETTINGS, - .type = Type::Settings, + .category = Category::Settings, .createApp = create }; diff --git a/Tactility/Source/app/screenshot/Screenshot.cpp b/Tactility/Source/app/screenshot/Screenshot.cpp index c7334c87..b826ef07 100644 --- a/Tactility/Source/app/screenshot/Screenshot.cpp +++ b/Tactility/Source/app/screenshot/Screenshot.cpp @@ -281,7 +281,7 @@ extern const AppManifest manifest = { .id = "Screenshot", .name = "Screenshot", .icon = LV_SYMBOL_IMAGE, - .type = Type::System, + .category = Category::System, .createApp = create }; diff --git a/Tactility/Source/app/selectiondialog/SelectionDialog.cpp b/Tactility/Source/app/selectiondialog/SelectionDialog.cpp index cc24a0de..f23ceb10 100644 --- a/Tactility/Source/app/selectiondialog/SelectionDialog.cpp +++ b/Tactility/Source/app/selectiondialog/SelectionDialog.cpp @@ -114,7 +114,8 @@ public: extern const AppManifest manifest = { .id = "SelectionDialog", .name = "Selection Dialog", - .type = Type::Hidden, + .category = Category::System, + .flags = AppManifest::Flags::Hidden, .createApp = create }; diff --git a/Tactility/Source/app/serialconsole/SerialConsole.cpp b/Tactility/Source/app/serialconsole/SerialConsole.cpp index 667df8d1..60165577 100644 --- a/Tactility/Source/app/serialconsole/SerialConsole.cpp +++ b/Tactility/Source/app/serialconsole/SerialConsole.cpp @@ -1,4 +1,4 @@ -#include "Tactility/app/serialconsole/ConnectView.h" +#include "../../../Private/Tactility/app/serialconsole/ConnectView.h" #include "Tactility/app/serialconsole/ConsoleView.h" #include "Tactility/lvgl/Style.h" @@ -88,7 +88,7 @@ extern const AppManifest manifest = { .id = "SerialConsole", .name = "Serial Console", .icon = LV_SYMBOL_LIST, - .type = Type::System, + .category = Category::System, .createApp = create }; diff --git a/Tactility/Source/app/settings/Settings.cpp b/Tactility/Source/app/settings/Settings.cpp index 8dea762c..3c41dfcb 100644 --- a/Tactility/Source/app/settings/Settings.cpp +++ b/Tactility/Source/app/settings/Settings.cpp @@ -38,7 +38,7 @@ class SettingsApp : public App { auto manifests = getApps(); std::sort(manifests.begin(), manifests.end(), SortAppManifestByName); for (const auto& manifest: manifests) { - if (manifest->type == Type::Settings) { + if (manifest->category == Category::Settings) { createWidget(manifest, list); } } @@ -49,7 +49,8 @@ extern const AppManifest manifest = { .id = "Settings", .name = "Settings", .icon = TT_ASSETS_APP_ICON_SETTINGS, - .type = Type::Hidden, + .category = Category::System, + .flags = AppManifest::Flags::Hidden, .createApp = create }; diff --git a/Tactility/Source/app/systeminfo/SystemInfo.cpp b/Tactility/Source/app/systeminfo/SystemInfo.cpp index 6c7546c4..397790f1 100644 --- a/Tactility/Source/app/systeminfo/SystemInfo.cpp +++ b/Tactility/Source/app/systeminfo/SystemInfo.cpp @@ -295,7 +295,7 @@ extern const AppManifest manifest = { .id = "SystemInfo", .name = "System Info", .icon = TT_ASSETS_APP_ICON_SYSTEM_INFO, - .type = Type::System, + .category = Category::System, .createApp = create }; diff --git a/Tactility/Source/app/timedatesettings/TimeDateSettings.cpp b/Tactility/Source/app/timedatesettings/TimeDateSettings.cpp index 6a4aeb3c..e61d5149 100644 --- a/Tactility/Source/app/timedatesettings/TimeDateSettings.cpp +++ b/Tactility/Source/app/timedatesettings/TimeDateSettings.cpp @@ -60,7 +60,7 @@ extern const AppManifest manifest = { .id = "TimeDateSettings", .name = "Time & Date", .icon = TT_ASSETS_APP_ICON_TIME_DATE_SETTINGS, - .type = Type::Settings, + .category = Category::Settings, .createApp = create }; diff --git a/Tactility/Source/app/timezone/TimeZone.cpp b/Tactility/Source/app/timezone/TimeZone.cpp index 49c2dbb1..cad696fb 100644 --- a/Tactility/Source/app/timezone/TimeZone.cpp +++ b/Tactility/Source/app/timezone/TimeZone.cpp @@ -1,9 +1,9 @@ -#include "Tactility/app/AppContext.h" -#include "Tactility/app/AppManifest.h" -#include "Tactility/app/timezone/TimeZone.h" -#include "Tactility/lvgl/Toolbar.h" -#include "Tactility/lvgl/LvglSync.h" -#include "Tactility/service/loader/Loader.h" +#include +#include +#include +#include +#include +#include #include #include @@ -15,9 +15,8 @@ namespace tt::app::timezone { constexpr auto* TAG = "TimeZone"; - -#define RESULT_BUNDLE_CODE_INDEX "code" -#define RESULT_BUNDLE_NAME_INDEX "name" +constexpr auto* RESULT_BUNDLE_CODE_INDEX = "code"; +constexpr auto* RESULT_BUNDLE_NAME_INDEX = "name"; extern const AppManifest manifest; @@ -113,14 +112,6 @@ class TimeZoneApp final : public App { lv_obj_add_event_cb(btn, &onListItemSelectedCallback, LV_EVENT_SHORT_CLICKED, (void*)index); } - static void updateTimerCallback() { - auto appContext = getCurrentAppContext(); - if (appContext != nullptr && appContext->getManifest().id == manifest.id) { - auto app = std::static_pointer_cast(appContext->getApp()); - app->updateList(); - } - } - void readTimeZones(std::string filter) { auto path = std::string(file::MOUNT_POINT_SYSTEM) + "/timezones.csv"; auto* file = fopen(path.c_str(), "rb"); @@ -228,14 +219,17 @@ public: } void onCreate(AppContext& app) override { - updateTimer = std::make_unique(Timer::Type::Once, [] { updateTimerCallback(); }); + updateTimer = std::make_unique(Timer::Type::Once, [this] { + updateList(); + }); } }; extern const AppManifest manifest = { .id = "TimeZone", .name = "Select timezone", - .type = Type::Hidden, + .category = Category::System, + .flags = AppManifest::Flags::Hidden, .createApp = create }; diff --git a/Tactility/Source/app/usbsettings/UsbSettings.cpp b/Tactility/Source/app/usbsettings/UsbSettings.cpp index a2432442..257b9d23 100644 --- a/Tactility/Source/app/usbsettings/UsbSettings.cpp +++ b/Tactility/Source/app/usbsettings/UsbSettings.cpp @@ -45,7 +45,7 @@ extern const AppManifest manifest = { .id = "UsbSettings", .name = "USB", .icon = LV_SYMBOL_USB, - .type = Type::Settings, + .category = Category::Settings, .createApp = create }; diff --git a/Tactility/Source/app/wifiapsettings/WifiApSettings.cpp b/Tactility/Source/app/wifiapsettings/WifiApSettings.cpp index 014c7d6a..a40ed0c1 100644 --- a/Tactility/Source/app/wifiapsettings/WifiApSettings.cpp +++ b/Tactility/Source/app/wifiapsettings/WifiApSettings.cpp @@ -1,20 +1,18 @@ -#include "Tactility/app/wifiapsettings/WifiApSettings.h" - -#include "Tactility/app/App.h" -#include "Tactility/app/AppContext.h" -#include "Tactility/app/AppManifest.h" -#include "Tactility/app/alertdialog/AlertDialog.h" -#include "Tactility/lvgl/Style.h" -#include "Tactility/lvgl/Toolbar.h" - +#include +#include +#include +#include +#include +#include +#include +#include #include -#include #include namespace tt::app::wifiapsettings { -#define TAG "wifi_ap_settings" +constexpr auto* TAG = "WifiApSettings"; extern const AppManifest manifest; @@ -146,7 +144,8 @@ extern const AppManifest manifest = { .id = "WifiApSettings", .name = "Wi-Fi AP Settings", .icon = LV_SYMBOL_WIFI, - .type = Type::Hidden, + .category = Category::System, + .flags = AppManifest::Flags::Hidden, .createApp = create }; diff --git a/Tactility/Source/app/wificonnect/WifiConnect.cpp b/Tactility/Source/app/wificonnect/WifiConnect.cpp index e8be8b8e..3cb07abc 100644 --- a/Tactility/Source/app/wificonnect/WifiConnect.cpp +++ b/Tactility/Source/app/wificonnect/WifiConnect.cpp @@ -97,7 +97,8 @@ extern const AppManifest manifest = { .id = "WifiConnect", .name = "Wi-Fi Connect", .icon = LV_SYMBOL_WIFI, - .type = Type::Hidden, + .category = Category::System, + .flags = AppManifest::Flags::Hidden, .createApp = create }; diff --git a/Tactility/Source/app/wifimanage/WifiManage.cpp b/Tactility/Source/app/wifimanage/WifiManage.cpp index 6e4f32b3..46995b12 100644 --- a/Tactility/Source/app/wifimanage/WifiManage.cpp +++ b/Tactility/Source/app/wifimanage/WifiManage.cpp @@ -136,7 +136,7 @@ extern const AppManifest manifest = { .id = "WifiManage", .name = "Wi-Fi", .icon = LV_SYMBOL_WIFI, - .type = Type::Settings, + .category = Category::Settings, .createApp = create }; diff --git a/Tactility/Source/service/gui/GuiService.cpp b/Tactility/Source/service/gui/GuiService.cpp index 2268d7a4..e2c6ca4d 100644 --- a/Tactility/Source/service/gui/GuiService.cpp +++ b/Tactility/Source/service/gui/GuiService.cpp @@ -1,7 +1,6 @@ #include "Tactility/service/gui/GuiService.h" #include "Tactility/lvgl/LvglSync.h" #include "Tactility/lvgl/Statusbar.h" -#include "Tactility/lvgl/Style.h" #include "Tactility/service/loader/Loader.h" #include @@ -92,10 +91,10 @@ void GuiService::redraw() { lv_group_set_default(group); app::Flags flags = std::static_pointer_cast(appToRender)->getFlags(); - if (flags.showStatusbar) { - lv_obj_remove_flag(statusbarWidget, LV_OBJ_FLAG_HIDDEN); - } else { + if (flags.hideStatusbar) { lv_obj_add_flag(statusbarWidget, LV_OBJ_FLAG_HIDDEN); + } else { + lv_obj_remove_flag(statusbarWidget, LV_OBJ_FLAG_HIDDEN); } lv_obj_t* container = createAppViews(appRootWidget); diff --git a/Tactility/Source/service/loader/Loader.cpp b/Tactility/Source/service/loader/Loader.cpp index b1ade374..3318abe1 100644 --- a/Tactility/Source/service/loader/Loader.cpp +++ b/Tactility/Source/service/loader/Loader.cpp @@ -103,7 +103,7 @@ void LoaderService::onStartAppMessage(const std::string& id, app::LaunchId launc auto previous_app = !appStack.empty() ? appStack.top() : nullptr; auto new_app = std::make_shared(app_manifest, launchId, parameters); - new_app->mutableFlags().showStatusbar = (app_manifest->type != app::Type::Boot); + new_app->mutableFlags().hideStatusbar = (app_manifest->flags & app::AppManifest::Flags::HideStatusBar); appStack.push(new_app); transitionAppToState(new_app, app::State::Initial); @@ -141,7 +141,7 @@ void LoaderService::onStopAppMessage(const std::string& id) { return; } - if (original_stack_size == 1 && app_to_stop->getManifest().type != app::Type::Boot) { + if (original_stack_size == 1 && app_to_stop->getManifest().name != "Boot") { TT_LOG_E(TAG, "Stop app: can't stop root app"); return; } diff --git a/Tactility/Source/service/statusbar/Statusbar.cpp b/Tactility/Source/service/statusbar/Statusbar.cpp index f2b6c038..3f430f77 100644 --- a/Tactility/Source/service/statusbar/Statusbar.cpp +++ b/Tactility/Source/service/statusbar/Statusbar.cpp @@ -1,9 +1,10 @@ -#include "Tactility/lvgl/Statusbar.h" -#include "Tactility/lvgl/LvglSync.h" +#include +#include -#include "Tactility/hal/power/PowerDevice.h" -#include "Tactility/hal/sdcard/SdCardDevice.h" -#include "Tactility/service/gps/GpsService.h" +#include +#include +#include +#include #include #include #include @@ -16,31 +17,31 @@ namespace tt::service::statusbar { constexpr auto* TAG = "StatusbarService"; // SD card status -#define STATUSBAR_ICON_SDCARD "sdcard.png" -#define STATUSBAR_ICON_SDCARD_ALERT "sdcard_alert.png" +constexpr auto* STATUSBAR_ICON_SDCARD = "sdcard.png"; +constexpr auto* STATUSBAR_ICON_SDCARD_ALERT = "sdcard_alert.png"; // Wifi status -#define STATUSBAR_ICON_WIFI_OFF_WHITE "wifi_off_white.png" -#define STATUSBAR_ICON_WIFI_SCAN_WHITE "wifi_scan_white.png" -#define STATUSBAR_ICON_WIFI_SIGNAL_WEAK_WHITE "wifi_signal_weak_white.png" -#define STATUSBAR_ICON_WIFI_SIGNAL_MEDIUM_WHITE "wifi_signal_medium_white.png" -#define STATUSBAR_ICON_WIFI_SIGNAL_STRONG_WHITE "wifi_signal_strong_white.png" +constexpr auto* STATUSBAR_ICON_WIFI_OFF_WHITE = "wifi_off_white.png"; +constexpr auto* STATUSBAR_ICON_WIFI_SCAN_WHITE = "wifi_scan_white.png"; +constexpr auto* STATUSBAR_ICON_WIFI_SIGNAL_WEAK_WHITE = "wifi_signal_weak_white.png"; +constexpr auto* STATUSBAR_ICON_WIFI_SIGNAL_MEDIUM_WHITE = "wifi_signal_medium_white.png"; +constexpr auto* STATUSBAR_ICON_WIFI_SIGNAL_STRONG_WHITE = "wifi_signal_strong_white.png"; // Power status -#define STATUSBAR_ICON_POWER_0 "power_0.png" -#define STATUSBAR_ICON_POWER_10 "power_10.png" -#define STATUSBAR_ICON_POWER_20 "power_20.png" -#define STATUSBAR_ICON_POWER_30 "power_30.png" -#define STATUSBAR_ICON_POWER_40 "power_40.png" -#define STATUSBAR_ICON_POWER_50 "power_50.png" -#define STATUSBAR_ICON_POWER_60 "power_60.png" -#define STATUSBAR_ICON_POWER_70 "power_70.png" -#define STATUSBAR_ICON_POWER_80 "power_80.png" -#define STATUSBAR_ICON_POWER_90 "power_90.png" -#define STATUSBAR_ICON_POWER_100 "power_100.png" +constexpr auto* STATUSBAR_ICON_POWER_0 = "power_0.png"; +constexpr auto* STATUSBAR_ICON_POWER_10 = "power_10.png"; +constexpr auto* STATUSBAR_ICON_POWER_20 = "power_20.png"; +constexpr auto* STATUSBAR_ICON_POWER_30 = "power_30.png"; +constexpr auto* STATUSBAR_ICON_POWER_40 = "power_40.png"; +constexpr auto* STATUSBAR_ICON_POWER_50 = "power_50.png"; +constexpr auto* STATUSBAR_ICON_POWER_60 = "power_60.png"; +constexpr auto* STATUSBAR_ICON_POWER_70 = "power_70.png"; +constexpr auto* STATUSBAR_ICON_POWER_80 = "power_80.png"; +constexpr auto* STATUSBAR_ICON_POWER_90 = "power_90.png"; +constexpr auto* STATUSBAR_ICON_POWER_100 = "power_100.png"; // GPS -#define STATUSBAR_ICON_GPS "location.png" +constexpr auto* STATUSBAR_ICON_GPS = "location.png"; extern const ServiceManifest manifest; @@ -222,15 +223,15 @@ class StatusbarService final : public Service { } void update() { - // TODO: Make thread-safe for LVGL - updateGpsIcon(); - updateWifiIcon(); - updateSdCardIcon(); - updatePowerStatusIcon(); - } - - static void onUpdate(const std::shared_ptr& service) { - service->update(); + if (lvgl::isStarted()) { + if (lvgl::lock(100)) { + updateGpsIcon(); + updateWifiIcon(); + updateSdCardIcon(); + updatePowerStatusIcon(); + lvgl::unlock(); + } + } } public: @@ -262,10 +263,10 @@ public: auto service = findServiceById(manifest.id); assert(service); - onUpdate(service); + service->update(); updateTimer = std::make_unique(Timer::Type::Periodic, [service] { - onUpdate(service); + service->update(); }); // We want to try and scan more often in case of startup or scan lock failure diff --git a/TactilityC/Include/tt_app_manifest.h b/TactilityC/Include/tt_app_manifest.h index 7551b4f3..a7657e90 100644 --- a/TactilityC/Include/tt_app_manifest.h +++ b/TactilityC/Include/tt_app_manifest.h @@ -28,10 +28,6 @@ typedef void (*AppOnHide)(AppHandle app, void* _Nullable data); typedef void (*AppOnResult)(AppHandle app, void* _Nullable data, AppLaunchId launchId, AppResult result, BundleHandle resultData); typedef struct { - /** The application's human-readable name */ - const char* name; - /** The application icon (you can use LV_SYMBOL_* too) */ - const char* _Nullable icon; /** The application can allocate data to re-use later (e.g. struct with state) */ AppCreateData _Nullable createData; /** If createData is specified, this one must be specified too */ diff --git a/TactilityC/Source/tt_app_manifest.cpp b/TactilityC/Source/tt_app_manifest.cpp index d274cfd8..9e38deb9 100644 --- a/TactilityC/Source/tt_app_manifest.cpp +++ b/TactilityC/Source/tt_app_manifest.cpp @@ -3,18 +3,16 @@ #include #include -#define TAG "tt_app" - extern "C" { +constexpr auto TAG = "tt_app"; + void tt_app_register( const ExternalAppManifest* manifest ) { #ifdef ESP_PLATFORM assert((manifest->createData == nullptr) == (manifest->destroyData == nullptr)); - setElfAppManifest( - manifest->name, - manifest->icon, + tt::app::setElfAppParameters( manifest->createData, manifest->destroyData, manifest->onCreate, diff --git a/TactilityC/Source/tt_init.cpp b/TactilityC/Source/tt_init.cpp index 08fc354f..91d488e8 100644 --- a/TactilityC/Source/tt_init.cpp +++ b/TactilityC/Source/tt_init.cpp @@ -90,6 +90,9 @@ const esp_elfsym elf_symbols[] { ESP_ELFSYM_EXPORT(strstr), ESP_ELFSYM_EXPORT(memset), ESP_ELFSYM_EXPORT(memcpy), + ESP_ELFSYM_EXPORT(memcmp), + ESP_ELFSYM_EXPORT(memchr), + ESP_ELFSYM_EXPORT(memmove), // ctype ESP_ELFSYM_EXPORT(isalnum), ESP_ELFSYM_EXPORT(isalpha),