Merge develop into main (#337)

- Implement `UiScale` in `hal::Configuration`: small screens with no touch can now opt for a more optimized experience (e.g. Cardputer, Waveshare 1.47, Waveshare 1.3", etc.)
- Fix for Cardputer UART configuration and added I2C configuration
- Fix for software keyboard bug in Gui
- Removed deprecated fields from `hal::Configuration`
- Updated the simulator devices to use the new HAL config
- add `bool tt::hal::hasDevice(Device::Type)`
- Cleanup of `AppList` app code
- Improve `Gpio` app for small screen devices
- Added various ESP32 GCC wrappers to wrap LVGL functions (with manipulations for small screen devices)
- Moved `Launcher` assets to `assets/` subfolder
- Optimized `Toolbar` for small screen devices
- Stop showing `system/` partition in `FileBrowser` because it's read-only and not very useful. Created `config::SHOW_SYSTEM_PARTITION` to override this behaviour.
- Hide apps when their required hardware isn't available (I2C, UART, PowerDevice)
- Fix for `CYD-2432S032C` DPI setting
This commit is contained in:
Ken Van Hoeylandt
2025-09-15 22:46:12 +02:00
committed by GitHub
parent ce8ac61d42
commit 53b711584f
42 changed files with 394 additions and 189 deletions
+13 -9
View File
@@ -1,4 +1,6 @@
#include "Tactility/MountPoints.h"
#include "Tactility/TactilityConfig.h"
#include "Tactility/hal/Device.h"
#include "Tactility/hal/sdcard/SdCardDevice.h"
@@ -14,15 +16,6 @@ std::vector<dirent> getMountPoints() {
std::vector<dirent> dir_entries;
dir_entries.clear();
// System partition
auto system_dirent = dirent{
.d_ino = 0,
.d_type = TT_DT_DIR,
.d_name = { 0 }
};
strcpy(system_dirent.d_name, SYSTEM_PARTITION_NAME);
dir_entries.push_back(system_dirent);
// Data partition
auto data_dirent = dirent{
.d_ino = 1,
@@ -49,6 +42,17 @@ std::vector<dirent> getMountPoints() {
}
}
if (config::SHOW_SYSTEM_PARTITION) {
// System partition
auto system_dirent = dirent{
.d_ino = 0,
.d_type = TT_DT_DIR,
.d_name = { 0 }
};
strcpy(system_dirent.d_name, SYSTEM_PARTITION_NAME);
dir_entries.push_back(system_dirent);
}
return dir_entries;
}
+16 -7
View File
@@ -98,7 +98,6 @@ namespace app {
// List of all apps excluding Boot app (as Boot app calls this function indirectly)
static void registerSystemApps() {
addApp(app::addgps::manifest);
addApp(app::alertdialog::manifest);
addApp(app::applist::manifest);
addApp(app::calculator::manifest);
@@ -106,26 +105,25 @@ static void registerSystemApps() {
addApp(app::filebrowser::manifest);
addApp(app::fileselection::manifest);
addApp(app::gpio::manifest);
addApp(app::gpssettings::manifest);
addApp(app::i2cscanner::manifest);
addApp(app::i2csettings::manifest);
addApp(app::imageviewer::manifest);
addApp(app::inputdialog::manifest);
addApp(app::launcher::manifest);
addApp(app::localesettings::manifest);
addApp(app::log::manifest);
addApp(app::notes::manifest);
addApp(app::serialconsole::manifest);
addApp(app::settings::manifest);
addApp(app::selectiondialog::manifest);
addApp(app::systeminfo::manifest);
addApp(app::timedatesettings::manifest);
addApp(app::timezone::manifest);
addApp(app::usbsettings::manifest);
addApp(app::wifiapsettings::manifest);
addApp(app::wificonnect::manifest);
addApp(app::wifimanage::manifest);
#if defined(CONFIG_TINYUSB_MSC_ENABLED) && CONFIG_TINYUSB_MSC_ENABLED
addApp(app::usbsettings::manifest);
#endif
#if TT_FEATURE_SCREENSHOT_ENABLED
addApp(app::screenshot::manifest);
#endif
@@ -136,7 +134,18 @@ static void registerSystemApps() {
addApp(app::development::manifest);
#endif
if (hal::findDevices(hal::Device::Type::Power).size() > 0) {
if (!hal::getConfiguration()->i2c.empty()) {
addApp(app::i2cscanner::manifest);
addApp(app::i2csettings::manifest);
}
if (!hal::getConfiguration()->uart.empty()) {
addApp(app::addgps::manifest);
addApp(app::gpssettings::manifest);
addApp(app::serialconsole::manifest);
}
if (hal::hasDevice(hal::Device::Type::Power)) {
addApp(app::power::manifest);
}
}
+2 -7
View File
@@ -3,18 +3,14 @@
#include "Tactility/lvgl/Toolbar.h"
#include <Tactility/Assets.h>
#include <Tactility/Check.h>
#include <lvgl.h>
#include <algorithm>
namespace tt::app::applist {
class AppListApp : public App {
private:
static void onAppPressed(lv_event_t* e) {
const auto* manifest = static_cast<const AppManifest*>(lv_event_get_user_data(e));
service::loader::startApp(manifest->id);
@@ -23,7 +19,7 @@ private:
static void createAppWidget(const std::shared_ptr<AppManifest>& manifest, lv_obj_t* list) {
const void* icon = !manifest->icon.empty() ? manifest->icon.c_str() : TT_ASSETS_APP_ICON_FALLBACK;
lv_obj_t* btn = lv_list_add_button(list, icon, manifest->name.c_str());
lv_obj_add_event_cb(btn, &onAppPressed, LV_EVENT_SHORT_CLICKED, (void*)manifest.get());
lv_obj_add_event_cb(btn, &onAppPressed, LV_EVENT_SHORT_CLICKED, manifest.get());
}
public:
@@ -41,7 +37,7 @@ public:
lv_obj_set_height(list, parent_content_height - toolbar_height);
auto manifests = getApps();
std::sort(manifests.begin(), manifests.end(), SortAppManifestByName);
std::ranges::sort(manifests, SortAppManifestByName);
for (const auto& manifest: manifests) {
if (manifest->type == Type::User || manifest->type == Type::System) {
@@ -51,7 +47,6 @@ public:
}
};
extern const AppManifest manifest = {
.id = "AppList",
.name = "Apps",
+16 -3
View File
@@ -101,10 +101,20 @@ void GpioApp::stopTask() {
// endregion Task
static int getSquareSpacing(hal::UiScale uiScale) {
if (uiScale == hal::UiScale::Smallest) {
return 0;
} else {
return 4;
}
}
void GpioApp::onShow(AppContext& app, lv_obj_t* parent) {
auto ui_scale = hal::getConfiguration()->uiScale;
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, app);
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
@@ -113,13 +123,16 @@ void GpioApp::onShow(AppContext& app, lv_obj_t* parent) {
lv_obj_set_width(wrapper, LV_PCT(100));
lv_obj_set_flex_grow(wrapper, 1);
lv_obj_set_style_border_width(wrapper, 0, LV_STATE_DEFAULT);
lv_obj_set_style_pad_all(wrapper, 0, LV_STATE_DEFAULT);
auto* display = lv_obj_get_display(parent);
auto horizontal_px = lv_display_get_horizontal_resolution(display);
auto vertical_px = lv_display_get_vertical_resolution(display);
bool is_landscape_display = horizontal_px > vertical_px;
int32_t x_spacing = 20;
constexpr auto block_width = 16;
const auto square_spacing = getSquareSpacing(ui_scale);
int32_t x_spacing = block_width + square_spacing;
uint8_t column = 0;
const uint8_t offset_from_left_label = 4;
const uint8_t column_limit = is_landscape_display ? 10 : 5;
@@ -138,7 +151,7 @@ void GpioApp::onShow(AppContext& app, lv_obj_t* parent) {
// Add a new GPIO status indicator
auto* status_label = lv_label_create(row_wrapper);
lv_obj_set_pos(status_label, (int32_t)((column+1) * x_spacing + offset_from_left_label), 0);
lv_obj_set_pos(status_label, (column+1) * x_spacing + offset_from_left_label, 0);
lv_label_set_text_fmt(status_label, "%s", LV_SYMBOL_STOP);
lv_obj_set_style_text_color(status_label, lv_color_background_darkest(), LV_STATE_DEFAULT);
lvPins[i] = status_label;
@@ -153,7 +166,7 @@ void GpioApp::onShow(AppContext& app, lv_obj_t* parent) {
// Add a new row wrapper underneath the last one
auto* new_row_wrapper = createGpioRowWrapper(wrapper);
lv_obj_align_to(new_row_wrapper, row_wrapper, LV_ALIGN_BOTTOM_LEFT, 0, 4);
lv_obj_align_to(new_row_wrapper, row_wrapper, LV_ALIGN_BOTTOM_LEFT, 0, square_spacing);
row_wrapper = new_row_wrapper;
column = 0;
@@ -30,7 +30,8 @@ class ImageViewerApp : public App {
lv_obj_align_to(image_wrapper, toolbar, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
lv_obj_set_width(image_wrapper, LV_PCT(100));
auto parent_height = lv_obj_get_height(wrapper);
lv_obj_set_height(image_wrapper, parent_height - TOOLBAR_HEIGHT);
auto toolbar_height = lv_obj_get_height(toolbar);
lv_obj_set_height(image_wrapper, parent_height - toolbar_height);
lv_obj_set_flex_flow(image_wrapper, LV_FLEX_FLOW_COLUMN);
lv_obj_set_flex_align(image_wrapper, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
lv_obj_set_style_pad_all(image_wrapper, 0, 0);
+23 -11
View File
@@ -11,11 +11,20 @@
namespace tt::app::launcher {
constexpr auto* TAG = "Launcher";
constexpr auto BUTTON_SIZE = 64;
static int getButtonSize(hal::UiScale scale) {
if (scale == hal::UiScale::Smallest) {
return 40;
} else {
return 64;
}
}
class LauncherApp final : public App {
static lv_obj_t* createAppButton(lv_obj_t* parent, const char* imageFile, const char* appId, int32_t horizontalMargin) {
static lv_obj_t* createAppButton(lv_obj_t* parent, hal::UiScale uiScale, const char* imageFile, const char* appId, int32_t horizontalMargin) {
auto button_size = getButtonSize(uiScale);
auto* apps_button = lv_button_create(parent);
lv_obj_set_style_pad_all(apps_button, 0, LV_STATE_DEFAULT);
lv_obj_set_style_margin_hor(apps_button, horizontalMargin, LV_STATE_DEFAULT);
@@ -28,7 +37,7 @@ class LauncherApp final : public App {
lv_obj_set_style_image_recolor_opa(button_image, LV_OPA_COVER, LV_STATE_DEFAULT);
// Ensure buttons are still tappable when the asset fails to load
// Icon images are 40x40, so we get some extra padding too
lv_obj_set_size(button_image, BUTTON_SIZE, BUTTON_SIZE);
lv_obj_set_size(button_image, button_size, button_size);
lv_obj_add_event_cb(apps_button, onAppPressed, LV_EVENT_SHORT_CLICKED, (void*)appId);
@@ -73,6 +82,9 @@ public:
void onShow(TT_UNUSED AppContext& app, lv_obj_t* parent) override {
auto* buttons_wrapper = lv_obj_create(parent);
auto ui_scale = hal::getConfiguration()->uiScale;
auto button_size = getButtonSize(ui_scale);
lv_obj_align(buttons_wrapper, LV_ALIGN_CENTER, 0, 0);
// lv_obj_set_style_pad_all(buttons_wrapper, 0, LV_STATE_DEFAULT);
lv_obj_set_size(buttons_wrapper, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
@@ -89,17 +101,17 @@ public:
lv_obj_set_flex_flow(buttons_wrapper, LV_FLEX_FLOW_COLUMN);
}
const int32_t available_width = lv_display_get_horizontal_resolution(display) - (3 * BUTTON_SIZE);
const int32_t margin = is_landscape_display ? std::min<int32_t>(available_width / 16, BUTTON_SIZE) : 0;
const int32_t available_width = lv_display_get_horizontal_resolution(display) - (3 * button_size);
const int32_t margin = is_landscape_display ? std::min<int32_t>(available_width / 16, button_size) : 0;
const auto paths = app.getPaths();
const auto apps_icon_path = paths->getSystemPathLvgl("icon_apps.png");
const auto files_icon_path = paths->getSystemPathLvgl("icon_files.png");
const auto settings_icon_path = paths->getSystemPathLvgl("icon_settings.png");
const auto apps_icon_path = paths->getSystemPathLvgl("assets/icon_apps.png");
const auto files_icon_path = paths->getSystemPathLvgl("assets/icon_files.png");
const auto settings_icon_path = paths->getSystemPathLvgl("assets/icon_settings.png");
createAppButton(buttons_wrapper, apps_icon_path.c_str(), "AppList", margin);
createAppButton(buttons_wrapper, files_icon_path.c_str(), "Files", margin);
createAppButton(buttons_wrapper, settings_icon_path.c_str(), "Settings", margin);
createAppButton(buttons_wrapper, ui_scale, apps_icon_path.c_str(), "AppList", margin);
createAppButton(buttons_wrapper, ui_scale, files_icon_path.c_str(), "Files", margin);
createAppButton(buttons_wrapper, ui_scale, settings_icon_path.c_str(), "Settings", margin);
if (shouldShowPowerButton()) {
auto* power_button = lv_btn_create(parent);
+14 -4
View File
@@ -1,3 +1,4 @@
#include "Tactility/TactilityConfig.h"
#include "Tactility/lvgl/Toolbar.h"
#include <Tactility/Assets.h>
@@ -141,7 +142,12 @@ static void addMemoryBar(lv_obj_t* parent, const char* label, uint64_t free, uin
lv_label_set_text_fmt(bottom_label, "%s / %s %s used", used_converted.c_str(), total_converted.c_str(), unit_label.c_str());
lv_obj_set_width(bottom_label, LV_PCT(100));
lv_obj_set_style_text_align(bottom_label, LV_TEXT_ALIGN_RIGHT, 0);
lv_obj_set_style_pad_bottom(bottom_label, 12, LV_STATE_DEFAULT);
if (hal::getConfiguration()->uiScale == hal::UiScale::Smallest) {
lv_obj_set_style_pad_bottom(bottom_label, 2, LV_STATE_DEFAULT);
} else {
lv_obj_set_style_pad_bottom(bottom_label, 12, LV_STATE_DEFAULT);
}
}
#if configUSE_TRACE_FACILITY
@@ -245,9 +251,6 @@ class SystemInfoApp : public App {
uint64_t storage_total = 0;
uint64_t storage_free = 0;
if (esp_vfs_fat_info(file::MOUNT_POINT_SYSTEM, &storage_total, &storage_free) == ESP_OK) {
addMemoryBar(storage_tab, file::MOUNT_POINT_SYSTEM, storage_free, storage_total);
}
if (esp_vfs_fat_info(file::MOUNT_POINT_DATA, &storage_total, &storage_free) == ESP_OK) {
addMemoryBar(storage_tab, file::MOUNT_POINT_DATA, storage_free, storage_total);
@@ -264,6 +267,13 @@ class SystemInfoApp : public App {
);
}
}
if (config::SHOW_SYSTEM_PARTITION) {
if (esp_vfs_fat_info(file::MOUNT_POINT_SYSTEM, &storage_total, &storage_free) == ESP_OK) {
addMemoryBar(storage_tab, file::MOUNT_POINT_SYSTEM, storage_free, storage_total);
}
}
#endif
#if configUSE_TRACE_FACILITY
+9
View File
@@ -92,4 +92,13 @@ std::vector<std::shared_ptr<Device>> getDevices() {
return devices;
}
bool hasDevice(Device::Type type) {
auto scoped_mutex = mutex.asScopedLock();
scoped_mutex.lock();
auto result_set = devices | std::views::filter([&type](auto& device) {
return device->getType() == type;
});
return !result_set.empty();
}
}
-23
View File
@@ -19,29 +19,6 @@ constexpr auto* TAG = "Hal";
void registerDevices(const Configuration& configuration) {
TT_LOG_I(TAG, "Registering devices");
if (configuration.sdcard != nullptr) {
registerDevice(configuration.sdcard);
}
if (configuration.power != nullptr) {
std::shared_ptr<power::PowerDevice> power = configuration.power();
registerDevice(power);
}
if (configuration.createKeyboard) {
auto keyboard = configuration.createKeyboard();
if (keyboard != nullptr) {
registerDevice(std::reinterpret_pointer_cast<Device>(keyboard));
}
}
if (configuration.createDisplay != nullptr) {
auto display = configuration.createDisplay();
if (display != nullptr) {
registerDevice(display);
}
}
auto devices = configuration.createDevices();
for (auto& device : devices) {
registerDevice(device);
+2 -2
View File
@@ -5,7 +5,7 @@
#include <ranges>
#include <cstring>
#include <Tactility/TactilityHeadless.h>
#include <Tactility/Tactility.h>
#ifdef ESP_PLATFORM
#include <Tactility/hal/uart/UartEsp.h>
@@ -142,7 +142,7 @@ void close(uint32_t uartId) {
std::vector<std::string> getNames() {
std::vector<std::string> names;
#ifdef ESP_PLATFORM
for (auto& config : hal::getConfiguration()->uart) {
for (auto& config : getConfiguration()->uart) {
names.push_back(config.name);
}
#else
+53 -21
View File
@@ -8,6 +8,30 @@
namespace tt::lvgl {
static int getToolbarHeight(hal::UiScale uiScale) {
if (uiScale == hal::UiScale::Smallest) {
return 20;
} else {
return 40;
}
}
static int getToolbarFontHeight(hal::UiScale uiScale) {
if (uiScale == hal::UiScale::Smallest) {
return 14;
} else {
return 18;
}
}
static const _lv_font_t* getToolbarFont(hal::UiScale uiScale) {
if (uiScale == hal::UiScale::Smallest) {
return &lv_font_montserrat_14;
} else {
return &lv_font_montserrat_18;
}
}
typedef struct {
lv_obj_t obj;
lv_obj_t* title_label;
@@ -19,7 +43,7 @@ typedef struct {
static void toolbar_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj);
static const lv_obj_class_t toolbar_class = {
static lv_obj_class_t toolbar_class = {
.base_class = &lv_obj_class,
.constructor_cb = &toolbar_constructor,
.destructor_cb = nullptr,
@@ -27,7 +51,7 @@ static const lv_obj_class_t toolbar_class = {
.user_data = nullptr,
.name = nullptr,
.width_def = LV_PCT(100),
.height_def = TOOLBAR_HEIGHT,
.height_def = 40,
.editable = false,
.group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE,
.instance_size = sizeof(Toolbar),
@@ -48,41 +72,46 @@ static void toolbar_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj) {
lv_obj_t* toolbar_create(lv_obj_t* parent, const std::string& title) {
LV_LOG_INFO("begin");
auto ui_scale = hal::getConfiguration()->uiScale;
auto toolbar_height = getToolbarHeight(ui_scale);
toolbar_class.height_def = toolbar_height;
lv_obj_t* obj = lv_obj_class_create_obj(&toolbar_class, parent);
lv_obj_class_init_obj(obj);
auto* toolbar = (Toolbar*)obj;
lv_obj_set_style_pad_all(obj, 0, 0);
lv_obj_set_style_pad_gap(obj, 0, 0);
lv_obj_set_style_pad_all(obj, 0, LV_STATE_DEFAULT);
lv_obj_set_style_pad_gap(obj, 0, LV_STATE_DEFAULT);
lv_obj_center(obj);
lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_ROW);
toolbar->close_button = lv_button_create(obj);
lv_obj_set_size(toolbar->close_button, TOOLBAR_HEIGHT - 4, TOOLBAR_HEIGHT - 4);
lv_obj_set_style_pad_all(toolbar->close_button, 0, 0);
lv_obj_set_style_pad_gap(toolbar->close_button, 0, 0);
lv_obj_set_size(toolbar->close_button, toolbar_height - 4, toolbar_height - 4);
lv_obj_set_style_pad_all(toolbar->close_button, 0, LV_STATE_DEFAULT);
lv_obj_set_style_pad_gap(toolbar->close_button, 0, LV_STATE_DEFAULT);
toolbar->close_button_image = lv_image_create(toolbar->close_button);
lv_obj_align(toolbar->close_button_image, LV_ALIGN_CENTER, 0, 0);
toolbar->title_label = lv_label_create(obj);
lv_obj_set_style_text_font(toolbar->title_label, &lv_font_montserrat_18, 0); // TODO replace with size 18
lv_obj_set_style_text_font(toolbar->title_label, getToolbarFont(ui_scale), LV_STATE_DEFAULT);
lv_label_set_text(toolbar->title_label, title.c_str());
lv_obj_set_style_text_align(toolbar->title_label, LV_TEXT_ALIGN_LEFT, 0);
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_set_flex_grow(toolbar->title_label, 1);
int32_t title_offset_x = (TOOLBAR_HEIGHT - TOOLBAR_TITLE_FONT_HEIGHT - 8) / 4 * 3;
int32_t title_offset_x = (toolbar_height - getToolbarFontHeight(ui_scale) - 8) / 4 * 3;
// Margin top doesn't work
lv_obj_set_style_pad_top(toolbar->title_label, title_offset_x, 0);
lv_obj_set_style_margin_left(toolbar->title_label, 8, 0);
lv_obj_set_style_pad_top(toolbar->title_label, title_offset_x, LV_STATE_DEFAULT);
lv_obj_set_style_margin_left(toolbar->title_label, 8, LV_STATE_DEFAULT);
// Hack for margin bug where buttons in flex get rendered more narrowly
lv_obj_set_style_margin_right(toolbar->title_label, -8, 0);
lv_obj_set_style_margin_right(toolbar->title_label, -8, LV_STATE_DEFAULT);
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, 0);
lv_obj_set_style_border_width(toolbar->action_container, 0, 0);
lv_obj_set_style_pad_all(toolbar->action_container, 0, LV_STATE_DEFAULT);
lv_obj_set_style_border_width(toolbar->action_container, 0, LV_STATE_DEFAULT);
lv_obj_set_flex_align(toolbar->action_container, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START);
toolbar_set_nav_action(obj, LV_SYMBOL_CLOSE, &stop_app, nullptr);
@@ -110,10 +139,13 @@ lv_obj_t* toolbar_add_button_action(lv_obj_t* obj, const char* icon, lv_event_cb
tt_check(toolbar->action_count < TOOLBAR_ACTION_LIMIT, "max actions reached");
toolbar->action_count++;
auto ui_scale = hal::getConfiguration()->uiScale;
auto toolbar_height = getToolbarHeight(ui_scale);
lv_obj_t* action_button = lv_button_create(toolbar->action_container);
lv_obj_set_size(action_button, TOOLBAR_HEIGHT - 4, TOOLBAR_HEIGHT - 4);
lv_obj_set_style_pad_all(action_button, 0, 0);
lv_obj_set_style_pad_gap(action_button, 0, 0);
lv_obj_set_size(action_button, toolbar_height - 4, toolbar_height - 4);
lv_obj_set_style_pad_all(action_button, 0, LV_STATE_DEFAULT);
lv_obj_set_style_pad_gap(action_button, 0, LV_STATE_DEFAULT);
lv_obj_add_event_cb(action_button, callback, LV_EVENT_SHORT_CLICKED, user_data);
lv_obj_t* action_button_image = lv_image_create(action_button);
lv_image_set_src(action_button_image, icon);
@@ -125,14 +157,14 @@ lv_obj_t* toolbar_add_button_action(lv_obj_t* obj, const char* icon, lv_event_cb
lv_obj_t* toolbar_add_switch_action(lv_obj_t* obj) {
auto* toolbar = (Toolbar*)obj;
lv_obj_t* widget = lv_switch_create(toolbar->action_container);
lv_obj_set_style_margin_top(widget, 4, 0); // Because aligning doesn't work
lv_obj_set_style_margin_right(widget, 4, 0);
lv_obj_set_style_margin_top(widget, 4, LV_STATE_DEFAULT); // Because aligning doesn't work
lv_obj_set_style_margin_right(widget, 4, LV_STATE_DEFAULT);
return widget;
}
lv_obj_t* toolbar_add_spinner_action(lv_obj_t* obj) {
auto* toolbar = (Toolbar*)obj;
return tt::lvgl::spinner_create(toolbar->action_container);
return spinner_create(toolbar->action_container);
}
} // namespace
+23
View File
@@ -0,0 +1,23 @@
#ifdef ESP_PLATFORM
#include <Tactility/Tactility.h>
#include <lvgl.h>
extern "C" {
extern lv_obj_t* __real_lv_button_create(lv_obj_t* parent);
lv_obj_t* __wrap_lv_button_create(lv_obj_t* parent) {
auto button = __real_lv_button_create(parent);
if (tt::hal::getConfiguration()->uiScale == tt::hal::UiScale::Smallest) {
lv_obj_set_style_pad_all(button, 2, LV_STATE_DEFAULT);
}
return button;
}
}
#endif // ESP_PLATFORM
@@ -0,0 +1,23 @@
#ifdef ESP_PLATFORM
#include <Tactility/Tactility.h>
#include <lvgl.h>
extern "C" {
extern lv_obj_t* __real_lv_dropdown_create(lv_obj_t* parent);
lv_obj_t* __wrap_lv_dropdown_create(lv_obj_t* parent) {
auto dropdown = __real_lv_dropdown_create(parent);
if (tt::hal::getConfiguration()->uiScale == tt::hal::UiScale::Smallest) {
lv_obj_set_style_pad_all(dropdown, 2, LV_STATE_DEFAULT);
}
return dropdown;
}
}
#endif // ESP_PLATFORM
+35
View File
@@ -0,0 +1,35 @@
#ifdef ESP_PLATFORM
#include <Tactility/Tactility.h>
#include <lvgl.h>
extern "C" {
extern lv_obj_t* __real_lv_list_create(lv_obj_t* parent);
extern lv_obj_t* __real_lv_list_add_button(lv_obj_t* list, const void* icon, const char* txt);
lv_obj_t* __wrap_lv_list_create(lv_obj_t* parent) {
auto list = __real_lv_list_create(parent);
if (tt::hal::getConfiguration()->uiScale == tt::hal::UiScale::Smallest) {
lv_obj_set_style_pad_row(list, 2, LV_STATE_DEFAULT);
lv_obj_set_style_pad_column(list, 2, LV_STATE_DEFAULT);
}
return list;
}
lv_obj_t* __wrap_lv_list_add_button(lv_obj_t* list, const void* icon, const char* txt) {
auto button = __real_lv_list_add_button(list, icon, txt);
if (tt::hal::getConfiguration()->uiScale == tt::hal::UiScale::Smallest) {
lv_obj_set_style_pad_ver(button, 2, LV_STATE_DEFAULT);
}
return button;
}
}
#endif // ESP_PLATFORM
+35
View File
@@ -0,0 +1,35 @@
#ifdef ESP_PLATFORM
#include <Tactility/Tactility.h>
#include <lvgl.h>
extern "C" {
extern void __real_lv_obj_set_flex_flow(lv_obj_t* obj, lv_flex_flow_t flow);
extern lv_obj_t* __real_lv_obj_create(lv_obj_t* parent);
void __wrap_lv_obj_set_flex_flow(lv_obj_t* obj, lv_flex_flow_t flow) {
__real_lv_obj_set_flex_flow(obj, flow);
if (tt::hal::getConfiguration()->uiScale == tt::hal::UiScale::Smallest) {
lv_obj_set_style_pad_row(obj, 2, LV_STATE_DEFAULT);
lv_obj_set_style_pad_column(obj, 2, LV_STATE_DEFAULT);
}
}
lv_obj_t* __wrap_lv_obj_create(lv_obj_t* parent) {
auto obj = __real_lv_obj_create(parent);
if (tt::hal::getConfiguration()->uiScale == tt::hal::UiScale::Smallest) {
lv_obj_set_style_pad_row(obj, 2, LV_STATE_DEFAULT);
lv_obj_set_style_pad_column(obj, 2, LV_STATE_DEFAULT);
lv_obj_set_style_pad_all(obj, 2, LV_STATE_DEFAULT);
lv_obj_set_style_radius(obj, 3, LV_STATE_DEFAULT);
lv_obj_set_style_border_width(obj, 1, LV_STATE_DEFAULT);
}
return obj;
}
}
#endif // ESP_PLATFORM
+23
View File
@@ -0,0 +1,23 @@
#ifdef ESP_PLATFORM
#include <Tactility/Tactility.h>
#include <lvgl.h>
extern "C" {
extern lv_obj_t* __real_lv_switch_create(lv_obj_t* parent);
lv_obj_t* __wrap_lv_switch_create(lv_obj_t* parent) {
auto widget = __real_lv_switch_create(parent);
if (tt::hal::getConfiguration()->uiScale == tt::hal::UiScale::Smallest) {
lv_obj_set_style_size(widget, 25, 15, LV_STATE_DEFAULT);
}
return widget;
}
}
#endif // ESP_PLATFORM
@@ -1,18 +1,20 @@
#ifdef ESP_PLATFORM
#include "Tactility/app/App.h"
#include "Tactility/service/gui/GuiService.h"
#include <lvgl.h>
#include <Tactility/app/App.h>
#include <Tactility/service/gui/GuiService.h>
#include <Tactility/Tactility.h>
extern "C" {
extern lv_obj_t * __real_lv_textarea_create(lv_obj_t * parent);
extern lv_obj_t* __real_lv_textarea_create(lv_obj_t* parent);
lv_obj_t * __wrap_lv_textarea_create(lv_obj_t * parent) {
lv_obj_t* __wrap_lv_textarea_create(lv_obj_t* parent) {
auto textarea = __real_lv_textarea_create(parent);
if (tt::hal::getConfiguration()->uiScale == tt::hal::UiScale::Smallest) {
lv_obj_set_style_pad_all(textarea, 2, LV_STATE_DEFAULT);
}
auto gui_service = tt::service::gui::findService();
if (gui_service != nullptr) {
gui_service->keyboardAddTextArea(textarea);
+1 -1
View File
@@ -27,7 +27,7 @@ void GuiService::onLoaderEvent(loader::LoaderEvent event) {
int32_t GuiService::guiMain() {
while (true) {
uint32_t flags = Thread::awaitFlags(GUI_THREAD_FLAG_ALL, EventFlag::WaitAny, (uint32_t)portMAX_DELAY);
uint32_t flags = Thread::awaitFlags(GUI_THREAD_FLAG_ALL, EventFlag::WaitAny, portMAX_DELAY);
// When service not started or starting -> exit
State service_state = getState(manifest.id);
+5 -5
View File
@@ -59,13 +59,13 @@ void GuiService::keyboardAddTextArea(lv_obj_t* textarea) {
lv_obj_add_event_cb(textarea, show_keyboard, LV_EVENT_FOCUSED, nullptr);
lv_obj_add_event_cb(textarea, hide_keyboard, LV_EVENT_DEFOCUSED, nullptr);
lv_obj_add_event_cb(textarea, hide_keyboard, LV_EVENT_READY, nullptr);
// lv_obj_t auto-remove themselves from the group when they are destroyed (last checked in LVGL 8.3)
lv_group_add_obj(keyboardGroup, textarea);
lvgl::software_keyboard_activate(keyboardGroup);
}
// lv_obj_t auto-remove themselves from the group when they are destroyed (last checked in LVGL 8.3)
lv_group_add_obj(keyboardGroup, textarea);
lvgl::software_keyboard_activate(keyboardGroup);
lvgl::unlock();
}