From b98a813f3cfd65ed95d8ff8f4ef745b66b1770c5 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 26 Jul 2026 15:58:35 +0200 Subject: [PATCH] Migrate TactilityC and LVGL functionality (#588) lvgl-module - Move and rename source and include files - Fix bug with missing lvgl unlock - New widgets: spinner, toolbar, sliderbox TactilityC - Removed tt_lock, tt_lvgl_\* --- Documentation/ideas.md | 1 + .../{lvgl_display.h => devices/display.h} | 0 .../{lvgl_keyboard.h => devices/keyboard.h} | 0 .../{lvgl_pointer.h => devices/pointer.h} | 0 .../include/lvgl/{lvgl_fonts.h => fonts.h} | 0 .../launcher.h} | 0 .../{lvgl_icon_shared.h => icons/shared.h} | 0 .../statusbar.h} | 0 .../include/lvgl/{lvgl_ppa.h => ppa.h} | 0 .../include/lvgl/widgets/sliderbox.h | 41 +++ .../include/lvgl/widgets/spinner.h | 19 ++ .../include/lvgl/widgets/toolbar.h | 86 ++++++ .../{lvgl_devices.c => devices/devices.c} | 10 +- .../{lvgl_display.c => devices/display.c} | 4 +- .../{lvgl_keyboard.c => devices/keyboard.c} | 2 +- .../{lvgl_pointer.c => devices/pointer.c} | 2 +- .../source/{lvgl_fonts.c => fonts.c} | 2 +- .../lvgl-module/source/{lvgl_ppa.c => ppa.c} | 2 +- Modules/lvgl-module/source/symbols.c | 39 ++- .../lvgl-module/source/widgets/sliderbox.cpp | 20 +- .../lvgl-module/source/widgets/spinner.cpp | 17 +- .../lvgl-module/source/widgets/toolbar.cpp | 260 ++++++++++++++++++ Tactility/Include/Tactility/lvgl/SliderBox.h | 36 --- Tactility/Include/Tactility/lvgl/Spinner.h | 12 - Tactility/Include/Tactility/lvgl/Toolbar.h | 58 +--- Tactility/Source/Tactility.cpp | 8 + Tactility/Source/app/addgps/AddGps.cpp | 2 +- .../Source/app/alertdialog/AlertDialog.cpp | 4 +- .../Source/app/appdetails/AppDetails.cpp | 4 +- Tactility/Source/app/apphub/AppHubApp.cpp | 12 +- .../app/apphubdetails/AppHubDetailsApp.cpp | 14 +- Tactility/Source/app/applist/AppList.cpp | 4 +- .../Source/app/appsettings/AppSettings.cpp | 8 +- .../app/audiosettings/AudioSettings.cpp | 16 +- Tactility/Source/app/btmanage/BtManage.cpp | 2 +- Tactility/Source/app/btmanage/View.cpp | 4 +- .../app/btpeersettings/BtPeerSettings.cpp | 4 +- Tactility/Source/app/chat/ChatApp.cpp | 2 +- Tactility/Source/app/chat/ChatView.cpp | 6 +- .../Source/app/development/Development.cpp | 6 +- Tactility/Source/app/files/View.cpp | 8 +- Tactility/Source/app/fileselection/View.cpp | 6 +- .../Source/app/gpssettings/GpsSettings.cpp | 4 +- .../app/grovesettings/GroveSettings.cpp | 2 +- .../Source/app/i2cscanner/I2cScanner.cpp | 2 +- .../Source/app/inputdialog/InputDialog.cpp | 4 +- .../app/kerneldisplay/KernelDisplay.cpp | 8 +- .../Source/app/keyboard/KeyboardSettings.cpp | 2 +- Tactility/Source/app/launcher/Launcher.cpp | 6 +- .../app/localesettings/LocaleSettings.cpp | 2 +- Tactility/Source/app/notes/Notes.cpp | 2 +- Tactility/Source/app/power/Power.cpp | 2 +- Tactility/Source/app/poweroff/PowerOff.cpp | 4 +- .../Source/app/screenshot/Screenshot.cpp | 2 +- .../app/selectiondialog/SelectionDialog.cpp | 4 +- Tactility/Source/app/settings/Settings.cpp | 4 +- Tactility/Source/app/setup/Setup.cpp | 2 +- .../Source/app/systeminfo/SystemInfo.cpp | 4 +- .../app/timedatesettings/TimeDateSettings.cpp | 2 +- Tactility/Source/app/timezone/TimeZone.cpp | 4 +- .../app/touchcalibration/TouchCalibration.cpp | 2 +- .../app/trackball/TrackballSettings.cpp | 4 +- .../Source/app/usbsettings/UsbSettings.cpp | 2 +- .../webserversettings/WebServerSettings.cpp | 4 +- .../app/wifiapsettings/WifiApSettings.cpp | 6 +- Tactility/Source/app/wificonnect/View.cpp | 4 +- Tactility/Source/app/wifimanage/View.cpp | 4 +- .../Source/app/wifimanage/WifiManage.cpp | 2 +- Tactility/Source/lvgl/Statusbar.cpp | 4 +- Tactility/Source/lvgl/Toolbar.cpp | 253 +---------------- .../memorychecker/MemoryCheckerService.cpp | 2 +- .../Source/service/statusbar/Statusbar.cpp | 2 +- .../service/webserver/WebServerService.cpp | 2 +- TactilityC/Include/tt_lock.h | 48 ---- TactilityC/Include/tt_lvgl_keyboard.h | 55 ---- TactilityC/Include/tt_lvgl_spinner.h | 14 - TactilityC/Include/tt_lvgl_toolbar.h | 72 ----- TactilityC/Private/tt_lock_private.h | 8 - TactilityC/Source/tt_init.cpp | 26 -- TactilityC/Source/tt_lock.cpp | 29 -- TactilityC/Source/tt_lvgl_keyboard.cpp | 33 --- TactilityC/Source/tt_lvgl_spinner.cpp | 10 - TactilityC/Source/tt_lvgl_toolbar.cpp | 42 --- Tests/SdkIntegration/main/Source/main.c | 8 +- 84 files changed, 586 insertions(+), 831 deletions(-) rename Modules/lvgl-module/include/lvgl/{lvgl_display.h => devices/display.h} (100%) rename Modules/lvgl-module/include/lvgl/{lvgl_keyboard.h => devices/keyboard.h} (100%) rename Modules/lvgl-module/include/lvgl/{lvgl_pointer.h => devices/pointer.h} (100%) rename Modules/lvgl-module/include/lvgl/{lvgl_fonts.h => fonts.h} (100%) rename Modules/lvgl-module/include/lvgl/{lvgl_icon_launcher.h => icons/launcher.h} (100%) rename Modules/lvgl-module/include/lvgl/{lvgl_icon_shared.h => icons/shared.h} (100%) rename Modules/lvgl-module/include/lvgl/{lvgl_icon_statusbar.h => icons/statusbar.h} (100%) rename Modules/lvgl-module/include/lvgl/{lvgl_ppa.h => ppa.h} (100%) create mode 100644 Modules/lvgl-module/include/lvgl/widgets/sliderbox.h create mode 100644 Modules/lvgl-module/include/lvgl/widgets/spinner.h create mode 100644 Modules/lvgl-module/include/lvgl/widgets/toolbar.h rename Modules/lvgl-module/source/{lvgl_devices.c => devices/devices.c} (97%) rename Modules/lvgl-module/source/{lvgl_display.c => devices/display.c} (99%) rename Modules/lvgl-module/source/{lvgl_keyboard.c => devices/keyboard.c} (98%) rename Modules/lvgl-module/source/{lvgl_pointer.c => devices/pointer.c} (99%) rename Modules/lvgl-module/source/{lvgl_fonts.c => fonts.c} (98%) rename Modules/lvgl-module/source/{lvgl_ppa.c => ppa.c} (99%) rename Tactility/Source/lvgl/SliderBox.cpp => Modules/lvgl-module/source/widgets/sliderbox.cpp (93%) rename Tactility/Source/lvgl/Spinner.cpp => Modules/lvgl-module/source/widgets/spinner.cpp (81%) create mode 100644 Modules/lvgl-module/source/widgets/toolbar.cpp delete mode 100644 Tactility/Include/Tactility/lvgl/SliderBox.h delete mode 100644 Tactility/Include/Tactility/lvgl/Spinner.h delete mode 100644 TactilityC/Include/tt_lock.h delete mode 100644 TactilityC/Include/tt_lvgl_keyboard.h delete mode 100644 TactilityC/Include/tt_lvgl_spinner.h delete mode 100644 TactilityC/Include/tt_lvgl_toolbar.h delete mode 100644 TactilityC/Private/tt_lock_private.h delete mode 100644 TactilityC/Source/tt_lock.cpp delete mode 100644 TactilityC/Source/tt_lvgl_keyboard.cpp delete mode 100644 TactilityC/Source/tt_lvgl_spinner.cpp delete mode 100644 TactilityC/Source/tt_lvgl_toolbar.cpp diff --git a/Documentation/ideas.md b/Documentation/ideas.md index 7039ee047..afe5b753f 100644 --- a/Documentation/ideas.md +++ b/Documentation/ideas.md @@ -52,6 +52,7 @@ ## Lower Priority +- lvgl-module's spinner relies on hard-coded spinner asset from Tactility main project. - Localize all apps - Support hot-plugging SD card (note: this is not possible if they require the CS pin hack) - Explore LVGL9's FreeRTOS functionality diff --git a/Modules/lvgl-module/include/lvgl/lvgl_display.h b/Modules/lvgl-module/include/lvgl/devices/display.h similarity index 100% rename from Modules/lvgl-module/include/lvgl/lvgl_display.h rename to Modules/lvgl-module/include/lvgl/devices/display.h diff --git a/Modules/lvgl-module/include/lvgl/lvgl_keyboard.h b/Modules/lvgl-module/include/lvgl/devices/keyboard.h similarity index 100% rename from Modules/lvgl-module/include/lvgl/lvgl_keyboard.h rename to Modules/lvgl-module/include/lvgl/devices/keyboard.h diff --git a/Modules/lvgl-module/include/lvgl/lvgl_pointer.h b/Modules/lvgl-module/include/lvgl/devices/pointer.h similarity index 100% rename from Modules/lvgl-module/include/lvgl/lvgl_pointer.h rename to Modules/lvgl-module/include/lvgl/devices/pointer.h diff --git a/Modules/lvgl-module/include/lvgl/lvgl_fonts.h b/Modules/lvgl-module/include/lvgl/fonts.h similarity index 100% rename from Modules/lvgl-module/include/lvgl/lvgl_fonts.h rename to Modules/lvgl-module/include/lvgl/fonts.h diff --git a/Modules/lvgl-module/include/lvgl/lvgl_icon_launcher.h b/Modules/lvgl-module/include/lvgl/icons/launcher.h similarity index 100% rename from Modules/lvgl-module/include/lvgl/lvgl_icon_launcher.h rename to Modules/lvgl-module/include/lvgl/icons/launcher.h diff --git a/Modules/lvgl-module/include/lvgl/lvgl_icon_shared.h b/Modules/lvgl-module/include/lvgl/icons/shared.h similarity index 100% rename from Modules/lvgl-module/include/lvgl/lvgl_icon_shared.h rename to Modules/lvgl-module/include/lvgl/icons/shared.h diff --git a/Modules/lvgl-module/include/lvgl/lvgl_icon_statusbar.h b/Modules/lvgl-module/include/lvgl/icons/statusbar.h similarity index 100% rename from Modules/lvgl-module/include/lvgl/lvgl_icon_statusbar.h rename to Modules/lvgl-module/include/lvgl/icons/statusbar.h diff --git a/Modules/lvgl-module/include/lvgl/lvgl_ppa.h b/Modules/lvgl-module/include/lvgl/ppa.h similarity index 100% rename from Modules/lvgl-module/include/lvgl/lvgl_ppa.h rename to Modules/lvgl-module/include/lvgl/ppa.h diff --git a/Modules/lvgl-module/include/lvgl/widgets/sliderbox.h b/Modules/lvgl-module/include/lvgl/widgets/sliderbox.h new file mode 100644 index 000000000..c22dd6478 --- /dev/null +++ b/Modules/lvgl-module/include/lvgl/widgets/sliderbox.h @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: Apache-2.0 +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Create a SliderBox: a slider flanked by "-" and "+" buttons with a value label. + * @param[in] parent the parent object + * @param[in] min minimum value (inclusive) + * @param[in] max maximum value (inclusive) + * @param[in] step the amount each +/- button press changes the value by + * @param[in] value the initial value + * @return the created SliderBox instance + */ +lv_obj_t* lvgl_sliderbox_create(lv_obj_t* parent, int32_t min, int32_t max, int32_t step, int32_t value); + +/** @return the current value of the SliderBox */ +int32_t lvgl_sliderbox_get_value(lv_obj_t* obj); + +/** + * Set the current value of the SliderBox (clamped to its [min, max] range). + * Updates the slider position and the value label. + */ +void lvgl_sliderbox_set_value(lv_obj_t* obj, int32_t value, lv_anim_enable_t anim); + +/** + * Register a callback that is fired with LV_EVENT_VALUE_CHANGED whenever the value + * changes, whether the change came from the slider or from the +/- buttons. + * @param[in] obj the SliderBox instance + * @param[in] callback the callback to invoke + * @param[in] userData user data that is attached to the event + */ +void lvgl_sliderbox_add_value_changed_cb(lv_obj_t* obj, lv_event_cb_t callback, void* userData); + +#ifdef __cplusplus +} +#endif diff --git a/Modules/lvgl-module/include/lvgl/widgets/spinner.h b/Modules/lvgl-module/include/lvgl/widgets/spinner.h new file mode 100644 index 000000000..534bc8b2e --- /dev/null +++ b/Modules/lvgl-module/include/lvgl/widgets/spinner.h @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: Apache-2.0 +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Creates the Tactility spinner widget. + * @param[in] parent the parent object for the new spinner + * @return the created spinner + */ +lv_obj_t* lvgl_spinner_create(lv_obj_t* parent); + +#ifdef __cplusplus +} +#endif diff --git a/Modules/lvgl-module/include/lvgl/widgets/toolbar.h b/Modules/lvgl-module/include/lvgl/widgets/toolbar.h new file mode 100644 index 000000000..043f43a09 --- /dev/null +++ b/Modules/lvgl-module/include/lvgl/widgets/toolbar.h @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: Apache-2.0 +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TOOLBAR_ACTION_LIMIT 4 + +/** Configuration for toolbar-wide defaults */ +typedef struct { + /** Callback invoked when a toolbar's default navigation (top-left) button is pressed */ + lv_event_cb_t nav_action_callback; +} ToolbarConfig; + +/** + * @brief Configure toolbar-wide defaults. Must be called before any toolbar is created (e.g. during LVGL startup). + * @param[in] config the configuration to apply + */ +void lvgl_toolbar_configure(const ToolbarConfig* config); + +/** + * @brief Create a toolbar widget with the given title. + * @param[in] parent the parent object for the new toolbar + * @param[in] title the toolbar title + * @return the created toolbar + */ +lv_obj_t* lvgl_toolbar_create(lv_obj_t* parent, const char* title); + +/** Sets the toolbar title */ +void lvgl_toolbar_set_title(lv_obj_t* obj, const char* title); + +/** + * Sets the navigation action of the toolbar (button on the top-left) + * @param[in] obj the toolbar instance + * @param[in] icon the icon to set on the button + * @param[in] callback the callback for the click action of the button + * @param[in] userData the user data that is attached to the callback event object + */ +void lvgl_toolbar_set_nav_action(lv_obj_t* obj, const char* icon, lv_event_cb_t callback, void* userData); + +/** + * Create and add an action button with an image to the toolbar (aligned to the right of the toolbar) + * @param[in] obj the toolbar instance + * @param[in] imagePath the path to an image file to shown on the button + * @param[in] callback the callback for the click action of the button + * @param[in] callbackUserData the user data that is passed to the callback + * @return an lv_button instance + */ +lv_obj_t* lvgl_toolbar_add_image_button_action(lv_obj_t* obj, const char* imagePath, lv_event_cb_t callback, void* callbackUserData); + +/** + * Create and add an action button with text to the toolbar (aligned to the right of the toolbar) + * @param[in] obj the toolbar instance + * @param[in] text the button text + * @param[in] callback the callback for the click action of the button + * @param[in] callbackUserData the user data that is passed to the callback + * @return an lv_button instance + */ +lv_obj_t* lvgl_toolbar_add_text_button_action(lv_obj_t* obj, const char* text, lv_event_cb_t callback, void* callbackUserData); + +/** + * Create and add a switch to the toolbar actions. + * @param[in] obj the toolbar instance + * @return an instance created by lv_switch_create() + */ +lv_obj_t* lvgl_toolbar_add_switch_action(lv_obj_t* obj); + +/** + * Create and add a spinner to the toolbar actions. + * @param[in] obj the toolbar instance + * @return an instance created by lvgl_spinner_create() + */ +lv_obj_t* lvgl_toolbar_add_spinner_action(lv_obj_t* obj); + +/** + * Remove all actions from the toolbar + * @param[in] obj the toolbar instance + */ +void lvgl_toolbar_clear_actions(lv_obj_t* obj); + +#ifdef __cplusplus +} +#endif diff --git a/Modules/lvgl-module/source/lvgl_devices.c b/Modules/lvgl-module/source/devices/devices.c similarity index 97% rename from Modules/lvgl-module/source/lvgl_devices.c rename to Modules/lvgl-module/source/devices/devices.c index 5222a5c8b..f7766f2ce 100644 --- a/Modules/lvgl-module/source/lvgl_devices.c +++ b/Modules/lvgl-module/source/devices/devices.c @@ -1,12 +1,12 @@ +#include +#include +#include +#include #include #include #include #include #include -#include -#include -#include -#include #include @@ -115,5 +115,5 @@ void lvgl_devices_detach() { display = lv_disp_get_next(NULL); } - lvgl_lock(); + lvgl_unlock(); } diff --git a/Modules/lvgl-module/source/lvgl_display.c b/Modules/lvgl-module/source/devices/display.c similarity index 99% rename from Modules/lvgl-module/source/lvgl_display.c rename to Modules/lvgl-module/source/devices/display.c index 0586e5b5a..9f523a5b3 100644 --- a/Modules/lvgl-module/source/lvgl_display.c +++ b/Modules/lvgl-module/source/devices/display.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 -#include +#include -#include +#include #include #include diff --git a/Modules/lvgl-module/source/lvgl_keyboard.c b/Modules/lvgl-module/source/devices/keyboard.c similarity index 98% rename from Modules/lvgl-module/source/lvgl_keyboard.c rename to Modules/lvgl-module/source/devices/keyboard.c index 0d73cd54e..498450490 100644 --- a/Modules/lvgl-module/source/lvgl_keyboard.c +++ b/Modules/lvgl-module/source/devices/keyboard.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -#include +#include #include diff --git a/Modules/lvgl-module/source/lvgl_pointer.c b/Modules/lvgl-module/source/devices/pointer.c similarity index 99% rename from Modules/lvgl-module/source/lvgl_pointer.c rename to Modules/lvgl-module/source/devices/pointer.c index c52cb89d4..9acbc9fde 100644 --- a/Modules/lvgl-module/source/lvgl_pointer.c +++ b/Modules/lvgl-module/source/devices/pointer.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -#include +#include #include diff --git a/Modules/lvgl-module/source/lvgl_fonts.c b/Modules/lvgl-module/source/fonts.c similarity index 98% rename from Modules/lvgl-module/source/lvgl_fonts.c rename to Modules/lvgl-module/source/fonts.c index a2cc2d1ad..96812d087 100644 --- a/Modules/lvgl-module/source/lvgl_fonts.c +++ b/Modules/lvgl-module/source/fonts.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include +#include #include // The preprocessor definitions that are used below are defined in the CMakeLists.txt from this module. diff --git a/Modules/lvgl-module/source/lvgl_ppa.c b/Modules/lvgl-module/source/ppa.c similarity index 99% rename from Modules/lvgl-module/source/lvgl_ppa.c rename to Modules/lvgl-module/source/ppa.c index 25a61bfac..63f28e4bf 100644 --- a/Modules/lvgl-module/source/lvgl_ppa.c +++ b/Modules/lvgl-module/source/ppa.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -#include +#include #include diff --git a/Modules/lvgl-module/source/symbols.c b/Modules/lvgl-module/source/symbols.c index ae24a07f3..ba74f2f73 100644 --- a/Modules/lvgl-module/source/symbols.c +++ b/Modules/lvgl-module/source/symbols.c @@ -1,7 +1,15 @@ // SPDX-License-Identifier: Apache-2.0 +#include #include #include -#include + +#include +#include +#include + +#include +#include +#include #include @@ -26,6 +34,35 @@ const struct ModuleSymbol lvgl_module_symbols[] = { DEFINE_MODULE_SYMBOL(lvgl_get_launcher_icon_font_height), DEFINE_MODULE_SYMBOL(lvgl_get_statusbar_icon_font), DEFINE_MODULE_SYMBOL(lvgl_get_statusbar_icon_font_height), + // lvgl_display + DEFINE_MODULE_SYMBOL(lvgl_display_add), + DEFINE_MODULE_SYMBOL(lvgl_display_remove), + // lvgl_keyboard + DEFINE_MODULE_SYMBOL(lvgl_keyboard_add), + DEFINE_MODULE_SYMBOL(lvgl_keyboard_remove), + // lvgl_pointer + DEFINE_MODULE_SYMBOL(lvgl_pointer_set_calibration), + DEFINE_MODULE_SYMBOL(lvgl_pointer_get_calibration), + DEFINE_MODULE_SYMBOL(lvgl_pointer_get_default), + DEFINE_MODULE_SYMBOL(lvgl_pointer_add), + DEFINE_MODULE_SYMBOL(lvgl_pointer_remove), + // lvgl_spinner + DEFINE_MODULE_SYMBOL(lvgl_spinner_create), + // lvgl_toolbar + DEFINE_MODULE_SYMBOL(lvgl_toolbar_configure), + DEFINE_MODULE_SYMBOL(lvgl_toolbar_create), + DEFINE_MODULE_SYMBOL(lvgl_toolbar_set_title), + DEFINE_MODULE_SYMBOL(lvgl_toolbar_set_nav_action), + DEFINE_MODULE_SYMBOL(lvgl_toolbar_add_image_button_action), + DEFINE_MODULE_SYMBOL(lvgl_toolbar_add_text_button_action), + DEFINE_MODULE_SYMBOL(lvgl_toolbar_add_switch_action), + DEFINE_MODULE_SYMBOL(lvgl_toolbar_add_spinner_action), + DEFINE_MODULE_SYMBOL(lvgl_toolbar_clear_actions), + // lvgl_sliderbox + DEFINE_MODULE_SYMBOL(lvgl_sliderbox_create), + DEFINE_MODULE_SYMBOL(lvgl_sliderbox_get_value), + DEFINE_MODULE_SYMBOL(lvgl_sliderbox_set_value), + DEFINE_MODULE_SYMBOL(lvgl_sliderbox_add_value_changed_cb), // lv_event DEFINE_MODULE_SYMBOL(lv_event_get_code), DEFINE_MODULE_SYMBOL(lv_event_get_indev), diff --git a/Tactility/Source/lvgl/SliderBox.cpp b/Modules/lvgl-module/source/widgets/sliderbox.cpp similarity index 93% rename from Tactility/Source/lvgl/SliderBox.cpp rename to Modules/lvgl-module/source/widgets/sliderbox.cpp index 515af1c9c..59de76e09 100644 --- a/Tactility/Source/lvgl/SliderBox.cpp +++ b/Modules/lvgl-module/source/widgets/sliderbox.cpp @@ -1,10 +1,8 @@ +// SPDX-License-Identifier: Apache-2.0 #define LV_USE_PRIVATE_API 1 // For actual lv_obj_t declaration -#include - -#include - -namespace tt::lvgl { +#include +#include typedef struct { lv_obj_t obj; @@ -133,7 +131,7 @@ static lv_obj_t* create_step_button(lv_obj_t* parent, const char* symbol, lv_eve return button; } -lv_obj_t* sliderbox_create(lv_obj_t* parent, int32_t min, int32_t max, int32_t step, int32_t value) { +lv_obj_t* lvgl_sliderbox_create(lv_obj_t* parent, int32_t min, int32_t max, int32_t step, int32_t value) { if (max <= min) { max = min + 1; } @@ -176,17 +174,17 @@ lv_obj_t* sliderbox_create(lv_obj_t* parent, int32_t min, int32_t max, int32_t s sliderBox->plusButton = create_step_button(obj, LV_SYMBOL_PLUS, &on_plus_button_clicked, obj, button_size); - sliderbox_set_value(obj, value, LV_ANIM_OFF); + lvgl_sliderbox_set_value(obj, value, LV_ANIM_OFF); return obj; } -int32_t sliderbox_get_value(lv_obj_t* obj) { +int32_t lvgl_sliderbox_get_value(lv_obj_t* obj) { auto* sliderBox = reinterpret_cast(obj); return lv_slider_get_value(sliderBox->slider); } -void sliderbox_set_value(lv_obj_t* obj, int32_t value, lv_anim_enable_t anim) { +void lvgl_sliderbox_set_value(lv_obj_t* obj, int32_t value, lv_anim_enable_t anim) { auto* sliderBox = reinterpret_cast(obj); if (value < sliderBox->min) { @@ -200,8 +198,6 @@ void sliderbox_set_value(lv_obj_t* obj, int32_t value, lv_anim_enable_t anim) { update_button_states(sliderBox); } -void sliderbox_add_value_changed_cb(lv_obj_t* obj, lv_event_cb_t callback, void* userData) { +void lvgl_sliderbox_add_value_changed_cb(lv_obj_t* obj, lv_event_cb_t callback, void* userData) { lv_obj_add_event_cb(obj, callback, LV_EVENT_VALUE_CHANGED, userData); } - -} // namespace tt::lvgl diff --git a/Tactility/Source/lvgl/Spinner.cpp b/Modules/lvgl-module/source/widgets/spinner.cpp similarity index 81% rename from Tactility/Source/lvgl/Spinner.cpp rename to Modules/lvgl-module/source/widgets/spinner.cpp index 164de7052..befdbe20b 100644 --- a/Tactility/Source/lvgl/Spinner.cpp +++ b/Modules/lvgl-module/source/widgets/spinner.cpp @@ -1,15 +1,14 @@ +// SPDX-License-Identifier: Apache-2.0 #define LV_USE_PRIVATE_API 1 // For actual lv_obj_t declaration -#include -#include +#include -#include - -namespace tt::lvgl { +// TODO: Don't depend on asset from a different project +#define SPINNER_ASSET "A:/system/spinner.png" static void spinner_constructor(const lv_obj_class_t* object_class, lv_obj_t* object); -const lv_obj_class_t tt_spinner_class = { +static const lv_obj_class_t tt_spinner_class = { .base_class = &lv_image_class, .constructor_cb = spinner_constructor, .destructor_cb = nullptr, @@ -24,11 +23,11 @@ const lv_obj_class_t tt_spinner_class = { .theme_inheritable = 0 }; -lv_obj_t* spinner_create(lv_obj_t* parent) { +lv_obj_t* lvgl_spinner_create(lv_obj_t* parent) { lv_obj_t* obj = lv_obj_class_create_obj(&tt_spinner_class, parent); lv_obj_class_init_obj(obj); - lv_image_set_src(obj, TT_ASSETS_UI_SPINNER); + lv_image_set_src(obj, SPINNER_ASSET); return obj; } @@ -54,5 +53,3 @@ static void spinner_constructor(const lv_obj_class_t* object_class, lv_obj_t* ob lv_anim_set_exec_cb(&a, anim_rotation_callback); lv_anim_start(&a); } - -} diff --git a/Modules/lvgl-module/source/widgets/toolbar.cpp b/Modules/lvgl-module/source/widgets/toolbar.cpp new file mode 100644 index 000000000..612f4f019 --- /dev/null +++ b/Modules/lvgl-module/source/widgets/toolbar.cpp @@ -0,0 +1,260 @@ +// SPDX-License-Identifier: Apache-2.0 +#define LV_USE_PRIVATE_API 1 // For actual lv_obj_t declaration + +#include +#include +#include +#include + +#include +#include + +static uint32_t getToolbarHeight(UiDensity uiDensity) { + if (uiDensity == LVGL_UI_DENSITY_COMPACT) { + return lvgl_get_text_font_height(FONT_SIZE_DEFAULT) * 1.4f; + } else { + return lvgl_get_text_font_height(FONT_SIZE_LARGE) * 2.2f; + } +} + +static const _lv_font_t* getToolbarFont(UiDensity uiDensity) { + if (uiDensity == LVGL_UI_DENSITY_COMPACT) { + return lvgl_get_text_font(FONT_SIZE_DEFAULT); + } else { + return lvgl_get_text_font(FONT_SIZE_LARGE); + } +} + +static uint32_t getActionIconPadding(UiDensity uiDensity) { + auto toolbar_height = getToolbarHeight(uiDensity); + // Minimal 8 pixels total padding for selection/animation (4+4 pixels) + return (uiDensity != LVGL_UI_DENSITY_COMPACT) ? (uint32_t)(toolbar_height * 0.2f) : 8; +} + +/** + * Helps with button expansion and also with vertical alignment of content, + * as the parent flex doesn't allow for vertical alignment + */ +static lv_obj_t* create_action_wrapper(lv_obj_t* parent, UiDensity ui_density) { + auto* wrapper = lv_obj_create(parent); + auto toolbar_height = getToolbarHeight(ui_density); + lv_obj_set_size(wrapper, LV_SIZE_CONTENT, toolbar_height); + + auto icon_padding = getActionIconPadding(ui_density); + auto icon_padding_half = icon_padding / 2; + + lv_obj_set_style_pad_all(wrapper, icon_padding_half, LV_STATE_DEFAULT); // For selection and touch animation + lv_obj_set_style_bg_opa(wrapper, 0, LV_STATE_DEFAULT); + lv_obj_set_style_border_width(wrapper, 0, LV_STATE_DEFAULT); + lv_obj_set_style_border_opa(wrapper, 0, LV_STATE_DEFAULT); + + return wrapper; +} + +typedef struct { + lv_obj_t obj; + lv_obj_t* title_label; + lv_obj_t* close_button; + lv_obj_t* close_button_image; + lv_obj_t* action_container; + uint8_t action_count; +} Toolbar; + +static void toolbar_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj); + +static lv_obj_class_t toolbar_class = { + .base_class = &lv_obj_class, + .constructor_cb = &toolbar_constructor, + .destructor_cb = nullptr, + .event_cb = nullptr, + .user_data = nullptr, + .name = nullptr, + .width_def = LV_PCT(100), + .height_def = 0, + .editable = false, + .group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE, + .instance_size = sizeof(Toolbar), + .theme_inheritable = false +}; + +static lv_event_cb_t nav_action_callback = nullptr; + +void lvgl_toolbar_configure(const ToolbarConfig* config) { + nav_action_callback = config->nav_action_callback; +} + +static void default_nav_action(lv_event_t* event) { + if (nav_action_callback != nullptr) { + nav_action_callback(event); + } +} + +static void toolbar_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj) { + LV_UNUSED(class_p); + lv_obj_remove_flag(obj, LV_OBJ_FLAG_SCROLLABLE); + lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS); +} + +lv_obj_t* lvgl_toolbar_create(lv_obj_t* parent, const char* title) { + auto ui_density = lvgl_get_ui_density(); + auto toolbar_height = getToolbarHeight(ui_density); + toolbar_class.height_def = toolbar_height; + lv_obj_t* obj = lv_obj_class_create_obj(&toolbar_class, parent); + lv_obj_class_init_obj(obj); + lv_obj_set_height(obj, toolbar_height); + + auto* toolbar = reinterpret_cast(obj); + lv_obj_set_width(obj, LV_PCT(100)); + lv_obj_set_style_pad_all(obj, 0, LV_STATE_DEFAULT); + lv_obj_set_style_pad_column(obj, 0, LV_STATE_DEFAULT); + + lv_obj_center(obj); + lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_ROW); + + auto icon_padding = getActionIconPadding(ui_density); + + auto* close_button_wrapper = create_action_wrapper(obj, ui_density); + + toolbar->close_button = lv_button_create(close_button_wrapper); + if (ui_density == LVGL_UI_DENSITY_COMPACT) { + lv_obj_set_style_bg_opa(toolbar->close_button, LV_OPA_TRANSP, LV_STATE_DEFAULT); + } + + lv_obj_set_size(toolbar->close_button, toolbar_height - icon_padding, toolbar_height - icon_padding); + + lv_obj_set_style_pad_all(toolbar->close_button, 0, LV_STATE_DEFAULT); + lv_obj_align(toolbar->close_button, LV_ALIGN_CENTER, 0, 0); + toolbar->close_button_image = lv_image_create(toolbar->close_button); + lv_obj_align(toolbar->close_button_image, LV_ALIGN_CENTER, 0, 0); + + auto* title_wrapper = lv_obj_create(obj); + uint32_t title_left_padding = (ui_density != LVGL_UI_DENSITY_COMPACT) ? icon_padding : 2; + uint32_t title_right_padding = (ui_density != LVGL_UI_DENSITY_COMPACT) ? (icon_padding / 2) : 2; + lv_obj_set_size(title_wrapper, LV_SIZE_CONTENT, LV_PCT(100)); + lv_obj_set_style_bg_opa(title_wrapper, 0, LV_STATE_DEFAULT); + lv_obj_set_style_pad_left(title_wrapper, title_left_padding, LV_STATE_DEFAULT); + lv_obj_set_style_pad_right(title_wrapper, title_right_padding, LV_STATE_DEFAULT); + lv_obj_set_style_pad_ver(title_wrapper, 0, LV_STATE_DEFAULT); + lv_obj_set_style_border_width(title_wrapper, 0, LV_STATE_DEFAULT); + lv_obj_set_flex_grow(title_wrapper, 1); + + toolbar->title_label = lv_label_create(title_wrapper); + lv_obj_set_style_text_font(toolbar->title_label, getToolbarFont(ui_density), LV_STATE_DEFAULT); + lv_label_set_text(toolbar->title_label, title); + lv_label_set_long_mode(toolbar->title_label, LV_LABEL_LONG_MODE_SCROLL); + lv_obj_set_style_text_align(toolbar->title_label, LV_TEXT_ALIGN_LEFT, LV_STATE_DEFAULT); + lv_obj_align(toolbar->title_label, LV_ALIGN_LEFT_MID, 0, 0); + lv_obj_set_width(toolbar->title_label, LV_PCT(100)); + + toolbar->action_container = lv_obj_create(obj); + lv_obj_set_width(toolbar->action_container, LV_SIZE_CONTENT); + lv_obj_set_flex_flow(toolbar->action_container, LV_FLEX_FLOW_ROW); + lv_obj_set_style_pad_all(toolbar->action_container, 0, LV_STATE_DEFAULT); + lv_obj_set_style_pad_column(toolbar->action_container, 0, LV_STATE_DEFAULT); + lv_obj_set_style_border_width(toolbar->action_container, 0, LV_STATE_DEFAULT); + lv_obj_set_style_bg_opa(toolbar->action_container, 0, LV_STATE_DEFAULT); + + lvgl_toolbar_set_nav_action(obj, LV_SYMBOL_CLOSE, &default_nav_action, nullptr); + + // If we don't have a touch device, we assume there's some other kind of input like a keyboard, an encoder or button control + // In that scenario we want to automatically have the close button selected so the user doesn't have to press the widget selection + // an extra time for every screen. + if (!device_has_active_by_type(&POINTER_TYPE)) { + lv_group_focus_obj(toolbar->close_button); + } + + return obj; +} + +void lvgl_toolbar_set_title(lv_obj_t* obj, const char* title) { + auto* toolbar = reinterpret_cast(obj); + lv_label_set_text(toolbar->title_label, title); +} + +void lvgl_toolbar_set_nav_action(lv_obj_t* obj, const char* icon, lv_event_cb_t callback, void* user_data) { + auto* toolbar = reinterpret_cast(obj); + lv_obj_add_event_cb(toolbar->close_button, callback, LV_EVENT_SHORT_CLICKED, user_data); + lv_image_set_src(toolbar->close_button_image, icon); // e.g. LV_SYMBOL_CLOSE +} + +static lv_obj_t* toolbar_add_button_action(lv_obj_t* obj, const char* imageOrButton, bool isImage, lv_event_cb_t callback, void* user_data) { + auto* toolbar = reinterpret_cast(obj); + check(toolbar->action_count < TOOLBAR_ACTION_LIMIT, "max actions reached"); + toolbar->action_count++; + + auto ui_density = lvgl_get_ui_density(); + auto toolbar_height = getToolbarHeight(ui_density); + + auto* wrapper = create_action_wrapper(toolbar->action_container, ui_density); + + auto padding = getActionIconPadding(ui_density); + + lv_obj_t* action_button = lv_button_create(wrapper); + lv_obj_set_size(action_button, toolbar_height - padding, toolbar_height - padding); + lv_obj_set_style_pad_all(action_button, 0, LV_STATE_DEFAULT); + lv_obj_align(action_button, LV_ALIGN_CENTER, 0, 0); + if (ui_density == LVGL_UI_DENSITY_COMPACT) { + lv_obj_set_style_bg_opa(action_button, LV_OPA_TRANSP, LV_STATE_DEFAULT); + } + + lv_obj_add_event_cb(action_button, callback, LV_EVENT_SHORT_CLICKED, user_data); + lv_obj_t* button_content; + if (isImage) { + button_content = lv_image_create(action_button); + lv_image_set_src(button_content, imageOrButton); + } else { + button_content = lv_label_create(action_button); + lv_label_set_text(button_content, imageOrButton); + } + lv_obj_align(button_content, LV_ALIGN_CENTER, 0, 0); + + return action_button; +} + +lv_obj_t* lvgl_toolbar_add_image_button_action(lv_obj_t* obj, const char* imagePath, lv_event_cb_t callback, void* user_data) { + return toolbar_add_button_action(obj, imagePath, true, callback, user_data); +} + +lv_obj_t* lvgl_toolbar_add_text_button_action(lv_obj_t* obj, const char* text, lv_event_cb_t callback, void* user_data) { + return toolbar_add_button_action(obj, text, false, callback, user_data); +} + +lv_obj_t* lvgl_toolbar_add_switch_action(lv_obj_t* obj) { + auto* toolbar = reinterpret_cast(obj); + check(toolbar->action_count < TOOLBAR_ACTION_LIMIT, "max actions reached"); + toolbar->action_count++; + + auto ui_density = lvgl_get_ui_density(); + auto* wrapper = create_action_wrapper(toolbar->action_container, ui_density); + lv_obj_set_style_pad_hor(wrapper, 4, LV_STATE_DEFAULT); + + lv_obj_t* widget = lv_switch_create(wrapper); + lv_obj_set_align(widget, LV_ALIGN_CENTER); + + return widget; +} + +lv_obj_t* lvgl_toolbar_add_spinner_action(lv_obj_t* obj) { + auto* toolbar = reinterpret_cast(obj); + check(toolbar->action_count < TOOLBAR_ACTION_LIMIT, "max actions reached"); + toolbar->action_count++; + + auto ui_density = lvgl_get_ui_density(); + auto* wrapper = create_action_wrapper(toolbar->action_container, ui_density); + + auto* spinner = lvgl_spinner_create(wrapper); + lv_obj_set_align(spinner, LV_ALIGN_CENTER); + + if (lv_display_get_color_format(lv_obj_get_display(obj)) == LV_COLOR_FORMAT_L8) { + lv_obj_set_style_image_recolor(spinner, lv_theme_get_color_secondary(obj), LV_STATE_DEFAULT); + lv_obj_set_style_image_recolor_opa(spinner, LV_OPA_COVER, LV_STATE_DEFAULT); + } + + return spinner; +} + +void lvgl_toolbar_clear_actions(lv_obj_t* obj) { + auto* toolbar = reinterpret_cast(obj); + lv_obj_clean(toolbar->action_container); + toolbar->action_count = 0; +} diff --git a/Tactility/Include/Tactility/lvgl/SliderBox.h b/Tactility/Include/Tactility/lvgl/SliderBox.h deleted file mode 100644 index 263aeb831..000000000 --- a/Tactility/Include/Tactility/lvgl/SliderBox.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include - -namespace tt::lvgl { - -/** - * Create a SliderBox: a slider flanked by "-" and "+" buttons with a value label. - * @param parent the parent object - * @param min minimum value (inclusive) - * @param max maximum value (inclusive) - * @param step the amount each +/- button press changes the value by - * @param value the initial value - * @return the created SliderBox instance - */ -lv_obj_t* sliderbox_create(lv_obj_t* parent, int32_t min, int32_t max, int32_t step, int32_t value); - -/** @return the current value of the SliderBox */ -int32_t sliderbox_get_value(lv_obj_t* obj); - -/** - * Set the current value of the SliderBox (clamped to its [min, max] range). - * Updates the slider position and the value label. - */ -void sliderbox_set_value(lv_obj_t* obj, int32_t value, lv_anim_enable_t anim); - -/** - * Register a callback that is fired with LV_EVENT_VALUE_CHANGED whenever the value - * changes, whether the change came from the slider or from the +/- buttons. - * @param obj the SliderBox instance - * @param callback the callback to invoke - * @param userData user data that is attached to the event - */ -void sliderbox_add_value_changed_cb(lv_obj_t* obj, lv_event_cb_t callback, void* userData); - -} // namespace tt::lvgl diff --git a/Tactility/Include/Tactility/lvgl/Spinner.h b/Tactility/Include/Tactility/lvgl/Spinner.h deleted file mode 100644 index 39b200086..000000000 --- a/Tactility/Include/Tactility/lvgl/Spinner.h +++ /dev/null @@ -1,12 +0,0 @@ -#include - -namespace tt::lvgl { - -/** - * Create the Tactility spinner widget - * @param parent pointer to an object, it will be the parent of the new spinner. - * @return the created spinner - */ -lv_obj_t* spinner_create(lv_obj_t* parent); - -} diff --git a/Tactility/Include/Tactility/lvgl/Toolbar.h b/Tactility/Include/Tactility/lvgl/Toolbar.h index 3e27a3f72..486cfe78f 100644 --- a/Tactility/Include/Tactility/lvgl/Toolbar.h +++ b/Tactility/Include/Tactility/lvgl/Toolbar.h @@ -2,67 +2,11 @@ #include "../app/AppContext.h" -#include +#include namespace tt::lvgl { -#define TOOLBAR_ACTION_LIMIT 4 - /** Create a toolbar widget that shows the app name as title */ lv_obj_t* toolbar_create(lv_obj_t* parent, const app::AppContext& app); -/** Create a toolbar widget with the provided title*/ -lv_obj_t* toolbar_create(lv_obj_t* parent, const std::string& title); - -/** Sets the toolbar title */ -void toolbar_set_title(lv_obj_t* obj, const std::string& title); - -/** Sets the navigation action of the toolbar (button on the top-left) - * @param[in] obj the toolbar instance - * @param[in] icon the icon to set on the button - * @param[in] callback the callback for the click action of the button - * @param[in] callbackEventUserData the user data that is attached to the callback event object - */ -void toolbar_set_nav_action(lv_obj_t* obj, const char* icon, lv_event_cb_t callback, void* userData); - -/** - * Create and add an action button with an image to the toolbar (aligned to the right of the toolbar) - * @param[in] obj the toolbar instance - * @param[in] imagePath the path to an image file to shown on the button - * @param[in] callback the callback for the click action of the button - * @param[in] callbackUserData the user data that is passed to the callback - * @return an lv_button instance - */ -lv_obj_t* toolbar_add_image_button_action(lv_obj_t* obj, const char* imagePath, lv_event_cb_t callback, void* callbackUserData); - -/** - * Create and add an action button with text to the toolbar (aligned to the right of the toolbar) - * @param[in] obj the toolbar instance - * @param[in] text the button text - * @param[in] callback the callback for the click action of the button - * @param[in] callbackUserData the user data that is passed to the callback - * @return an lv_button instance - */ -lv_obj_t* toolbar_add_text_button_action(lv_obj_t* obj, const char* text, lv_event_cb_t callback, void* callbackUserData); - -/** - * Create and add a switch to the toolbar actions. - * @param[in] obj the toolbar instance - * @return an instance created by lv_switch_create() - */ -lv_obj_t* toolbar_add_switch_action(lv_obj_t* obj); - -/** - * Create and add a spinner to the toolbar actions. - * @param[in] obj the toolbar instance - * @return an instance created by Tactility's spinner_create() - */ -lv_obj_t* toolbar_add_spinner_action(lv_obj_t* obj); - -/** - * Remove all actions from the toolbar - * @param[in] obj the toolbar instance - */ -void toolbar_clear_actions(lv_obj_t* obj); - } // namespace diff --git a/Tactility/Source/Tactility.cpp b/Tactility/Source/Tactility.cpp index 03c98b189..3ed13adbb 100644 --- a/Tactility/Source/Tactility.cpp +++ b/Tactility/Source/Tactility.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -350,7 +351,14 @@ void registerApps() { registerInstalledAppsFromFileSystems(); } +static void stopAppFromToolbar(lv_event_t*) { + app::stop(); +} + static void onLvglStarted() { + ToolbarConfig toolbar_config = { .nav_action_callback = stopAppFromToolbar }; + lvgl_toolbar_configure(&toolbar_config); + addService(service::gui::manifest); addService(service::statusbar::manifest); addService(service::memorychecker::manifest); diff --git a/Tactility/Source/app/addgps/AddGps.cpp b/Tactility/Source/app/addgps/AddGps.cpp index dce180e68..c1d187e5e 100644 --- a/Tactility/Source/app/addgps/AddGps.cpp +++ b/Tactility/Source/app/addgps/AddGps.cpp @@ -4,9 +4,9 @@ #include #include +#include #include #include -#include #include #include diff --git a/Tactility/Source/app/alertdialog/AlertDialog.cpp b/Tactility/Source/app/alertdialog/AlertDialog.cpp index ebfa24b5c..7f1ac2609 100644 --- a/Tactility/Source/app/alertdialog/AlertDialog.cpp +++ b/Tactility/Source/app/alertdialog/AlertDialog.cpp @@ -1,6 +1,6 @@ #include "Tactility/app/alertdialog/AlertDialog.h" -#include "Tactility/lvgl/Toolbar.h" +#include #include "Tactility/service/loader/Loader.h" #include @@ -98,7 +98,7 @@ public: check(parameters != nullptr, "Parameters missing"); std::string title = getTitleParameter(app.getParameters()); - lv_obj_t* toolbar = lvgl::toolbar_create(parent, title); + lv_obj_t* toolbar = lvgl_toolbar_create(parent, title.c_str()); lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0); lv_obj_t* message_label = lv_label_create(parent); diff --git a/Tactility/Source/app/appdetails/AppDetails.cpp b/Tactility/Source/app/appdetails/AppDetails.cpp index 88a6ef78e..96bb0c090 100644 --- a/Tactility/Source/app/appdetails/AppDetails.cpp +++ b/Tactility/Source/app/appdetails/AppDetails.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include @@ -51,7 +51,7 @@ public: lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT); auto title = std::format("{} details", manifest->appName); - lvgl::toolbar_create(parent, title); + lvgl_toolbar_create(parent, title.c_str()); auto* wrapper = lv_obj_create(parent); lv_obj_set_width(wrapper, LV_PCT(100)); diff --git a/Tactility/Source/app/apphub/AppHubApp.cpp b/Tactility/Source/app/apphub/AppHubApp.cpp index 3ae5e4773..d6a0145fd 100644 --- a/Tactility/Source/app/apphub/AppHubApp.cpp +++ b/Tactility/Source/app/apphub/AppHubApp.cpp @@ -3,18 +3,18 @@ #include #include #include -#include +#include #include #include #include #include #include -#include -#include -#include +#include #include #include +#include +#include namespace tt::app::apphub { @@ -125,7 +125,7 @@ class AppHubApp final : public App { void refresh() { lv_obj_clean(contentWrapper); - auto* spinner = lvgl::spinner_create(contentWrapper); + auto* spinner = lvgl_spinner_create(contentWrapper); lv_obj_align(spinner, LV_ALIGN_CENTER, 0, 0); lv_obj_add_flag(refreshButton, LV_OBJ_FLAG_HIDDEN); @@ -165,7 +165,7 @@ public: lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT); auto* toolbar = lvgl::toolbar_create(parent, app); - refreshButton = lvgl::toolbar_add_image_button_action(toolbar, LV_SYMBOL_REFRESH, onRefreshPressed, this); + refreshButton = lvgl_toolbar_add_image_button_action(toolbar, LV_SYMBOL_REFRESH, onRefreshPressed, this); lv_obj_add_flag(refreshButton, LV_OBJ_FLAG_HIDDEN); contentWrapper = lv_obj_create(parent); diff --git a/Tactility/Source/app/apphubdetails/AppHubDetailsApp.cpp b/Tactility/Source/app/apphubdetails/AppHubDetailsApp.cpp index aafd98913..16b977d4a 100644 --- a/Tactility/Source/app/apphubdetails/AppHubDetailsApp.cpp +++ b/Tactility/Source/app/apphubdetails/AppHubDetailsApp.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include @@ -154,19 +154,19 @@ class AppHubDetailsApp final : public App { } void updateViews() { - lvgl::toolbar_clear_actions(toolbar); + lvgl_toolbar_clear_actions(toolbar); const auto manifest = findAppManifestById(entry.appId); - spinner = lvgl::toolbar_add_spinner_action(toolbar); + spinner = lvgl_toolbar_add_spinner_action(toolbar); lv_obj_add_flag(spinner, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(updateLabel, LV_OBJ_FLAG_HIDDEN); if (manifest != nullptr) { if (manifest->appVersionCode < entry.appVersionCode) { - updateButton = lvgl::toolbar_add_image_button_action(toolbar, LV_SYMBOL_DOWNLOAD, onUpdatePressed, this); + updateButton = lvgl_toolbar_add_image_button_action(toolbar, LV_SYMBOL_DOWNLOAD, onUpdatePressed, this); lv_obj_remove_flag(updateLabel, LV_OBJ_FLAG_HIDDEN); } - lvgl::toolbar_add_image_button_action(toolbar, LV_SYMBOL_TRASH, onUninstallPressed, this); + lvgl_toolbar_add_image_button_action(toolbar, LV_SYMBOL_TRASH, onUninstallPressed, this); } else { - lvgl::toolbar_add_image_button_action(toolbar, LV_SYMBOL_DOWNLOAD, onInstallPressed, this); + lvgl_toolbar_add_image_button_action(toolbar, LV_SYMBOL_DOWNLOAD, onInstallPressed, this); } } @@ -190,7 +190,7 @@ public: lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT); - toolbar = lvgl::toolbar_create(parent, entry.appName.c_str()); + toolbar = lvgl_toolbar_create(parent, entry.appName.c_str()); auto* wrapper = lv_obj_create(parent); lv_obj_set_width(wrapper, LV_PCT(100)); lv_obj_set_flex_grow(wrapper, 1); diff --git a/Tactility/Source/app/applist/AppList.cpp b/Tactility/Source/app/applist/AppList.cpp index bd2882bbc..1957ea7d6 100644 --- a/Tactility/Source/app/applist/AppList.cpp +++ b/Tactility/Source/app/applist/AppList.cpp @@ -5,8 +5,8 @@ #include #include -#include -#include +#include +#include namespace tt::app::applist { diff --git a/Tactility/Source/app/appsettings/AppSettings.cpp b/Tactility/Source/app/appsettings/AppSettings.cpp index d53323cd4..0e25c72be 100644 --- a/Tactility/Source/app/appsettings/AppSettings.cpp +++ b/Tactility/Source/app/appsettings/AppSettings.cpp @@ -1,10 +1,10 @@ -#include -#include +#include +#include #include #include -#include #include +#include #include #include @@ -29,7 +29,7 @@ class AppSettingsApp final : public App { public: void onShow(AppContext& app, lv_obj_t* parent) override { - auto* toolbar = lvgl::toolbar_create(parent, "Installed Apps"); + auto* toolbar = lvgl_toolbar_create(parent, "Installed Apps"); lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0); lv_obj_t* list = lv_list_create(parent); diff --git a/Tactility/Source/app/audiosettings/AudioSettings.cpp b/Tactility/Source/app/audiosettings/AudioSettings.cpp index 399228c78..ec48d6c5a 100644 --- a/Tactility/Source/app/audiosettings/AudioSettings.cpp +++ b/Tactility/Source/app/audiosettings/AudioSettings.cpp @@ -1,13 +1,13 @@ #include -#include +#include #include #include #include -#include #include #include +#include #include #include @@ -52,13 +52,13 @@ class AudioSettingsApp final : public App { static void onInputVolumeSlider(lv_event_t* event) { auto* sliderBox = static_cast(lv_event_get_target(event)); - float percent = static_cast(lvgl::sliderbox_get_value(sliderBox)); + float percent = static_cast(lvgl_sliderbox_get_value(sliderBox)); service::audio::setInputVolume(percent); } static void onOutputVolumeSlider(lv_event_t* event) { auto* sliderBox = static_cast(lv_event_get_target(event)); - float percent = static_cast(lvgl::sliderbox_get_value(sliderBox)); + float percent = static_cast(lvgl_sliderbox_get_value(sliderBox)); service::audio::setOutputVolume(percent); } @@ -102,10 +102,10 @@ class AudioSettingsApp final : public App { lv_label_set_text(row_label, label); lv_obj_align(row_label, LV_ALIGN_LEFT_MID, 0, 0); - auto* sliderBox = lvgl::sliderbox_create(row, 0, 100, 10, initialValue); + auto* sliderBox = lvgl_sliderbox_create(row, 0, 100, 10, initialValue); lv_obj_set_width(sliderBox, LV_PCT(50)); lv_obj_align(sliderBox, LV_ALIGN_RIGHT_MID, 0, 0); - lvgl::sliderbox_add_value_changed_cb(sliderBox, cb, userData); + lvgl_sliderbox_add_value_changed_cb(sliderBox, cb, userData); return sliderBox; } @@ -192,7 +192,7 @@ public: else lv_obj_remove_state(inputMuteSwitch, LV_STATE_CHECKED); } if (inputVolumeSlider) { - lvgl::sliderbox_set_value(inputVolumeSlider, static_cast(service::audio::getInputVolume()), LV_ANIM_OFF); + lvgl_sliderbox_set_value(inputVolumeSlider, static_cast(service::audio::getInputVolume()), LV_ANIM_OFF); } if (outputEnabledSwitch) { @@ -204,7 +204,7 @@ public: else lv_obj_remove_state(outputMuteSwitch, LV_STATE_CHECKED); } if (outputVolumeSlider) { - lvgl::sliderbox_set_value(outputVolumeSlider, static_cast(service::audio::getOutputVolume()), LV_ANIM_OFF); + lvgl_sliderbox_set_value(outputVolumeSlider, static_cast(service::audio::getOutputVolume()), LV_ANIM_OFF); } } }; diff --git a/Tactility/Source/app/btmanage/BtManage.cpp b/Tactility/Source/app/btmanage/BtManage.cpp index 94bf04b3d..537e59a23 100644 --- a/Tactility/Source/app/btmanage/BtManage.cpp +++ b/Tactility/Source/app/btmanage/BtManage.cpp @@ -7,8 +7,8 @@ #include #include +#include #include -#include namespace tt::app::btmanage { diff --git a/Tactility/Source/app/btmanage/View.cpp b/Tactility/Source/app/btmanage/View.cpp index 0d9b2b90b..c0d356fc9 100644 --- a/Tactility/Source/app/btmanage/View.cpp +++ b/Tactility/Source/app/btmanage/View.cpp @@ -222,9 +222,9 @@ void View::init(const AppContext& app, lv_obj_t* parent) { // Toolbar auto* toolbar = lvgl::toolbar_create(parent, app); - scanning_spinner = lvgl::toolbar_add_spinner_action(toolbar); + scanning_spinner = lvgl_toolbar_add_spinner_action(toolbar); - enable_switch = lvgl::toolbar_add_switch_action(toolbar); + enable_switch = lvgl_toolbar_add_switch_action(toolbar); lv_obj_add_event_cb(enable_switch, onEnableSwitchChanged, LV_EVENT_VALUE_CHANGED, nullptr); // Peer list diff --git a/Tactility/Source/app/btpeersettings/BtPeerSettings.cpp b/Tactility/Source/app/btpeersettings/BtPeerSettings.cpp index a178c2900..d4c792a7f 100644 --- a/Tactility/Source/app/btpeersettings/BtPeerSettings.cpp +++ b/Tactility/Source/app/btpeersettings/BtPeerSettings.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -138,7 +138,7 @@ public: lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT); - lvgl::toolbar_create(parent, title); + lvgl_toolbar_create(parent, title.c_str()); auto* wrapper = lv_obj_create(parent); lv_obj_set_width(wrapper, LV_PCT(100)); diff --git a/Tactility/Source/app/chat/ChatApp.cpp b/Tactility/Source/app/chat/ChatApp.cpp index d2fde94b1..5ad89c4c9 100644 --- a/Tactility/Source/app/chat/ChatApp.cpp +++ b/Tactility/Source/app/chat/ChatApp.cpp @@ -10,11 +10,11 @@ #include #include +#include #include #include #include #include -#include #include namespace tt::app::chat { diff --git a/Tactility/Source/app/chat/ChatView.cpp b/Tactility/Source/app/chat/ChatView.cpp index eb9368fa3..b2a01b678 100644 --- a/Tactility/Source/app/chat/ChatView.cpp +++ b/Tactility/Source/app/chat/ChatView.cpp @@ -34,7 +34,7 @@ void ChatView::updateToolbarTitle() { if (!state || !toolbar) return; std::string channel = state->getCurrentChannel(); std::string title = "Chat: " + channel; - lvgl::toolbar_set_title(toolbar, title); + lvgl_toolbar_set_title(toolbar, title.c_str()); } void ChatView::createInputBar(lv_obj_t* parent) { @@ -149,8 +149,8 @@ void ChatView::init(AppContext& appContext, lv_obj_t* parent) { lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT); toolbar = lvgl::toolbar_create(parent, appContext); - lvgl::toolbar_add_text_button_action(toolbar, LV_SYMBOL_LIST, onChannelClicked, this); - lvgl::toolbar_add_text_button_action(toolbar, LV_SYMBOL_SETTINGS, onSettingsClicked, this); + lvgl_toolbar_add_text_button_action(toolbar, LV_SYMBOL_LIST, onChannelClicked, this); + lvgl_toolbar_add_text_button_action(toolbar, LV_SYMBOL_SETTINGS, onSettingsClicked, this); updateToolbarTitle(); // Message list diff --git a/Tactility/Source/app/development/Development.cpp b/Tactility/Source/app/development/Development.cpp index bfedf8857..e7ecf8df8 100644 --- a/Tactility/Source/app/development/Development.cpp +++ b/Tactility/Source/app/development/Development.cpp @@ -11,9 +11,9 @@ #include #include -#include -#include +#include #include +#include #include #include @@ -98,7 +98,7 @@ public: lv_obj_t* toolbar = lvgl::toolbar_create(parent, app); - enableSwitch = lvgl::toolbar_add_switch_action(toolbar); + enableSwitch = lvgl_toolbar_add_switch_action(toolbar); lv_obj_add_event_cb(enableSwitch, onEnableSwitchChanged, LV_EVENT_VALUE_CHANGED, this); if (service->isEnabled()) { diff --git a/Tactility/Source/app/files/View.cpp b/Tactility/Source/app/files/View.cpp index 5c5c797ac..b019a809a 100644 --- a/Tactility/Source/app/files/View.cpp +++ b/Tactility/Source/app/files/View.cpp @@ -523,10 +523,10 @@ void View::init(const AppContext& appContext, lv_obj_t* parent) { lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT); auto* toolbar = lvgl::toolbar_create(parent, appContext); - navigate_up_button = lvgl::toolbar_add_image_button_action(toolbar, LV_SYMBOL_UP, &onNavigateUpPressedCallback, this); - new_file_button = lvgl::toolbar_add_image_button_action(toolbar, LV_SYMBOL_FILE, &onNewFilePressedCallback, this); - new_folder_button = lvgl::toolbar_add_image_button_action(toolbar, LV_SYMBOL_DIRECTORY, &onNewFolderPressedCallback, this); - paste_button = lvgl::toolbar_add_image_button_action(toolbar, LV_SYMBOL_PASTE, &onPastePressedCallback, this); + navigate_up_button = lvgl_toolbar_add_image_button_action(toolbar, LV_SYMBOL_UP, &onNavigateUpPressedCallback, this); + new_file_button = lvgl_toolbar_add_image_button_action(toolbar, LV_SYMBOL_FILE, &onNewFilePressedCallback, this); + new_folder_button = lvgl_toolbar_add_image_button_action(toolbar, LV_SYMBOL_DIRECTORY, &onNewFolderPressedCallback, this); + paste_button = lvgl_toolbar_add_image_button_action(toolbar, LV_SYMBOL_PASTE, &onPastePressedCallback, this); lv_obj_add_flag(lv_obj_get_parent(paste_button), LV_OBJ_FLAG_HIDDEN); auto* wrapper = lv_obj_create(parent); diff --git a/Tactility/Source/app/fileselection/View.cpp b/Tactility/Source/app/fileselection/View.cpp index 96a9216c5..e4342fbf9 100644 --- a/Tactility/Source/app/fileselection/View.cpp +++ b/Tactility/Source/app/fileselection/View.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include @@ -181,8 +181,8 @@ void View::init(lv_obj_t* parent, Mode mode) { lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT); - auto* toolbar = lvgl::toolbar_create(parent, "Select File"); - navigate_up_button = lvgl::toolbar_add_image_button_action(toolbar, LV_SYMBOL_UP, &onNavigateUpPressedCallback, this); + auto* toolbar = lvgl_toolbar_create(parent, "Select File"); + navigate_up_button = lvgl_toolbar_add_image_button_action(toolbar, LV_SYMBOL_UP, &onNavigateUpPressedCallback, this); auto* wrapper = lv_obj_create(parent); lv_obj_set_width(wrapper, LV_PCT(100)); diff --git a/Tactility/Source/app/gpssettings/GpsSettings.cpp b/Tactility/Source/app/gpssettings/GpsSettings.cpp index e54f0a23e..e2af6a3af 100644 --- a/Tactility/Source/app/gpssettings/GpsSettings.cpp +++ b/Tactility/Source/app/gpssettings/GpsSettings.cpp @@ -1,5 +1,5 @@ +#include #include -#include #include #include @@ -223,7 +223,7 @@ public: uint8_t margin = (lvgl_get_ui_density() == LVGL_UI_DENSITY_COMPACT) ? 2 : 8; auto* toolbar = lvgl::toolbar_create(parent, app); - lvgl::toolbar_add_text_button_action(toolbar, LV_SYMBOL_PLUS, onAddGpsCallback, this); + lvgl_toolbar_add_text_button_action(toolbar, LV_SYMBOL_PLUS, onAddGpsCallback, this); lv_obj_set_style_margin_bottom(toolbar, margin, LV_STATE_DEFAULT); deviceListWrapper = lv_obj_create(parent); diff --git a/Tactility/Source/app/grovesettings/GroveSettings.cpp b/Tactility/Source/app/grovesettings/GroveSettings.cpp index b0190f1d8..cd52e77d6 100644 --- a/Tactility/Source/app/grovesettings/GroveSettings.cpp +++ b/Tactility/Source/app/grovesettings/GroveSettings.cpp @@ -2,9 +2,9 @@ #include +#include #include #include -#include #include #include diff --git a/Tactility/Source/app/i2cscanner/I2cScanner.cpp b/Tactility/Source/app/i2cscanner/I2cScanner.cpp index 4fac1d179..471fb71c8 100644 --- a/Tactility/Source/app/i2cscanner/I2cScanner.cpp +++ b/Tactility/Source/app/i2cscanner/I2cScanner.cpp @@ -13,8 +13,8 @@ #include +#include #include -#include namespace tt::app::i2cscanner { diff --git a/Tactility/Source/app/inputdialog/InputDialog.cpp b/Tactility/Source/app/inputdialog/InputDialog.cpp index 4c0184daf..8590abf29 100644 --- a/Tactility/Source/app/inputdialog/InputDialog.cpp +++ b/Tactility/Source/app/inputdialog/InputDialog.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include #include @@ -83,7 +83,7 @@ public: check(parameters != nullptr, "Parameters missing"); std::string title = getTitleParameter(app.getParameters()); - auto* toolbar = lvgl::toolbar_create(parent, title); + auto* toolbar = lvgl_toolbar_create(parent, title.c_str()); lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0); auto* message_label = lv_label_create(parent); diff --git a/Tactility/Source/app/kerneldisplay/KernelDisplay.cpp b/Tactility/Source/app/kerneldisplay/KernelDisplay.cpp index 2b141bc8f..d37ffef37 100644 --- a/Tactility/Source/app/kerneldisplay/KernelDisplay.cpp +++ b/Tactility/Source/app/kerneldisplay/KernelDisplay.cpp @@ -1,10 +1,10 @@ -#include -#include -#include +#include +#include #include #include +#include +#include #include -#include #include #ifdef ESP_PLATFORM diff --git a/Tactility/Source/app/keyboard/KeyboardSettings.cpp b/Tactility/Source/app/keyboard/KeyboardSettings.cpp index 0e55458de..073c4aa83 100644 --- a/Tactility/Source/app/keyboard/KeyboardSettings.cpp +++ b/Tactility/Source/app/keyboard/KeyboardSettings.cpp @@ -5,9 +5,9 @@ #include #include +#include #include #include -#include #include diff --git a/Tactility/Source/app/launcher/Launcher.cpp b/Tactility/Source/app/launcher/Launcher.cpp index 07019cc8d..877997f15 100644 --- a/Tactility/Source/app/launcher/Launcher.cpp +++ b/Tactility/Source/app/launcher/Launcher.cpp @@ -10,12 +10,12 @@ #include #include +#include +#include +#include #include #include #include -#include -#include -#include namespace tt::app::launcher { diff --git a/Tactility/Source/app/localesettings/LocaleSettings.cpp b/Tactility/Source/app/localesettings/LocaleSettings.cpp index 6c0b64edd..50db7e239 100644 --- a/Tactility/Source/app/localesettings/LocaleSettings.cpp +++ b/Tactility/Source/app/localesettings/LocaleSettings.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include diff --git a/Tactility/Source/app/notes/Notes.cpp b/Tactility/Source/app/notes/Notes.cpp index 075be0edd..5591c6235 100644 --- a/Tactility/Source/app/notes/Notes.cpp +++ b/Tactility/Source/app/notes/Notes.cpp @@ -7,9 +7,9 @@ #include +#include #include #include -#include namespace tt::app::notes { diff --git a/Tactility/Source/app/power/Power.cpp b/Tactility/Source/app/power/Power.cpp index df5b67e81..e2ccf4896 100644 --- a/Tactility/Source/app/power/Power.cpp +++ b/Tactility/Source/app/power/Power.cpp @@ -6,9 +6,9 @@ #include +#include #include #include -#include #include diff --git a/Tactility/Source/app/poweroff/PowerOff.cpp b/Tactility/Source/app/poweroff/PowerOff.cpp index 580e03e53..e6166e338 100644 --- a/Tactility/Source/app/poweroff/PowerOff.cpp +++ b/Tactility/Source/app/poweroff/PowerOff.cpp @@ -6,11 +6,11 @@ #include #include +#include #include +#include #include #include -#include -#include namespace tt::app::poweroff { diff --git a/Tactility/Source/app/screenshot/Screenshot.cpp b/Tactility/Source/app/screenshot/Screenshot.cpp index e8aa9e0aa..80c6ee599 100644 --- a/Tactility/Source/app/screenshot/Screenshot.cpp +++ b/Tactility/Source/app/screenshot/Screenshot.cpp @@ -14,8 +14,8 @@ #include #include +#include #include -#include namespace tt::app::screenshot { diff --git a/Tactility/Source/app/selectiondialog/SelectionDialog.cpp b/Tactility/Source/app/selectiondialog/SelectionDialog.cpp index fe1746f87..db28d4dce 100644 --- a/Tactility/Source/app/selectiondialog/SelectionDialog.cpp +++ b/Tactility/Source/app/selectiondialog/SelectionDialog.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include #include @@ -73,7 +73,7 @@ public: lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT); std::string title = getTitleParameter(app.getParameters()); - lvgl::toolbar_create(parent, title); + lvgl_toolbar_create(parent, title.c_str()); auto* list = lv_list_create(parent); lv_obj_set_width(list, LV_PCT(100)); diff --git a/Tactility/Source/app/settings/Settings.cpp b/Tactility/Source/app/settings/Settings.cpp index 68276dfcf..5a278505a 100644 --- a/Tactility/Source/app/settings/Settings.cpp +++ b/Tactility/Source/app/settings/Settings.cpp @@ -2,9 +2,9 @@ #include #include +#include +#include #include -#include -#include #include diff --git a/Tactility/Source/app/setup/Setup.cpp b/Tactility/Source/app/setup/Setup.cpp index 4b5c8cfe0..44ac8b0bf 100644 --- a/Tactility/Source/app/setup/Setup.cpp +++ b/Tactility/Source/app/setup/Setup.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/Tactility/Source/app/systeminfo/SystemInfo.cpp b/Tactility/Source/app/systeminfo/SystemInfo.cpp index 70923e51b..b6b567d84 100644 --- a/Tactility/Source/app/systeminfo/SystemInfo.cpp +++ b/Tactility/Source/app/systeminfo/SystemInfo.cpp @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include #include #ifdef ESP_PLATFORM diff --git a/Tactility/Source/app/timedatesettings/TimeDateSettings.cpp b/Tactility/Source/app/timedatesettings/TimeDateSettings.cpp index 2c52e7d95..ce04d3b53 100644 --- a/Tactility/Source/app/timedatesettings/TimeDateSettings.cpp +++ b/Tactility/Source/app/timedatesettings/TimeDateSettings.cpp @@ -12,8 +12,8 @@ #include +#include #include -#include namespace tt::app::timedatesettings { diff --git a/Tactility/Source/app/timezone/TimeZone.cpp b/Tactility/Source/app/timezone/TimeZone.cpp index 6601df958..01d2e8f95 100644 --- a/Tactility/Source/app/timezone/TimeZone.cpp +++ b/Tactility/Source/app/timezone/TimeZone.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include #include diff --git a/Tactility/Source/app/touchcalibration/TouchCalibration.cpp b/Tactility/Source/app/touchcalibration/TouchCalibration.cpp index 3f9d9cf05..e637c3b9c 100644 --- a/Tactility/Source/app/touchcalibration/TouchCalibration.cpp +++ b/Tactility/Source/app/touchcalibration/TouchCalibration.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include diff --git a/Tactility/Source/app/trackball/TrackballSettings.cpp b/Tactility/Source/app/trackball/TrackballSettings.cpp index 5464b799e..0caa4d039 100644 --- a/Tactility/Source/app/trackball/TrackballSettings.cpp +++ b/Tactility/Source/app/trackball/TrackballSettings.cpp @@ -2,7 +2,7 @@ #include -#include +#include #include #include @@ -117,7 +117,7 @@ public: lv_obj_t* toolbar = lvgl::toolbar_create(parent, app); - switchTrackball = lvgl::toolbar_add_switch_action(toolbar); + switchTrackball = lvgl_toolbar_add_switch_action(toolbar); lv_obj_add_event_cb(switchTrackball, onTrackballSwitch, LV_EVENT_VALUE_CHANGED, this); if (tbSettings.trackballEnabled) lv_obj_add_state(switchTrackball, LV_STATE_CHECKED); diff --git a/Tactility/Source/app/usbsettings/UsbSettings.cpp b/Tactility/Source/app/usbsettings/UsbSettings.cpp index 210379d30..02a607df8 100644 --- a/Tactility/Source/app/usbsettings/UsbSettings.cpp +++ b/Tactility/Source/app/usbsettings/UsbSettings.cpp @@ -5,7 +5,7 @@ #include -#include +#include #define TAG "usb_settings" diff --git a/Tactility/Source/app/webserversettings/WebServerSettings.cpp b/Tactility/Source/app/webserversettings/WebServerSettings.cpp index fa78e7972..030c2a9f6 100644 --- a/Tactility/Source/app/webserversettings/WebServerSettings.cpp +++ b/Tactility/Source/app/webserversettings/WebServerSettings.cpp @@ -10,9 +10,9 @@ #include #include +#include #include #include -#include #include #include @@ -192,7 +192,7 @@ public: lv_obj_t* toolbar = lvgl::toolbar_create(parent, app); // Web Server Enable toggle - switchWebServerEnabled = lvgl::toolbar_add_switch_action(toolbar); + switchWebServerEnabled = lvgl_toolbar_add_switch_action(toolbar); if (wsSettings.webServerEnabled) { lv_obj_add_state(switchWebServerEnabled, LV_STATE_CHECKED); } diff --git a/Tactility/Source/app/wifiapsettings/WifiApSettings.cpp b/Tactility/Source/app/wifiapsettings/WifiApSettings.cpp index 72fb7b80a..052e86b6d 100644 --- a/Tactility/Source/app/wifiapsettings/WifiApSettings.cpp +++ b/Tactility/Source/app/wifiapsettings/WifiApSettings.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include @@ -138,8 +138,8 @@ public: lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT); - auto* toolbar = lvgl::toolbar_create(parent, ssid); - busySpinner = lvgl::toolbar_add_spinner_action(toolbar); + auto* toolbar = lvgl_toolbar_create(parent, ssid.c_str()); + busySpinner = lvgl_toolbar_add_spinner_action(toolbar); auto* wrapper = lv_obj_create(parent); lv_obj_set_width(wrapper, LV_PCT(100)); diff --git a/Tactility/Source/app/wificonnect/View.cpp b/Tactility/Source/app/wificonnect/View.cpp index faefd8e1f..d64117566 100644 --- a/Tactility/Source/app/wificonnect/View.cpp +++ b/Tactility/Source/app/wificonnect/View.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include @@ -98,7 +98,7 @@ void View::createBottomButtons(lv_obj_t* parent) { lv_obj_align(remember_label, LV_ALIGN_CENTER, 0, 0); lv_obj_align_to(remember_label, remember_switch, LV_ALIGN_OUT_RIGHT_MID, 4, 0); - connecting_spinner = tt::lvgl::spinner_create(button_container); + connecting_spinner = lvgl_spinner_create(button_container); lv_obj_align(connecting_spinner, LV_ALIGN_RIGHT_MID, 0, 0); lv_obj_add_flag(connecting_spinner, LV_OBJ_FLAG_HIDDEN); diff --git a/Tactility/Source/app/wifimanage/View.cpp b/Tactility/Source/app/wifimanage/View.cpp index 0fda3a743..5628dd62e 100644 --- a/Tactility/Source/app/wifimanage/View.cpp +++ b/Tactility/Source/app/wifimanage/View.cpp @@ -302,9 +302,9 @@ void View::init(const AppContext& app, lv_obj_t* parent) { lv_obj_t* toolbar = lvgl::toolbar_create(parent, app); - scanning_spinner = lvgl::toolbar_add_spinner_action(toolbar); + scanning_spinner = lvgl_toolbar_add_spinner_action(toolbar); - enable_switch = lvgl::toolbar_add_switch_action(toolbar); + enable_switch = lvgl_toolbar_add_switch_action(toolbar); lv_obj_add_event_cb(enable_switch, onEnableSwitchChanged, LV_EVENT_VALUE_CHANGED, bindings); // Networks diff --git a/Tactility/Source/app/wifimanage/WifiManage.cpp b/Tactility/Source/app/wifimanage/WifiManage.cpp index 1abc808c0..0554b7344 100644 --- a/Tactility/Source/app/wifimanage/WifiManage.cpp +++ b/Tactility/Source/app/wifimanage/WifiManage.cpp @@ -8,8 +8,8 @@ #include #include +#include #include -#include namespace tt::app::wifimanage { diff --git a/Tactility/Source/lvgl/Statusbar.cpp b/Tactility/Source/lvgl/Statusbar.cpp index d1a0aba4f..febd3b0f7 100644 --- a/Tactility/Source/lvgl/Statusbar.cpp +++ b/Tactility/Source/lvgl/Statusbar.cpp @@ -10,10 +10,10 @@ #include #include +#include +#include #include #include -#include -#include #include #include diff --git a/Tactility/Source/lvgl/Toolbar.cpp b/Tactility/Source/lvgl/Toolbar.cpp index e0501eaa7..0bcf7709b 100644 --- a/Tactility/Source/lvgl/Toolbar.cpp +++ b/Tactility/Source/lvgl/Toolbar.cpp @@ -1,259 +1,10 @@ -#define LV_USE_PRIVATE_API 1 // For actual lv_obj_t declaration - -#include #include - -#include "tactility/drivers/pointer.h" - -#include -#include - -#include -#include -#include +#include namespace tt::lvgl { -static uint32_t getToolbarHeight(UiDensity uiDensity) { - if (uiDensity == LVGL_UI_DENSITY_COMPACT) { - return lvgl_get_text_font_height(FONT_SIZE_DEFAULT) * 1.4f; - } else { - return lvgl_get_text_font_height(FONT_SIZE_LARGE) * 2.2f; - } -} - -static const _lv_font_t* getToolbarFont(UiDensity uiDensity) { - if (uiDensity == LVGL_UI_DENSITY_COMPACT) { - return lvgl_get_text_font(FONT_SIZE_DEFAULT); - } else { - return lvgl_get_text_font(FONT_SIZE_LARGE); - } -} - -static uint32_t getActionIconPadding(UiDensity uiDensity) { - auto toolbar_height = getToolbarHeight(uiDensity); - // Minimal 8 pixels total padding for selection/animation (4+4 pixels) - return (uiDensity != LVGL_UI_DENSITY_COMPACT) ? (uint32_t)(toolbar_height * 0.2f) : 8; -} - -/** - * Helps with button expansion and also with vertical alignment of content, - * as the parent flex doesn't allow for vertical alignment - */ -static lv_obj_t* create_action_wrapper(lv_obj_t* parent, UiDensity ui_density) { - auto* wrapper = lv_obj_create(parent); - auto toolbar_height = getToolbarHeight(ui_density); - lv_obj_set_size(wrapper, LV_SIZE_CONTENT, toolbar_height); - - auto icon_padding = getActionIconPadding(ui_density); - auto icon_padding_half = icon_padding / 2; - - lv_obj_set_style_pad_all(wrapper, icon_padding_half, LV_STATE_DEFAULT); // For selection and touch animation - lv_obj_set_style_bg_opa(wrapper, 0, LV_STATE_DEFAULT); - lv_obj_set_style_border_width(wrapper, 0, LV_STATE_DEFAULT); - lv_obj_set_style_border_opa(wrapper, 0, LV_STATE_DEFAULT); - - return wrapper; -} - -typedef struct { - lv_obj_t obj; - lv_obj_t* title_label; - lv_obj_t* close_button; - lv_obj_t* close_button_image; - lv_obj_t* action_container; - uint8_t action_count; -} Toolbar; - -static void toolbar_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj); - -static lv_obj_class_t toolbar_class = { - .base_class = &lv_obj_class, - .constructor_cb = &toolbar_constructor, - .destructor_cb = nullptr, - .event_cb = nullptr, - .user_data = nullptr, - .name = nullptr, - .width_def = LV_PCT(100), - .height_def = 0, - .editable = false, - .group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE, - .instance_size = sizeof(Toolbar), - .theme_inheritable = false -}; - -static void stop_app(lv_event_t* event) { - app::stop(); -} - -static void toolbar_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj) { - LV_UNUSED(class_p); - lv_obj_remove_flag(obj, LV_OBJ_FLAG_SCROLLABLE); - lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS); -} - -lv_obj_t* toolbar_create(lv_obj_t* parent, const std::string& title) { - auto ui_density = lvgl_get_ui_density(); - auto toolbar_height = getToolbarHeight(ui_density); - toolbar_class.height_def = toolbar_height; - lv_obj_t* obj = lv_obj_class_create_obj(&toolbar_class, parent); - lv_obj_class_init_obj(obj); - lv_obj_set_height(obj, toolbar_height); - - auto* toolbar = reinterpret_cast(obj); - lv_obj_set_width(obj, LV_PCT(100)); - lv_obj_set_style_pad_all(obj, 0, LV_STATE_DEFAULT); - lv_obj_set_style_pad_column(obj, 0, LV_STATE_DEFAULT); - - lv_obj_center(obj); - lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_ROW); - - auto icon_padding = getActionIconPadding(ui_density); - - auto* close_button_wrapper = create_action_wrapper(obj, ui_density); - - toolbar->close_button = lv_button_create(close_button_wrapper); - if (ui_density == LVGL_UI_DENSITY_COMPACT) { - lv_obj_set_style_bg_opa(toolbar->close_button, LV_OPA_TRANSP, LV_STATE_DEFAULT); - } - - lv_obj_set_size(toolbar->close_button, toolbar_height - icon_padding, toolbar_height - icon_padding); - - lv_obj_set_style_pad_all(toolbar->close_button, 0, LV_STATE_DEFAULT); - lv_obj_align(toolbar->close_button, LV_ALIGN_CENTER, 0, 0); - toolbar->close_button_image = lv_image_create(toolbar->close_button); - lv_obj_align(toolbar->close_button_image, LV_ALIGN_CENTER, 0, 0); - - auto* title_wrapper = lv_obj_create(obj); - uint32_t title_left_padding = (ui_density != LVGL_UI_DENSITY_COMPACT) ? icon_padding : 2; - uint32_t title_right_padding = (ui_density != LVGL_UI_DENSITY_COMPACT) ? (icon_padding / 2) : 2; - lv_obj_set_size(title_wrapper, LV_SIZE_CONTENT, LV_PCT(100)); - lv_obj_set_style_bg_opa(title_wrapper, 0, LV_STATE_DEFAULT); - lv_obj_set_style_pad_left(title_wrapper, title_left_padding, LV_STATE_DEFAULT); - lv_obj_set_style_pad_right(title_wrapper, title_right_padding, LV_STATE_DEFAULT); - lv_obj_set_style_pad_ver(title_wrapper, 0, LV_STATE_DEFAULT); - lv_obj_set_style_border_width(title_wrapper, 0, LV_STATE_DEFAULT); - lv_obj_set_flex_grow(title_wrapper, 1); - - toolbar->title_label = lv_label_create(title_wrapper); - lv_obj_set_style_text_font(toolbar->title_label, getToolbarFont(ui_density), LV_STATE_DEFAULT); - lv_label_set_text(toolbar->title_label, title.c_str()); - lv_label_set_long_mode(toolbar->title_label, LV_LABEL_LONG_MODE_SCROLL); - lv_obj_set_style_text_align(toolbar->title_label, LV_TEXT_ALIGN_LEFT, LV_STATE_DEFAULT); - lv_obj_align(toolbar->title_label, LV_ALIGN_LEFT_MID, 0, 0); - lv_obj_set_width(toolbar->title_label, LV_PCT(100)); - - toolbar->action_container = lv_obj_create(obj); - lv_obj_set_width(toolbar->action_container, LV_SIZE_CONTENT); - lv_obj_set_flex_flow(toolbar->action_container, LV_FLEX_FLOW_ROW); - lv_obj_set_style_pad_all(toolbar->action_container, 0, LV_STATE_DEFAULT); - lv_obj_set_style_pad_column(toolbar->action_container, 0, LV_STATE_DEFAULT); - lv_obj_set_style_border_width(toolbar->action_container, 0, LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(toolbar->action_container, 0, LV_STATE_DEFAULT); - - toolbar_set_nav_action(obj, LV_SYMBOL_CLOSE, &stop_app, nullptr); - - // If we don't have a touch device, we assume there's some other kind of input like a keyboard, an encoder or button control - // In that scenario we want to automatically have the close button selected so the user doesn't have to press the widget selection - // an extra time for every screen. - if (!device_has_active_by_type(&POINTER_TYPE)) { - lv_group_focus_obj(toolbar->close_button); - } - - return obj; -} - lv_obj_t* toolbar_create(lv_obj_t* parent, const app::AppContext& app) { - return toolbar_create(parent, app.getManifest().appName); -} - -void toolbar_set_title(lv_obj_t* obj, const std::string& title) { - auto* toolbar = reinterpret_cast(obj); - lv_label_set_text(toolbar->title_label, title.c_str()); -} - -void toolbar_set_nav_action(lv_obj_t* obj, const char* icon, lv_event_cb_t callback, void* user_data) { - auto* toolbar = reinterpret_cast(obj); - lv_obj_add_event_cb(toolbar->close_button, callback, LV_EVENT_SHORT_CLICKED, user_data); - lv_image_set_src(toolbar->close_button_image, icon); // e.g. LV_SYMBOL_CLOSE -} - -lv_obj_t* toolbar_add_button_action(lv_obj_t* obj, const char* imageOrButton, bool isImage, lv_event_cb_t callback, void* user_data) { - auto* toolbar = reinterpret_cast(obj); - check(toolbar->action_count < TOOLBAR_ACTION_LIMIT, "max actions reached"); - toolbar->action_count++; - - auto ui_density = lvgl_get_ui_density(); - auto toolbar_height = getToolbarHeight(ui_density); - - auto* wrapper = create_action_wrapper(toolbar->action_container, ui_density); - - auto padding = getActionIconPadding(ui_density); - - lv_obj_t* action_button = lv_button_create(wrapper); - lv_obj_set_size(action_button, toolbar_height - padding, toolbar_height - padding); - lv_obj_set_style_pad_all(action_button, 0, LV_STATE_DEFAULT); - lv_obj_align(action_button, LV_ALIGN_CENTER, 0, 0); - if (ui_density == LVGL_UI_DENSITY_COMPACT) { - lv_obj_set_style_bg_opa(action_button, LV_OPA_TRANSP, LV_STATE_DEFAULT); - } - - lv_obj_add_event_cb(action_button, callback, LV_EVENT_SHORT_CLICKED, user_data); - lv_obj_t* button_content; - if (isImage) { - button_content = lv_image_create(action_button); - lv_image_set_src(button_content, imageOrButton); - } else { - button_content = lv_label_create(action_button); - lv_label_set_text(button_content, imageOrButton); - } - lv_obj_align(button_content, LV_ALIGN_CENTER, 0, 0); - - return action_button; -} - -lv_obj_t* toolbar_add_image_button_action(lv_obj_t* obj, const char* imagePath, lv_event_cb_t callback, void* user_data) { - return toolbar_add_button_action(obj, imagePath, true, callback, user_data); -} - -lv_obj_t* toolbar_add_text_button_action(lv_obj_t* obj, const char* text, lv_event_cb_t callback, void* user_data) { - return toolbar_add_button_action(obj, text, false, callback, user_data); -} - -lv_obj_t* toolbar_add_switch_action(lv_obj_t* obj) { - auto* toolbar = reinterpret_cast(obj); - - auto ui_density = lvgl_get_ui_density(); - auto* wrapper = create_action_wrapper(toolbar->action_container, ui_density); - lv_obj_set_style_pad_hor(wrapper, 4, LV_STATE_DEFAULT); - - lv_obj_t* widget = lv_switch_create(wrapper); - lv_obj_set_align(widget, LV_ALIGN_CENTER); - - return widget; -} - -lv_obj_t* toolbar_add_spinner_action(lv_obj_t* obj) { - auto* toolbar = reinterpret_cast(obj); - - auto ui_density = lvgl_get_ui_density(); - auto* wrapper = create_action_wrapper(toolbar->action_container, ui_density); - - auto* spinner = spinner_create(wrapper); - lv_obj_set_align(spinner, LV_ALIGN_CENTER); - - if (lv_display_get_color_format(lv_obj_get_display(obj)) == LV_COLOR_FORMAT_L8) { - lv_obj_set_style_image_recolor(spinner, lv_theme_get_color_secondary(obj), LV_STATE_DEFAULT); - lv_obj_set_style_image_recolor_opa(spinner, LV_OPA_COVER, LV_STATE_DEFAULT); - } - - return spinner; -} - -void toolbar_clear_actions(lv_obj_t* obj) { - auto* toolbar = reinterpret_cast(obj); - lv_obj_clean(toolbar->action_container); - toolbar->action_count = 0; + return lvgl_toolbar_create(parent, app.getManifest().appName.c_str()); } } // namespace diff --git a/Tactility/Source/service/memorychecker/MemoryCheckerService.cpp b/Tactility/Source/service/memorychecker/MemoryCheckerService.cpp index 3ed14fa7f..738bbf556 100644 --- a/Tactility/Source/service/memorychecker/MemoryCheckerService.cpp +++ b/Tactility/Source/service/memorychecker/MemoryCheckerService.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include namespace tt::service::memorychecker { diff --git a/Tactility/Source/service/statusbar/Statusbar.cpp b/Tactility/Source/service/statusbar/Statusbar.cpp index 3cf365000..72ee15d17 100644 --- a/Tactility/Source/service/statusbar/Statusbar.cpp +++ b/Tactility/Source/service/statusbar/Statusbar.cpp @@ -21,8 +21,8 @@ #include +#include #include -#include #include diff --git a/Tactility/Source/service/webserver/WebServerService.cpp b/Tactility/Source/service/webserver/WebServerService.cpp index fd15dd8d2..a5ddfc877 100644 --- a/Tactility/Source/service/webserver/WebServerService.cpp +++ b/Tactility/Source/service/webserver/WebServerService.cpp @@ -30,7 +30,7 @@ #include #endif -#include +#include #include #include diff --git a/TactilityC/Include/tt_lock.h b/TactilityC/Include/tt_lock.h deleted file mode 100644 index 06afe3bb7..000000000 --- a/TactilityC/Include/tt_lock.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** A handle that represents a lock instance. A lock could be a Mutex or similar construct */ -typedef void* LockHandle; - -typedef enum { - MutexTypeNormal, - MutexTypeRecursive -} TtMutexType; - -/** - * Allocate a lock for a file or folder. - * Locking is required before reading files for filesystems that are on a shared bus (e.g. SPI SD card sharing the bus with the display) - * @param path the path to create the lock for - * @return the allocated lock handle - */ -LockHandle tt_lock_alloc_for_path(const char* path); - -/** - * Attempt to lock the lock. - * @param[in] handle the handle that represents the mutex instance - * @param[in] timeout the maximum amount of ticks to wait when trying to lock - * @return true when the lock was acquired - */ -bool tt_lock_acquire(LockHandle handle, TickType_t timeout); - -/** - * Attempt to unlock the lock. - * @param[in] handle the handle that represents the mutex instance - */ -void tt_lock_release(LockHandle handle); - -/** Free the memory for this lock - * This does not auto-release the lock. - * @param[in] handle the handle that represents the mutex instance - */ -void tt_lock_free(LockHandle handle); - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/TactilityC/Include/tt_lvgl_keyboard.h b/TactilityC/Include/tt_lvgl_keyboard.h deleted file mode 100644 index 78c162c00..000000000 --- a/TactilityC/Include/tt_lvgl_keyboard.h +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Show the on-screen keyboard. - * @param[in] textarea the textarea to focus the input for - */ -void tt_lvgl_software_keyboard_show(lv_obj_t* textarea); - -/** - * Hide the on-screen keyboard. - * Has no effect when the keyboard is not visible. - */ -void tt_lvgl_software_keyboard_hide(); - -/** - * The on-screen keyboard is only shown when both of these conditions are true: - * - there is no hardware keyboard - * - TT_CONFIG_FORCE_ONSCREEN_KEYBOARD is set to true in tactility_config.h - * @return if we should show a on-screen keyboard for text input inside our apps - */ -bool tt_lvgl_software_keyboard_is_enabled(); - -/** - * Activate the keypad for a widget group. - * @param group - */ -void tt_lvgl_software_keyboard_activate(lv_group_t* group); - -/** - * Deactivate the keypad for the current widget group (if any). - * You don't have to call this after calling _activate() because widget - * cleanup automatically removes itself from the group it belongs to. - */ -void tt_lvgl_software_keyboard_deactivate(); - -/** - * @return true if LVGL is configured with a keypad - */ -bool tt_lvgl_hardware_keyboard_is_available(); - -/** - * Set the keypad. - * @param device the keypad device - */ -void tt_lvgl_hardware_keyboard_set_indev(lv_indev_t* device); - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/TactilityC/Include/tt_lvgl_spinner.h b/TactilityC/Include/tt_lvgl_spinner.h deleted file mode 100644 index 9136d0cc7..000000000 --- a/TactilityC/Include/tt_lvgl_spinner.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** Create a spinner widget. */ -lv_obj_t* tt_lvgl_spinner_create(lv_obj_t* parent); - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/TactilityC/Include/tt_lvgl_toolbar.h b/TactilityC/Include/tt_lvgl_toolbar.h deleted file mode 100644 index b681fcd19..000000000 --- a/TactilityC/Include/tt_lvgl_toolbar.h +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once - -#include "tt_app.h" -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** Create a toolbar widget that shows the app name as title */ -lv_obj_t* tt_lvgl_toolbar_create_for_app(lv_obj_t* parent, AppHandle context); - -/** Create a toolbar widget with the provided title*/ -lv_obj_t* tt_lvgl_toolbar_create(lv_obj_t* parent, const char* title); - -/** Sets the toolbar title */ -void tt_lvgl_toolbar_set_title(lv_obj_t* obj, const char* title); - -/** Sets the navigation action of the toolbar (button on the top-left) - * @param[in] obj the toolbar instance - * @param[in] icon the icon to set on the button - * @param[in] callback the callback for the click action of the button - * @param[in] callbackEventUserData the user data that is attached to the callback event object - */ -void tt_lvgl_toolbar_set_nav_action(lv_obj_t* obj, const char* icon, lv_event_cb_t callback, void* callbackEventUserData); - -/** - * Create and add an action button with an image to the toolbar (aligned to the right of the toolbar) - * @param[in] obj the toolbar instance - * @param[in] imagePath the path to an image file to shown on the button - * @param[in] callback the callback for the click action of the button - * @param[in] callbackUserData the user data that is passed to the callback - * @return an lv_button instance - - */ -lv_obj_t* tt_lvgl_toolbar_add_image_button_action(lv_obj_t* obj, const char* imagePath, lv_event_cb_t callback, void* callbackUserData); - -/** - * Create and add an action button with text to the toolbar (aligned to the right of the toolbar) - * @param[in] obj the toolbar instance - * @param[in] text the button text - * @param[in] callback the callback for the click action of the button - * @param[in] callbackUserData the user data that is passed to the callback - * @return an lv_button instance - - */ -lv_obj_t* tt_lvgl_toolbar_add_text_button_action(lv_obj_t* obj, const char* text, lv_event_cb_t callback, void* callbackUserData); - -/** - * Create and add a switch to the toolbar actions. - * @param[in] obj the toolbar instance - * @return an instance created by lv_switch_create() - */ -lv_obj_t* tt_lvgl_toolbar_add_switch_action(lv_obj_t* obj); - -/** - * Create and add a spinner to the toolbar actions. - * @param[in] obj the toolbar instance - * @return an instance created by Tactility's spinner_create() - */ -lv_obj_t* tt_lvgl_toolbar_add_spinner_action(lv_obj_t* obj); - - -/** - * Remove all actions from the toolbar - * @param[in] obj the toolbar instance - */ -void tt_lvgl_toolbar_clear_actions(lv_obj_t* obj); - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/TactilityC/Private/tt_lock_private.h b/TactilityC/Private/tt_lock_private.h deleted file mode 100644 index 4d0489c2c..000000000 --- a/TactilityC/Private/tt_lock_private.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include -#include - -struct LockHolder { - std::shared_ptr lock; -}; diff --git a/TactilityC/Source/tt_init.cpp b/TactilityC/Source/tt_init.cpp index 24326454a..9ba61b748 100644 --- a/TactilityC/Source/tt_init.cpp +++ b/TactilityC/Source/tt_init.cpp @@ -5,10 +5,6 @@ #include "tt_app_fileselection.h" #include "tt_app_selectiondialog.h" #include "tt_bundle.h" -#include -#include "tt_lvgl_keyboard.h" -#include "tt_lvgl_spinner.h" -#include "tt_lvgl_toolbar.h" #include "tt_preferences.h" #include "tt_time.h" @@ -281,10 +277,6 @@ const esp_elfsym main_symbols[] { ESP_ELFSYM_EXPORT(tt_app_get_user_data_child_path), ESP_ELFSYM_EXPORT(tt_app_get_assets_path), ESP_ELFSYM_EXPORT(tt_app_get_assets_child_path), - ESP_ELFSYM_EXPORT(tt_lock_alloc_for_path), - ESP_ELFSYM_EXPORT(tt_lock_acquire), - ESP_ELFSYM_EXPORT(tt_lock_release), - ESP_ELFSYM_EXPORT(tt_lock_free), ESP_ELFSYM_EXPORT(tt_bundle_alloc), ESP_ELFSYM_EXPORT(tt_bundle_free), ESP_ELFSYM_EXPORT(tt_bundle_opt_bool), @@ -293,22 +285,6 @@ const esp_elfsym main_symbols[] { ESP_ELFSYM_EXPORT(tt_bundle_put_bool), ESP_ELFSYM_EXPORT(tt_bundle_put_int32), ESP_ELFSYM_EXPORT(tt_bundle_put_string), - ESP_ELFSYM_EXPORT(tt_lvgl_software_keyboard_show), - ESP_ELFSYM_EXPORT(tt_lvgl_software_keyboard_hide), - ESP_ELFSYM_EXPORT(tt_lvgl_software_keyboard_is_enabled), - ESP_ELFSYM_EXPORT(tt_lvgl_software_keyboard_activate), - ESP_ELFSYM_EXPORT(tt_lvgl_software_keyboard_deactivate), - ESP_ELFSYM_EXPORT(tt_lvgl_hardware_keyboard_is_available), - ESP_ELFSYM_EXPORT(tt_lvgl_hardware_keyboard_set_indev), - ESP_ELFSYM_EXPORT(tt_lvgl_toolbar_create), - ESP_ELFSYM_EXPORT(tt_lvgl_toolbar_create_for_app), - ESP_ELFSYM_EXPORT(tt_lvgl_toolbar_set_title), - ESP_ELFSYM_EXPORT(tt_lvgl_toolbar_set_nav_action), - ESP_ELFSYM_EXPORT(tt_lvgl_toolbar_add_image_button_action), - ESP_ELFSYM_EXPORT(tt_lvgl_toolbar_add_text_button_action), - ESP_ELFSYM_EXPORT(tt_lvgl_toolbar_add_switch_action), - ESP_ELFSYM_EXPORT(tt_lvgl_toolbar_add_spinner_action), - ESP_ELFSYM_EXPORT(tt_lvgl_toolbar_clear_actions), ESP_ELFSYM_EXPORT(tt_preferences_alloc), ESP_ELFSYM_EXPORT(tt_preferences_free), ESP_ELFSYM_EXPORT(tt_preferences_opt_bool), @@ -322,8 +298,6 @@ const esp_elfsym main_symbols[] { ESP_ELFSYM_EXPORT(tt_timezone_get_code), ESP_ELFSYM_EXPORT(tt_timezone_is_format_24_hour), ESP_ELFSYM_EXPORT(tt_timezone_set_format_24_hour), - // tt::lvgl - ESP_ELFSYM_EXPORT(tt_lvgl_spinner_create), // stdio.h ESP_ELFSYM_EXPORT(rename), diff --git a/TactilityC/Source/tt_lock.cpp b/TactilityC/Source/tt_lock.cpp deleted file mode 100644 index 2bde94b91..000000000 --- a/TactilityC/Source/tt_lock.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include -#include -#include - -#define HANDLE_AS_LOCK(handle) (static_cast(handle)->lock) - -extern "C" { - -LockHandle tt_lock_alloc_for_path(const char* path) { - const auto lock = tt::file::getLock(path); - return new LockHolder(lock); -} - -bool tt_lock_acquire(LockHandle handle, TickType_t timeout) { - return HANDLE_AS_LOCK(handle)->lock(timeout); -} - -void tt_lock_release(LockHandle handle) { - HANDLE_AS_LOCK(handle)->unlock(); -} - -void tt_lock_free(LockHandle handle) { - const auto holder = static_cast(handle); - delete holder; -} - -} \ No newline at end of file diff --git a/TactilityC/Source/tt_lvgl_keyboard.cpp b/TactilityC/Source/tt_lvgl_keyboard.cpp deleted file mode 100644 index db9e3cb21..000000000 --- a/TactilityC/Source/tt_lvgl_keyboard.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "Tactility/lvgl/Keyboard.h" - -extern "C" { - -void tt_lvgl_software_keyboard_show(lv_obj_t* textarea) { - tt::lvgl::software_keyboard_show(textarea); -} - -void tt_lvgl_software_keyboard_hide() { - tt::lvgl::software_keyboard_hide(); -} - -bool tt_lvgl_software_keyboard_is_enabled() { - return tt::lvgl::software_keyboard_is_enabled(); -} - -void tt_lvgl_software_keyboard_activate(lv_group_t* group) { - tt::lvgl::software_keyboard_activate(group); -} - -void tt_lvgl_software_keyboard_deactivate() { - tt::lvgl::software_keyboard_deactivate(); -} - -bool tt_lvgl_hardware_keyboard_is_available() { - return tt::lvgl::hardware_keyboard_is_available(); -} - -void tt_lvgl_hardware_keyboard_set_indev(lv_indev_t* device) { - tt::lvgl::hardware_keyboard_set_indev(device); -} - -} diff --git a/TactilityC/Source/tt_lvgl_spinner.cpp b/TactilityC/Source/tt_lvgl_spinner.cpp deleted file mode 100644 index 8726d7fdd..000000000 --- a/TactilityC/Source/tt_lvgl_spinner.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "tt_lvgl_spinner.h" -#include - -extern "C" { - -lv_obj_t* tt_lvgl_spinner_create(lv_obj_t* parent) { - return tt::lvgl::spinner_create(parent); -} - -} diff --git a/TactilityC/Source/tt_lvgl_toolbar.cpp b/TactilityC/Source/tt_lvgl_toolbar.cpp deleted file mode 100644 index 36c3a6789..000000000 --- a/TactilityC/Source/tt_lvgl_toolbar.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "tt_lvgl_toolbar.h" -#include - -extern "C" { - -lv_obj_t* tt_lvgl_toolbar_create(lv_obj_t* parent, const char* title) { - return tt::lvgl::toolbar_create(parent, title); -} - -lv_obj_t* tt_lvgl_toolbar_create_for_app(lv_obj_t* parent, AppHandle context) { - return tt::lvgl::toolbar_create(parent, *(tt::app::AppContext*)context); -} - -void tt_lvgl_toolbar_set_title(lv_obj_t* obj, const char* title) { - tt::lvgl::toolbar_set_title(obj, title); -} - -void tt_lvgl_toolbar_set_nav_action(lv_obj_t* obj, const char* icon, lv_event_cb_t callback, void* callbackEventUserData) { - tt::lvgl::toolbar_set_nav_action(obj, icon, callback, callbackEventUserData); -} - -lv_obj_t* tt_lvgl_toolbar_add_image_button_action(lv_obj_t* obj, const char* imagePath, lv_event_cb_t callback, void* callbackUserData) { - return tt::lvgl::toolbar_add_image_button_action(obj, imagePath, callback, callbackUserData); -} - -lv_obj_t* tt_lvgl_toolbar_add_text_button_action(lv_obj_t* obj, const char* text, lv_event_cb_t callback, void* callbackUserData) { - return tt::lvgl::toolbar_add_text_button_action(obj, text, callback, callbackUserData); -} - -lv_obj_t* tt_lvgl_toolbar_add_switch_action(lv_obj_t* obj) { - return tt::lvgl::toolbar_add_switch_action(obj); -} - -lv_obj_t* tt_lvgl_toolbar_add_spinner_action(lv_obj_t* obj) { - return tt::lvgl::toolbar_add_spinner_action(obj); -} - -void tt_lvgl_toolbar_clear_actions(lv_obj_t* obj) { - tt::lvgl::toolbar_clear_actions(obj); -} - -} diff --git a/Tests/SdkIntegration/main/Source/main.c b/Tests/SdkIntegration/main/Source/main.c index 9762b833c..5b0bcfb70 100644 --- a/Tests/SdkIntegration/main/Source/main.c +++ b/Tests/SdkIntegration/main/Source/main.c @@ -1,5 +1,7 @@ #include -#include + +#include +#include #include #include @@ -22,8 +24,6 @@ #include #include -#include - #include #include #include @@ -32,7 +32,7 @@ #include static void onShowApp(AppHandle app, void* data, lv_obj_t* parent) { - lv_obj_t* toolbar = tt_lvgl_toolbar_create_for_app(parent, app); + lv_obj_t* toolbar = lvgl_toolbar_create(parent, "Title"); lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0); lv_obj_t* label = lv_label_create(parent);