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_\*
This commit is contained in:
Ken Van Hoeylandt 2026-07-26 15:58:35 +02:00 committed by GitHub
parent cd2d9d6158
commit b98a813f3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
84 changed files with 586 additions and 831 deletions

View File

@ -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

View File

@ -0,0 +1,41 @@
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <lvgl.h>
#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

View File

@ -0,0 +1,19 @@
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <lvgl.h>
#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

View File

@ -0,0 +1,86 @@
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <lvgl.h>
#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

View File

@ -1,12 +1,12 @@
#include <lvgl/devices/display.h>
#include <lvgl/devices/keyboard.h>
#include <lvgl/devices/pointer.h>
#include <lvgl/lvgl.h>
#include <tactility/device.h>
#include <tactility/drivers/display.h>
#include <tactility/drivers/keyboard.h>
#include <tactility/drivers/pointer.h>
#include <tactility/log.h>
#include <lvgl/lvgl_display.h>
#include <lvgl/lvgl_keyboard.h>
#include <lvgl/lvgl.h>
#include <lvgl/lvgl_pointer.h>
#include <lvgl.h>
@ -115,5 +115,5 @@ void lvgl_devices_detach() {
display = lv_disp_get_next(NULL);
}
lvgl_lock();
lvgl_unlock();
}

View File

@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
#include <lvgl/lvgl_display.h>
#include <lvgl/devices/display.h>
#include <lvgl/lvgl_ppa.h>
#include <lvgl/ppa.h>
#include <tactility/device.h>
#include <tactility/driver.h>

View File

@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
#include <lvgl/lvgl_keyboard.h>
#include <lvgl/devices/keyboard.h>
#include <tactility/drivers/keyboard.h>

View File

@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
#include <lvgl/lvgl_pointer.h>
#include <lvgl/devices/pointer.h>
#include <tactility/drivers/pointer.h>

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
#include <lvgl.h>
#include <lvgl/lvgl_fonts.h>
#include <lvgl/fonts.h>
#include <tactility/check.h>
// The preprocessor definitions that are used below are defined in the CMakeLists.txt from this module.

View File

@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
#include <lvgl/lvgl_ppa.h>
#include <lvgl/ppa.h>
#include <tactility/log.h>

View File

@ -1,7 +1,15 @@
// SPDX-License-Identifier: Apache-2.0
#include <lvgl/fonts.h>
#include <lvgl/lvgl.h>
#include <lvgl/module.h>
#include <lvgl/lvgl_fonts.h>
#include <lvgl/devices/display.h>
#include <lvgl/devices/keyboard.h>
#include <lvgl/devices/pointer.h>
#include <lvgl/widgets/sliderbox.h>
#include <lvgl/widgets/spinner.h>
#include <lvgl/widgets/toolbar.h>
#include <tactility/module.h>
@ -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),

View File

@ -1,10 +1,8 @@
// SPDX-License-Identifier: Apache-2.0
#define LV_USE_PRIVATE_API 1 // For actual lv_obj_t declaration
#include <Tactility/lvgl/SliderBox.h>
#include <lvgl/lvgl_fonts.h>
namespace tt::lvgl {
#include <lvgl/widgets/sliderbox.h>
#include <lvgl/fonts.h>
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<SliderBox*>(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<SliderBox*>(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

View File

@ -1,15 +1,14 @@
// SPDX-License-Identifier: Apache-2.0
#define LV_USE_PRIVATE_API 1 // For actual lv_obj_t declaration
#include <Tactility/Assets.h>
#include <Tactility/CoreDefines.h>
#include <lvgl/widgets/spinner.h>
#include <lvgl.h>
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);
}
}

View File

@ -0,0 +1,260 @@
// SPDX-License-Identifier: Apache-2.0
#define LV_USE_PRIVATE_API 1 // For actual lv_obj_t declaration
#include <lvgl/widgets/toolbar.h>
#include <lvgl/widgets/spinner.h>
#include <lvgl/fonts.h>
#include <lvgl/lvgl.h>
#include <tactility/check.h>
#include <tactility/drivers/pointer.h>
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<Toolbar*>(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<Toolbar*>(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<Toolbar*>(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<Toolbar*>(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<Toolbar*>(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<Toolbar*>(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<Toolbar*>(obj);
lv_obj_clean(toolbar->action_container);
toolbar->action_count = 0;
}

View File

@ -1,36 +0,0 @@
#pragma once
#include <lvgl.h>
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

View File

@ -1,12 +0,0 @@
#include <lvgl.h>
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);
}

View File

@ -2,67 +2,11 @@
#include "../app/AppContext.h"
#include <lvgl.h>
#include <lvgl/widgets/toolbar.h>
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

View File

@ -25,6 +25,7 @@
#include <crypt/module.h>
#include <lvgl/module.h>
#include <lvgl/widgets/toolbar.h>
#include <tactility/concurrent/thread.h>
#include <tactility/drivers/audio_stream.h>
#include <tactility/drivers/display.h>
@ -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);

View File

@ -4,9 +4,9 @@
#include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h>
#include <lvgl/icons/shared.h>
#include <tactility/drivers/uart_controller.h>
#include <tactility/log.h>
#include <lvgl/lvgl_icon_shared.h>
#include <gps/gps.h>
#include <gps/gps_settings.h>

View File

@ -1,6 +1,6 @@
#include "Tactility/app/alertdialog/AlertDialog.h"
#include "Tactility/lvgl/Toolbar.h"
#include <lvgl/widgets/toolbar.h>
#include "Tactility/service/loader/Loader.h"
#include <Tactility/StringUtils.h>
@ -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);

View File

@ -6,7 +6,7 @@
#include <Tactility/app/alertdialog/AlertDialog.h>
#include <tactility/check.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h>
#include <lvgl/widgets/toolbar.h>
#include <lvgl.h>
#include <format>
@ -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));

View File

@ -3,18 +3,18 @@
#include <Tactility/app/apphubdetails/AppHubDetailsApp.h>
#include <Tactility/file/File.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Spinner.h>
#include <lvgl/widgets/spinner.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/network/Http.h>
#include <Tactility/Paths.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/service/wifi/Wifi.h>
#include <lvgl.h>
#include <tactility/log.h>
#include <lvgl/lvgl_icon_shared.h>
#include <lvgl/icons/shared.h>
#include <algorithm>
#include <format>
#include <lvgl.h>
#include <tactility/log.h>
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);

View File

@ -4,7 +4,7 @@
#include <Tactility/app/AppRegistration.h>
#include <Tactility/file/File.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <lvgl/widgets/toolbar.h>
#include <Tactility/network/Http.h>
#include <Tactility/Paths.h>
#include <Tactility/service/loader/Loader.h>
@ -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);

View File

@ -5,8 +5,8 @@
#include <lvgl.h>
#include <algorithm>
#include <lvgl/lvgl_fonts.h>
#include <lvgl/lvgl_icon_shared.h>
#include <lvgl/icons/shared.h>
#include <lvgl/fonts.h>
namespace tt::app::applist {

View File

@ -1,10 +1,10 @@
#include <lvgl/lvgl_fonts.h>
#include <lvgl/lvgl_icon_shared.h>
#include <lvgl/icons/shared.h>
#include <lvgl/fonts.h>
#include <Tactility/app/AppRegistration.h>
#include <Tactility/app/appdetails/AppDetails.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/loader/Loader.h>
#include <lvgl/widgets/toolbar.h>
#include <lvgl.h>
#include <algorithm>
@ -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);

View File

@ -1,13 +1,13 @@
#include <Tactility/Tactility.h>
#include <lvgl/lvgl_icon_shared.h>
#include <lvgl/icons/shared.h>
#include <Tactility/PubSub.h>
#include <Tactility/app/App.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/SliderBox.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/audio/Audio.h>
#include <lvgl/widgets/sliderbox.h>
#include <lvgl.h>
#include <lvgl/lvgl.h>
@ -52,13 +52,13 @@ class AudioSettingsApp final : public App {
static void onInputVolumeSlider(lv_event_t* event) {
auto* sliderBox = static_cast<lv_obj_t*>(lv_event_get_target(event));
float percent = static_cast<float>(lvgl::sliderbox_get_value(sliderBox));
float percent = static_cast<float>(lvgl_sliderbox_get_value(sliderBox));
service::audio::setInputVolume(percent);
}
static void onOutputVolumeSlider(lv_event_t* event) {
auto* sliderBox = static_cast<lv_obj_t*>(lv_event_get_target(event));
float percent = static_cast<float>(lvgl::sliderbox_get_value(sliderBox));
float percent = static_cast<float>(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<int32_t>(service::audio::getInputVolume()), LV_ANIM_OFF);
lvgl_sliderbox_set_value(inputVolumeSlider, static_cast<int32_t>(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<int32_t>(service::audio::getOutputVolume()), LV_ANIM_OFF);
lvgl_sliderbox_set_value(outputVolumeSlider, static_cast<int32_t>(service::audio::getOutputVolume()), LV_ANIM_OFF);
}
}
};

View File

@ -7,8 +7,8 @@
#include <Tactility/app/AppManifest.h>
#include <Tactility/lvgl/LvglSync.h>
#include <lvgl/icons/shared.h>
#include <tactility/log.h>
#include <lvgl/lvgl_icon_shared.h>
namespace tt::app::btmanage {

View File

@ -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

View File

@ -11,7 +11,7 @@
#include <Tactility/bluetooth/BluetoothPairedDevice.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h>
#include <lvgl/widgets/toolbar.h>
#include <tactility/check.h>
#include <tactility/drivers/bluetooth.h>
#include <tactility/log.h>
@ -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));

View File

@ -10,11 +10,11 @@
#include <Tactility/app/AppManifest.h>
#include <Tactility/lvgl/LvglSync.h>
#include <lvgl/icons/shared.h>
#include <algorithm>
#include <cctype>
#include <cstdlib>
#include <tactility/log.h>
#include <lvgl/lvgl_icon_shared.h>
#include <vector>
namespace tt::app::chat {

View File

@ -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

View File

@ -11,9 +11,9 @@
#include <Tactility/service/loader/Loader.h>
#include <Tactility/service/wifi/Wifi.h>
#include <tactility/log.h>
#include <lvgl/lvgl_icon_shared.h>
#include <lvgl/icons/shared.h>
#include <lvgl/lvgl.h>
#include <tactility/log.h>
#include <cstring>
#include <lvgl.h>
@ -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()) {

View File

@ -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);

View File

@ -7,7 +7,7 @@
#include <Tactility/file/File.h>
#include <Tactility/Platform.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <lvgl/widgets/toolbar.h>
#include <tactility/check.h>
#include <tactility/log.h>
@ -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));

View File

@ -1,5 +1,5 @@
#include <lvgl/icons/shared.h>
#include <lvgl/lvgl.h>
#include <lvgl/lvgl_icon_shared.h>
#include <Tactility/Tactility.h>
#include <Tactility/Timer.h>
@ -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);

View File

@ -2,9 +2,9 @@
#include <lvgl.h>
#include <lvgl/icons/shared.h>
#include <tactility/device.h>
#include <tactility/drivers/grove.h>
#include <lvgl/lvgl_icon_shared.h>
#include <Tactility/Tactility.h>
#include <Tactility/lvgl/Toolbar.h>

View File

@ -13,8 +13,8 @@
#include <format>
#include <lvgl/icons/shared.h>
#include <tactility/log.h>
#include <lvgl/lvgl_icon_shared.h>
namespace tt::app::i2cscanner {

View File

@ -1,6 +1,6 @@
#include <Tactility/app/inputdialog/InputDialog.h>
#include <Tactility/lvgl/Toolbar.h>
#include <lvgl/widgets/toolbar.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/TactilityCore.h>
#include <tactility/log.h>
@ -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);

View File

@ -1,10 +1,10 @@
#include <tactility/drivers/display.h>
#include <tactility/error.h>
#include <lvgl/lvgl_icon_shared.h>
#include <lvgl/icons/shared.h>
#include <lvgl/lvgl.h>
#include <tactility/device.h>
#include <tactility/drivers/backlight.h>
#include <tactility/drivers/display.h>
#include <tactility/error.h>
#include <tactility/log.h>
#include <lvgl/lvgl.h>
#include <Tactility/Tactility.h>
#ifdef ESP_PLATFORM

View File

@ -5,9 +5,9 @@
#include <Tactility/settings/KeyboardSettings.h>
#include <Tactility/lvgl/Toolbar.h>
#include <lvgl/icons/shared.h>
#include <tactility/device.h>
#include <tactility/drivers/backlight.h>
#include <lvgl/lvgl_icon_shared.h>
#include <lvgl.h>

View File

@ -10,12 +10,12 @@
#include <cstring>
#include <lvgl.h>
#include <lvgl/icons/launcher.h>
#include <lvgl/fonts.h>
#include <lvgl/lvgl.h>
#include <tactility/device.h>
#include <tactility/drivers/power_supply.h>
#include <tactility/log.h>
#include <lvgl/lvgl_fonts.h>
#include <lvgl/lvgl_icon_launcher.h>
#include <lvgl/lvgl.h>
namespace tt::app::launcher {

View File

@ -8,7 +8,7 @@
#include <Tactility/settings/Language.h>
#include <Tactility/settings/SystemSettings.h>
#include <lvgl/lvgl_icon_shared.h>
#include <lvgl/icons/shared.h>
#include <lvgl.h>
#include <map>

View File

@ -7,9 +7,9 @@
#include <Tactility/file/File.h>
#include <lvgl/icons/shared.h>
#include <lvgl.h>
#include <tactility/log.h>
#include <lvgl/lvgl_icon_shared.h>
namespace tt::app::notes {

View File

@ -6,9 +6,9 @@
#include <Tactility/Timer.h>
#include <lvgl/icons/shared.h>
#include <tactility/device.h>
#include <tactility/drivers/power_supply.h>
#include <lvgl/lvgl_icon_shared.h>
#include <lvgl.h>

View File

@ -6,11 +6,11 @@
#include <Tactility/app/AppRegistration.h>
#include <Tactility/service/loader/Loader.h>
#include <lvgl/icons/shared.h>
#include <lvgl.h>
#include <lvgl/fonts.h>
#include <tactility/device.h>
#include <tactility/drivers/power_supply.h>
#include <lvgl/lvgl_fonts.h>
#include <lvgl/lvgl_icon_shared.h>
namespace tt::app::poweroff {

View File

@ -14,8 +14,8 @@
#include <Tactility/Paths.h>
#include <Tactility/Timer.h>
#include <lvgl/icons/shared.h>
#include <tactility/log.h>
#include <lvgl/lvgl_icon_shared.h>
namespace tt::app::screenshot {

View File

@ -1,6 +1,6 @@
#include <Tactility/app/selectiondialog/SelectionDialog.h>
#include <Tactility/lvgl/Toolbar.h>
#include <lvgl/widgets/toolbar.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/StringUtils.h>
#include <tactility/log.h>
@ -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));

View File

@ -2,9 +2,9 @@
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/loader/Loader.h>
#include <lvgl/icons/shared.h>
#include <lvgl/fonts.h>
#include <tactility/check.h>
#include <lvgl/lvgl_icon_shared.h>
#include <lvgl/lvgl_fonts.h>
#include <lvgl.h>

View File

@ -1,4 +1,4 @@
#include <lvgl/lvgl_fonts.h>
#include <lvgl/fonts.h>
#include <lvgl/lvgl.h>
#include <Tactility/app/App.h>

View File

@ -11,8 +11,8 @@
#include <lvgl.h>
#include <utility>
#include <lvgl/lvgl_fonts.h>
#include <lvgl/lvgl_icon_shared.h>
#include <lvgl/icons/shared.h>
#include <lvgl/fonts.h>
#include <lvgl/lvgl.h>
#ifdef ESP_PLATFORM

View File

@ -12,8 +12,8 @@
#include <lvgl.h>
#include <lvgl/icons/shared.h>
#include <tactility/log.h>
#include <lvgl/lvgl_icon_shared.h>
namespace tt::app::timedatesettings {

View File

@ -1,5 +1,5 @@
#include <lvgl/lvgl_fonts.h>
#include <lvgl/lvgl_icon_shared.h>
#include <lvgl/icons/shared.h>
#include <lvgl/fonts.h>
#include <Tactility/app/AppContext.h>
#include <Tactility/app/AppManifest.h>

View File

@ -7,7 +7,7 @@
#include <tactility/log.h>
#include <lvgl/lvgl.h>
#include <lvgl/lvgl_pointer.h>
#include <lvgl/devices/pointer.h>
#include <algorithm>
#include <lvgl.h>

View File

@ -2,7 +2,7 @@
#include <lvgl.h>
#include <lvgl/lvgl_icon_shared.h>
#include <lvgl/icons/shared.h>
#include <lvgl/lvgl.h>
#include <Tactility/Tactility.h>
@ -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);

View File

@ -5,7 +5,7 @@
#include <lvgl.h>
#include <lvgl/lvgl_icon_shared.h>
#include <lvgl/icons/shared.h>
#define TAG "usb_settings"

View File

@ -10,9 +10,9 @@
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/lvgl/LvglSync.h>
#include <lvgl/icons/shared.h>
#include <lvgl.h>
#include <tactility/log.h>
#include <lvgl/lvgl_icon_shared.h>
#include <esp_netif.h>
#include <esp_wifi.h>
@ -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);
}

View File

@ -6,7 +6,7 @@
#include <Tactility/app/AppManifest.h>
#include <Tactility/app/alertdialog/AlertDialog.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h>
#include <lvgl/widgets/toolbar.h>
#include <Tactility/service/wifi/Wifi.h>
#include <Tactility/service/wifi/WifiApSettings.h>
@ -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));

View File

@ -3,7 +3,7 @@
#include <Tactility/app/wificonnect/View.h>
#include <Tactility/app/wificonnect/WifiConnect.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/lvgl/Spinner.h>
#include <lvgl/widgets/spinner.h>
#include <Tactility/service/wifi/WifiApSettings.h>
#include <Tactility/service/wifi/WifiGlobals.h>
@ -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);

View File

@ -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

View File

@ -8,8 +8,8 @@
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/service/loader/Loader.h>
#include <lvgl/icons/shared.h>
#include <tactility/log.h>
#include <lvgl/lvgl_icon_shared.h>
namespace tt::app::wifimanage {

View File

@ -10,10 +10,10 @@
#include <Tactility/lvgl/Style.h>
#include <Tactility/settings/Time.h>
#include <lvgl/fonts.h>
#include <lvgl/lvgl.h>
#include <tactility/check.h>
#include <tactility/log.h>
#include <lvgl/lvgl_fonts.h>
#include <lvgl/lvgl.h>
#include <lvgl.h>
#include <memory>

View File

@ -1,259 +1,10 @@
#define LV_USE_PRIVATE_API 1 // For actual lv_obj_t declaration
#include <Tactility/Tactility.h>
#include <Tactility/lvgl/Toolbar.h>
#include "tactility/drivers/pointer.h"
#include <Tactility/lvgl/Spinner.h>
#include <Tactility/service/loader/Loader.h>
#include <tactility/check.h>
#include <lvgl/lvgl_fonts.h>
#include <lvgl/lvgl.h>
#include <Tactility/app/AppManifest.h>
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<Toolbar*>(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<Toolbar*>(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<Toolbar*>(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<Toolbar*>(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<Toolbar*>(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<Toolbar*>(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<Toolbar*>(obj);
lv_obj_clean(toolbar->action_container);
toolbar->action_count = 0;
return lvgl_toolbar_create(parent, app.getManifest().appName.c_str());
}
} // namespace

View File

@ -3,7 +3,7 @@
#include <Tactility/service/ServiceManifest.h>
#include <Tactility/service/memorychecker/MemoryCheckerService.h>
#include <lvgl/lvgl_icon_statusbar.h>
#include <lvgl/icons/statusbar.h>
#include <tactility/log.h>
namespace tt::service::memorychecker {

View File

@ -21,8 +21,8 @@
#include <tactility/log.h>
#include <lvgl/icons/statusbar.h>
#include <lvgl/lvgl.h>
#include <lvgl/lvgl_icon_statusbar.h>
#include <cstring>

View File

@ -30,7 +30,7 @@
#include <lv_screenshot.h>
#endif
#include <lvgl/lvgl_icon_statusbar.h>
#include <lvgl/icons/statusbar.h>
#include <atomic>
#include <cctype>

View File

@ -1,48 +0,0 @@
#pragma once
#include <stdbool.h>
#include <freertos/FreeRTOS.h>
#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

View File

@ -1,55 +0,0 @@
#pragma once
#include <lvgl.h>
#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

View File

@ -1,14 +0,0 @@
#pragma once
#include <lvgl.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Create a spinner widget. */
lv_obj_t* tt_lvgl_spinner_create(lv_obj_t* parent);
#ifdef __cplusplus
}
#endif

View File

@ -1,72 +0,0 @@
#pragma once
#include "tt_app.h"
#include <lvgl.h>
#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

View File

@ -1,8 +0,0 @@
#pragma once
#include <memory>
#include <Tactility/Lock.h>
struct LockHolder {
std::shared_ptr<tt::Lock> lock;
};

View File

@ -5,10 +5,6 @@
#include "tt_app_fileselection.h"
#include "tt_app_selectiondialog.h"
#include "tt_bundle.h"
#include <tt_lock.h>
#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),

View File

@ -1,29 +0,0 @@
#include <Tactility/Mutex.h>
#include <Tactility/RecursiveMutex.h>
#include <Tactility/file/File.h>
#include <tt_lock.h>
#include <tt_lock_private.h>
#define HANDLE_AS_LOCK(handle) (static_cast<LockHolder*>(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<LockHolder*>(handle);
delete holder;
}
}

View File

@ -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);
}
}

View File

@ -1,10 +0,0 @@
#include "tt_lvgl_spinner.h"
#include <Tactility/lvgl/Spinner.h>
extern "C" {
lv_obj_t* tt_lvgl_spinner_create(lv_obj_t* parent) {
return tt::lvgl::spinner_create(parent);
}
}

View File

@ -1,42 +0,0 @@
#include "tt_lvgl_toolbar.h"
#include <Tactility/lvgl/Toolbar.h>
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);
}
}

View File

@ -1,5 +1,7 @@
#include <tt_app.h>
#include <tt_lvgl_toolbar.h>
#include <lvgl/lvgl.h>
#include <lvgl/widgets/toolbar.h>
#include <tactility/concurrent/dispatcher.h>
#include <tactility/concurrent/event_group.h>
@ -22,8 +24,6 @@
#include <tactility/module.h>
#include <tactility/time.h>
#include <lvgl/lvgl.h>
#include <drivers/bm8563.h>
#include <drivers/bmi270.h>
#include <drivers/mpu6886.h>
@ -32,7 +32,7 @@
#include <drivers/rx8130ce.h>
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);