Move UiDensity to lvgl-module and remove some symbols from TactilityC

This commit is contained in:
Ken Van Hoeylandt 2026-02-15 18:04:05 +01:00
parent 6d47488c86
commit ce890d93ca
47 changed files with 208 additions and 164 deletions

View File

@ -21,3 +21,59 @@ function(GET_PROPERTY_FILE_CONTENT PROPERTY_FILE RESULT_VAR)
set(${RESULT_VAR} "${file_content}" PARENT_SCOPE) set(${RESULT_VAR} "${file_content}" PARENT_SCOPE)
endfunction() endfunction()
function(READ_PROPERTIES_TO_MAP PROPERTY_FILE RESULT_VAR)
get_filename_component(PROPERTY_FILE_ABS ${PROPERTY_FILE} ABSOLUTE)
if (NOT EXISTS ${PROPERTY_FILE_ABS})
message(FATAL_ERROR "Property file not found: ${PROPERTY_FILE}")
endif ()
file(STRINGS ${PROPERTY_FILE_ABS} lines)
set(current_section "")
set(map_content "")
foreach(line IN LISTS lines)
string(STRIP "${line}" line)
if (line STREQUAL "" OR line MATCHES "^#")
continue()
endif ()
if (line MATCHES "^\\[.*\\]$")
set(current_section "${line}")
elseif (line MATCHES "^([^=]+)=(.*)$")
set(key "${CMAKE_MATCH_1}")
set(value "${CMAKE_MATCH_2}")
string(STRIP "${key}" key)
string(STRIP "${value}" value)
# Remove optional quotes from value
if (value MATCHES "^\"(.*)\"$")
set(value "${CMAKE_MATCH_1}")
endif ()
list(APPEND map_content "${current_section}${key}" "${value}")
endif ()
endforeach()
set(${RESULT_VAR} "${map_content}" PARENT_SCOPE)
endfunction()
function(GET_VALUE_FROM_MAP MAP_VAR KEY_NAME RESULT_VAR)
list(FIND ${MAP_VAR} "${KEY_NAME}" key_index)
if (key_index EQUAL -1)
set(${RESULT_VAR} "" PARENT_SCOPE)
return()
endif ()
math(EXPR value_index "${key_index} + 1")
list(GET ${MAP_VAR} ${value_index} value)
set(${RESULT_VAR} "${value}" PARENT_SCOPE)
endfunction()
function(KEY_EXISTS_IN_MAP MAP_VAR KEY_NAME RESULT_VAR)
list(FIND ${MAP_VAR} "${KEY_NAME}" key_index)
if (key_index EQUAL -1)
set(${RESULT_VAR} FALSE PARENT_SCOPE)
else ()
set(${RESULT_VAR} TRUE PARENT_SCOPE)
endif ()
endfunction()

View File

@ -44,6 +44,5 @@ static std::vector<std::shared_ptr<tt::hal::Device>> createDevices() {
extern const Configuration hardwareConfiguration = { extern const Configuration hardwareConfiguration = {
.initBoot = initBoot, .initBoot = initBoot,
.uiDensity = UiDensity::Compact,
.createDevices = createDevices .createDevices = createDevices
}; };

View File

@ -26,3 +26,4 @@ infoMessage=Due to the small size of the screen, the icons don't render properly
theme=Mono theme=Mono
colorDepth=16 colorDepth=16
uiScale=70 uiScale=70
uiDensity=compact

View File

@ -19,6 +19,5 @@ static std::vector<std::shared_ptr<tt::hal::Device>> createDevices() {
extern const Configuration hardwareConfiguration = { extern const Configuration hardwareConfiguration = {
.initBoot = initBoot, .initBoot = initBoot,
.uiDensity = UiDensity::Compact,
.createDevices = createDevices .createDevices = createDevices
}; };

View File

@ -20,4 +20,4 @@ dpi=242
[lvgl] [lvgl]
colorDepth=16 colorDepth=16
uiDensity=compact

View File

@ -16,6 +16,5 @@ static std::vector<std::shared_ptr<tt::hal::Device>> createDevices() {
extern const Configuration hardwareConfiguration = { extern const Configuration hardwareConfiguration = {
.initBoot = initBoot, .initBoot = initBoot,
.uiDensity = UiDensity::Compact,
.createDevices = createDevices .createDevices = createDevices
}; };

View File

@ -21,3 +21,4 @@ dpi=186
[lvgl] [lvgl]
colorDepth=16 colorDepth=16
uiDensity=compact

View File

@ -28,6 +28,5 @@ static DeviceVector createDevices() {
extern const Configuration hardwareConfiguration = { extern const Configuration hardwareConfiguration = {
.initBoot = initBoot, .initBoot = initBoot,
.uiDensity = UiDensity::Compact,
.createDevices = createDevices .createDevices = createDevices
}; };

View File

@ -20,3 +20,4 @@ dpi=139
[lvgl] [lvgl]
colorDepth=16 colorDepth=16
uiDensity=compact

View File

@ -26,6 +26,5 @@ static DeviceVector createDevices() {
extern const Configuration hardwareConfiguration = { extern const Configuration hardwareConfiguration = {
.initBoot = initBoot, .initBoot = initBoot,
.uiDensity = UiDensity::Compact,
.createDevices = createDevices .createDevices = createDevices
}; };

View File

@ -20,3 +20,4 @@ dpi=139
[lvgl] [lvgl]
colorDepth=16 colorDepth=16
uiDensity=compact

View File

@ -25,6 +25,5 @@ static DeviceVector createDevices() {
extern const Configuration hardwareConfiguration = { extern const Configuration hardwareConfiguration = {
.initBoot = initBoot, .initBoot = initBoot,
.uiDensity = UiDensity::Compact,
.createDevices = createDevices .createDevices = createDevices
}; };

View File

@ -20,3 +20,4 @@ dpi=242
[lvgl] [lvgl]
colorDepth=16 colorDepth=16
uiDensity=compact

View File

@ -28,6 +28,5 @@ static DeviceVector createDevices() {
extern const Configuration hardwareConfiguration = { extern const Configuration hardwareConfiguration = {
.initBoot = initBoot, .initBoot = initBoot,
.uiDensity = UiDensity::Compact,
.createDevices = createDevices .createDevices = createDevices
}; };

View File

@ -22,3 +22,4 @@ dpi=242
[lvgl] [lvgl]
colorDepth=16 colorDepth=16
uiDensity=compact

View File

@ -0,0 +1,13 @@
[general]
vendor=Simulator
name=Tab5Simulator
[apps]
launcherAppId=Launcher
[hardware]
target=POSIX
[lvgl]
colorDepth=16
fontSize=14

View File

@ -21,6 +21,5 @@ static bool initBoot() {
extern const Configuration hardwareConfiguration = { extern const Configuration hardwareConfiguration = {
.initBoot = initBoot, .initBoot = initBoot,
.uiDensity = UiDensity::Compact,
.createDevices = createDevices .createDevices = createDevices
}; };

View File

@ -23,6 +23,7 @@ dpi=143
[lvgl] [lvgl]
colorDepth=16 colorDepth=16
uiDensity=compact
[sdkconfig] [sdkconfig]
# Fix error "PSRAM space not enough for the Flash instructions" on boot: # Fix error "PSRAM space not enough for the Flash instructions" on boot:

View File

@ -20,6 +20,5 @@ static bool initBoot() {
extern const Configuration hardwareConfiguration = { extern const Configuration hardwareConfiguration = {
.initBoot = initBoot, .initBoot = initBoot,
.uiDensity = UiDensity::Compact,
.createDevices = createDevices .createDevices = createDevices
}; };

View File

@ -23,3 +23,4 @@ dpi=261
[lvgl] [lvgl]
colorDepth=16 colorDepth=16
uiDensity=compact

View File

@ -20,6 +20,5 @@ static bool initBoot() {
extern const Configuration hardwareConfiguration = { extern const Configuration hardwareConfiguration = {
.initBoot = initBoot, .initBoot = initBoot,
.uiDensity = UiDensity::Compact,
.createDevices = createDevices .createDevices = createDevices
}; };

View File

@ -23,6 +23,7 @@ dpi=265
[lvgl] [lvgl]
colorDepth=16 colorDepth=16
uiDensity=compact
[sdkconfig] [sdkconfig]
# Fix error "PSRAM space not enough for the Flash instructions" on boot: # Fix error "PSRAM space not enough for the Flash instructions" on boot:

View File

@ -16,6 +16,5 @@ static std::vector<std::shared_ptr<tt::hal::Device>> createDevices() {
extern const Configuration hardwareConfiguration = { extern const Configuration hardwareConfiguration = {
.initBoot = initBoot, .initBoot = initBoot,
.uiDensity = UiDensity::Compact,
.createDevices = createDevices .createDevices = createDevices
}; };

View File

@ -26,3 +26,4 @@ warningMessage=Touch doesn't work yet
[lvgl] [lvgl]
colorDepth=16 colorDepth=16
uiDensity=compact

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.20) cmake_minimum_required(VERSION 3.20)
# #################################### # ####################################
# Read properties # Read sdkconfig properties
# #################################### # ####################################
include("${CMAKE_CURRENT_LIST_DIR}/../../Buildscripts/properties.cmake") include("${CMAKE_CURRENT_LIST_DIR}/../../Buildscripts/properties.cmake")
@ -14,6 +14,7 @@ if (DEFINED ENV{ESP_IDF_VERSION})
GET_PROPERTY_VALUE(sdkconfig_text "CONFIG_TT_LVGL_STATUSBAR_ICON_SIZE" statusbar_symbol_size) GET_PROPERTY_VALUE(sdkconfig_text "CONFIG_TT_LVGL_STATUSBAR_ICON_SIZE" statusbar_symbol_size)
GET_PROPERTY_VALUE(sdkconfig_text "CONFIG_TT_LVGL_LAUNCHER_ICON_SIZE" launcher_symbol_size) GET_PROPERTY_VALUE(sdkconfig_text "CONFIG_TT_LVGL_LAUNCHER_ICON_SIZE" launcher_symbol_size)
GET_PROPERTY_VALUE(sdkconfig_text "CONFIG_TT_LVGL_SHARED_ICON_SIZE" shared_symbol_size) GET_PROPERTY_VALUE(sdkconfig_text "CONFIG_TT_LVGL_SHARED_ICON_SIZE" shared_symbol_size)
GET_PROPERTY_VALUE(sdkconfig_text "CONFIG_TT_LVGL_SHARED_ICON_SIZE" shared_symbol_size)
else () else ()
# Default values for simulator # Default values for simulator
set(font_size_small 10) set(font_size_small 10)
@ -33,6 +34,31 @@ message(" - statusbar: ${statusbar_symbol_size}")
message(" - launcher: ${launcher_symbol_size}") message(" - launcher: ${launcher_symbol_size}")
message(" - shared: ${shared_symbol_size}") message(" - shared: ${shared_symbol_size}")
# ####################################
# Read device properties
# ####################################
# Load device.properties as a map
get_property(TACTILITY_DEVICE_ID GLOBAL PROPERTY TACTILITY_DEVICE_ID)
READ_PROPERTIES_TO_MAP(
"${CMAKE_CURRENT_LIST_DIR}/../../Devices/${TACTILITY_DEVICE_ID}/device.properties"
device_properties
)
# Read UI density
GET_VALUE_FROM_MAP(device_properties "[lvgl]uiDensity" ui_density)
# Define UiDensity enum value
if (ui_scale)
if (ui_scale == "normal")
set(ui_density "LVGL_UI_DENSITY_DEFAULT")
elif (ui_scale == "compact")
set(ui_density "LVGL_UI_DENSITY_COMPACT")
else ()
message(FATAL_ERROR "Invalid [lvgl]uiDensity: '${ui_density}'. Must be either 'default' or 'compact'")
endif ()
else ()
set(ui_density "LVGL_UI_DENSITY_DEFAULT")
endif ()
# #################################### # ####################################
# Create module # Create module
# #################################### # ####################################
@ -66,17 +92,22 @@ tactility_add_module(lvgl-module
tactility_get_module_name("lvgl-module" MODULE_NAME) tactility_get_module_name("lvgl-module" MODULE_NAME)
target_compile_definitions(${MODULE_NAME} PUBLIC target_compile_definitions(${MODULE_NAME} PUBLIC
# Ensure it loads <lvgl.h>
"-DLV_LVGL_H_INCLUDE_SIMPLE" "-DLV_LVGL_H_INCLUDE_SIMPLE"
# Text fonts
"-DTT_LVGL_TEXT_FONT_SMALL_SIZE=${font_size_small}" "-DTT_LVGL_TEXT_FONT_SMALL_SIZE=${font_size_small}"
"-DTT_LVGL_TEXT_FONT_SMALL_SYMBOL=lv_font_montserrat_${font_size_small}" "-DTT_LVGL_TEXT_FONT_SMALL_SYMBOL=lv_font_montserrat_${font_size_small}"
"-DTT_LVGL_TEXT_FONT_DEFAULT_SIZE=${font_size_default}" "-DTT_LVGL_TEXT_FONT_DEFAULT_SIZE=${font_size_default}"
"-DTT_LVGL_TEXT_FONT_DEFAULT_SYMBOL=lv_font_montserrat_${font_size_default}" "-DTT_LVGL_TEXT_FONT_DEFAULT_SYMBOL=lv_font_montserrat_${font_size_default}"
"-DTT_LVGL_TEXT_FONT_LARGE_SIZE=${font_size_large}" "-DTT_LVGL_TEXT_FONT_LARGE_SIZE=${font_size_large}"
"-DTT_LVGL_TEXT_FONT_LARGE_SYMBOL=lv_font_montserrat_${font_size_large}" "-DTT_LVGL_TEXT_FONT_LARGE_SYMBOL=lv_font_montserrat_${font_size_large}"
# Icon fonts
"-DTT_LVGL_STATUSBAR_FONT_ICON_SIZE=${statusbar_symbol_size}" "-DTT_LVGL_STATUSBAR_FONT_ICON_SIZE=${statusbar_symbol_size}"
"-DTT_LVGL_STATUSBAR_FONT_ICON_SYMBOL=material_symbols_statusbar_${statusbar_symbol_size}" "-DTT_LVGL_STATUSBAR_FONT_ICON_SYMBOL=material_symbols_statusbar_${statusbar_symbol_size}"
"-DTT_LVGL_LAUNCHER_FONT_ICON_SIZE=${launcher_symbol_size}" "-DTT_LVGL_LAUNCHER_FONT_ICON_SIZE=${launcher_symbol_size}"
"-DTT_LVGL_LAUNCHER_FONT_ICON_SYMBOL=material_symbols_launcher_${launcher_symbol_size}" "-DTT_LVGL_LAUNCHER_FONT_ICON_SYMBOL=material_symbols_launcher_${launcher_symbol_size}"
"-DTT_LVGL_SHARED_FONT_ICON_SIZE=${shared_symbol_size}" "-DTT_LVGL_SHARED_FONT_ICON_SIZE=${shared_symbol_size}"
"-DTT_LVGL_SHARED_FONT_ICON_SYMBOL=material_symbols_shared_${shared_symbol_size}" "-DTT_LVGL_SHARED_FONT_ICON_SYMBOL=material_symbols_shared_${shared_symbol_size}"
# UiDensity
"-DTT_LVGL_UI_DENSITY=${ui_density}"
) )

View File

@ -16,6 +16,14 @@ extern "C" {
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
/** Affects LVGL widget style */
enum UiDensity {
/** Ideal for very small non-touch screen devices (e.g. Waveshare S3 LCD 1.3") */
LVGL_UI_DENSITY_COMPACT,
/** Nothing was changed in the LVGL UI/UX */
LVGL_UI_DENSITY_DEFAULT
};
/** /**
* @brief The LVGL module instance. * @brief The LVGL module instance.
*/ */
@ -86,6 +94,14 @@ void lvgl_unlock(void);
*/ */
bool lvgl_is_running(void); bool lvgl_is_running(void);
/**
* @brief Gets the desired UI density for the target hardware.
* The density is defined in the `device.properties` of a hardware device.
* This setting is read by CMakeLists.txt and passed as a target compile definition of the LVLG module.
* @return the UI density
*/
enum UiDensity lvgl_get_ui_density(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -10,7 +10,7 @@
#include <lvgl.h> #include <lvgl.h>
#include "tactility/lvgl_module.h" #include <tactility/lvgl_module.h>
extern struct LvglModuleConfig lvgl_module_config; extern struct LvglModuleConfig lvgl_module_config;

View File

@ -60,6 +60,10 @@ bool lvgl_is_running() {
return is_running; return is_running;
} }
enum UiDensity lvgl_get_ui_density(void) {
return TT_LVGL_UI_DENSITY;
}
struct Module lvgl_module = { struct Module lvgl_module = {
.name = "lvgl", .name = "lvgl",
.start = start, .start = start,

View File

@ -11,6 +11,7 @@ const struct ModuleSymbol lvgl_module_symbols[] = {
DEFINE_MODULE_SYMBOL(lvgl_try_lock), DEFINE_MODULE_SYMBOL(lvgl_try_lock),
DEFINE_MODULE_SYMBOL(lvgl_unlock), DEFINE_MODULE_SYMBOL(lvgl_unlock),
DEFINE_MODULE_SYMBOL(lvgl_is_running), DEFINE_MODULE_SYMBOL(lvgl_is_running),
DEFINE_MODULE_SYMBOL(lvgl_get_ui_density),
// lvgl_fonts // lvgl_fonts
DEFINE_MODULE_SYMBOL(lvgl_get_shared_icon_font), DEFINE_MODULE_SYMBOL(lvgl_get_shared_icon_font),
DEFINE_MODULE_SYMBOL(lvgl_get_shared_icon_font_height), DEFINE_MODULE_SYMBOL(lvgl_get_shared_icon_font_height),

View File

@ -12,23 +12,12 @@ typedef std::vector<std::shared_ptr<Device>> DeviceVector;
typedef std::shared_ptr<Device> (*CreateDevice)(); typedef std::shared_ptr<Device> (*CreateDevice)();
/** Affects LVGL widget style */
enum class UiDensity {
/** Ideal for very small non-touch screen devices (e.g. Waveshare S3 LCD 1.3") */
Compact,
/** Nothing was changed in the LVGL UI/UX */
Default
};
struct Configuration { struct Configuration {
/** /**
* Used for powering on the peripherals manually. * Used for powering on the peripherals manually.
*/ */
const InitBoot initBoot = nullptr; const InitBoot initBoot = nullptr;
/** Modify LVGL widget size */
const UiDensity uiDensity = UiDensity::Default;
const std::function<DeviceVector()> createDevices = [] { return DeviceVector(); }; const std::function<DeviceVector()> createDevices = [] { return DeviceVector(); };
}; };

View File

@ -12,6 +12,7 @@
#include <Tactility/settings/DisplaySettings.h> #include <Tactility/settings/DisplaySettings.h>
#include <lvgl.h> #include <lvgl.h>
#include <tactility/lvgl_module.h>
namespace tt::app::display { namespace tt::app::display {
@ -122,7 +123,7 @@ public:
void onShow(AppContext& app, lv_obj_t* parent) override { void onShow(AppContext& app, lv_obj_t* parent) override {
displaySettings = settings::display::loadOrGetDefault(); displaySettings = settings::display::loadOrGetDefault();
auto ui_density = hal::getConfiguration()->uiDensity; auto ui_density = lvgl_get_ui_density();
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT); lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT);
@ -144,7 +145,7 @@ public:
lv_obj_set_size(brightness_wrapper, LV_PCT(100), LV_SIZE_CONTENT); lv_obj_set_size(brightness_wrapper, LV_PCT(100), LV_SIZE_CONTENT);
lv_obj_set_style_pad_hor(brightness_wrapper, 0, LV_STATE_DEFAULT); lv_obj_set_style_pad_hor(brightness_wrapper, 0, LV_STATE_DEFAULT);
lv_obj_set_style_border_width(brightness_wrapper, 0, LV_STATE_DEFAULT); lv_obj_set_style_border_width(brightness_wrapper, 0, LV_STATE_DEFAULT);
if (ui_density != hal::UiDensity::Compact) { if (ui_density != LVGL_UI_DENSITY_COMPACT) {
lv_obj_set_style_pad_ver(brightness_wrapper, 4, LV_STATE_DEFAULT); lv_obj_set_style_pad_ver(brightness_wrapper, 4, LV_STATE_DEFAULT);
} }
@ -168,7 +169,7 @@ public:
lv_obj_set_size(gamma_wrapper, LV_PCT(100), LV_SIZE_CONTENT); lv_obj_set_size(gamma_wrapper, LV_PCT(100), LV_SIZE_CONTENT);
lv_obj_set_style_pad_hor(gamma_wrapper, 0, LV_STATE_DEFAULT); lv_obj_set_style_pad_hor(gamma_wrapper, 0, LV_STATE_DEFAULT);
lv_obj_set_style_border_width(gamma_wrapper, 0, LV_STATE_DEFAULT); lv_obj_set_style_border_width(gamma_wrapper, 0, LV_STATE_DEFAULT);
if (ui_density != hal::UiDensity::Compact) { if (ui_density != LVGL_UI_DENSITY_COMPACT) {
lv_obj_set_style_pad_ver(gamma_wrapper, 4, LV_STATE_DEFAULT); lv_obj_set_style_pad_ver(gamma_wrapper, 4, LV_STATE_DEFAULT);
} }

View File

@ -12,13 +12,14 @@
#include <tactility/lvgl_fonts.h> #include <tactility/lvgl_fonts.h>
#include <tactility/lvgl_icon_launcher.h> #include <tactility/lvgl_icon_launcher.h>
#include <tactility/lvgl_module.h>
namespace tt::app::launcher { namespace tt::app::launcher {
static const auto LOGGER = Logger("Launcher"); static const auto LOGGER = Logger("Launcher");
static uint32_t getButtonPadding(hal::UiDensity density, uint32_t buttonSize) { static uint32_t getButtonPadding(UiDensity density, uint32_t buttonSize) {
if (density == hal::UiDensity::Compact) { if (density == LVGL_UI_DENSITY_COMPACT) {
return 0; return 0;
} else { } else {
return buttonSize / 8; return buttonSize / 8;
@ -27,7 +28,7 @@ static uint32_t getButtonPadding(hal::UiDensity density, uint32_t buttonSize) {
class LauncherApp final : public App { class LauncherApp final : public App {
static lv_obj_t* createAppButton(lv_obj_t* parent, hal::UiDensity uiDensity, const char* imageFile, const char* appId, int32_t itemMargin, bool isLandscape) { static lv_obj_t* createAppButton(lv_obj_t* parent, UiDensity uiDensity, const char* imageFile, const char* appId, int32_t itemMargin, bool isLandscape) {
const auto button_size = lvgl_get_launcher_icon_font_height(); const auto button_size = lvgl_get_launcher_icon_font_height();
const auto button_padding = getButtonPadding(uiDensity, button_size); const auto button_padding = getButtonPadding(uiDensity, button_size);
auto* apps_button = lv_button_create(parent); auto* apps_button = lv_button_create(parent);
@ -119,7 +120,7 @@ public:
void onShow(AppContext& app, lv_obj_t* parent) override { void onShow(AppContext& app, lv_obj_t* parent) override {
auto* buttons_wrapper = lv_obj_create(parent); auto* buttons_wrapper = lv_obj_create(parent);
auto ui_density = hal::getConfiguration()->uiDensity; auto ui_density = lvgl_get_ui_density();
const auto button_size = lvgl_get_launcher_icon_font_height(); const auto button_size = lvgl_get_launcher_icon_font_height();
const auto button_padding = getButtonPadding(ui_density, button_size); const auto button_padding = getButtonPadding(ui_density, button_size);
const auto total_button_size = button_size + (button_padding * 2); const auto total_button_size = button_size + (button_padding * 2);

View File

@ -1,19 +1,20 @@
#include <Tactility/TactilityConfig.h> #include <Tactility/TactilityConfig.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h> #include <Tactility/lvgl/Toolbar.h>
#include <Tactility/hal/sdcard/SdCardDevice.h> #include <Tactility/hal/sdcard/SdCardDevice.h>
#include <Tactility/Tactility.h> #include <Tactility/Tactility.h>
#include <Tactility/Timer.h> #include <Tactility/Timer.h>
#include <algorithm> #include <algorithm>
#include <cstring>
#include <format> #include <format>
#include <lvgl.h> #include <lvgl.h>
#include <tactility/lvgl_fonts.h>
#include <tactility/hal/Device.h>
#include <tactility/lvgl_icon_shared.h>
#include <utility> #include <utility>
#include <cstring>
#include <tactility/hal/Device.h>
#include <tactility/lvgl_fonts.h>
#include <tactility/lvgl_icon_shared.h>
#include <tactility/lvgl_module.h>
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
#include <esp_vfs_fat.h> #include <esp_vfs_fat.h>
@ -150,7 +151,7 @@ static MemoryBarWidgets createMemoryBar(lv_obj_t* parent, const char* label) {
lv_obj_set_width(bottom_label, LV_PCT(100)); 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_text_align(bottom_label, LV_TEXT_ALIGN_RIGHT, 0);
if (hal::getConfiguration()->uiDensity == hal::UiDensity::Compact) { if (lvgl_get_ui_density() == LVGL_UI_DENSITY_COMPACT) {
lv_obj_set_style_pad_bottom(bottom_label, 2, LV_STATE_DEFAULT); lv_obj_set_style_pad_bottom(bottom_label, 2, LV_STATE_DEFAULT);
} else { } else {
lv_obj_set_style_pad_bottom(bottom_label, 12, LV_STATE_DEFAULT); lv_obj_set_style_pad_bottom(bottom_label, 12, LV_STATE_DEFAULT);

View File

@ -1,13 +1,13 @@
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
#include <Tactility/Tactility.h>
#include <Tactility/settings/TrackballSettings.h>
#include <Tactility/lvgl/Toolbar.h>
#include <lvgl.h> #include <lvgl.h>
#include <tactility/lvgl_icon_shared.h> #include <tactility/lvgl_icon_shared.h>
#include <tactility/lvgl_module.h>
#include <Tactility/Tactility.h>
#include <Tactility/settings/TrackballSettings.h>
#include <Tactility/lvgl/Toolbar.h>
// Forward declare driver functions // Forward declare driver functions
namespace trackball { namespace trackball {
@ -109,7 +109,7 @@ class TrackballSettingsApp final : public App {
public: public:
void onShow(AppContext& app, lv_obj_t* parent) override { void onShow(AppContext& app, lv_obj_t* parent) override {
tbSettings = settings::trackball::loadOrGetDefault(); tbSettings = settings::trackball::loadOrGetDefault();
auto ui_density = hal::getConfiguration()->uiDensity; auto ui_density = lvgl_get_ui_density();
updated = false; updated = false;
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
@ -154,7 +154,7 @@ public:
lv_obj_set_size(enc_sens_wrapper, LV_PCT(100), LV_SIZE_CONTENT); lv_obj_set_size(enc_sens_wrapper, LV_PCT(100), LV_SIZE_CONTENT);
lv_obj_set_style_pad_hor(enc_sens_wrapper, 0, LV_STATE_DEFAULT); lv_obj_set_style_pad_hor(enc_sens_wrapper, 0, LV_STATE_DEFAULT);
lv_obj_set_style_border_width(enc_sens_wrapper, 0, LV_STATE_DEFAULT); lv_obj_set_style_border_width(enc_sens_wrapper, 0, LV_STATE_DEFAULT);
if (ui_density != hal::UiDensity::Compact) { if (ui_density != LVGL_UI_DENSITY_COMPACT) {
lv_obj_set_style_pad_ver(enc_sens_wrapper, 4, LV_STATE_DEFAULT); lv_obj_set_style_pad_ver(enc_sens_wrapper, 4, LV_STATE_DEFAULT);
} }
@ -178,7 +178,7 @@ public:
lv_obj_set_size(ptr_sens_wrapper, LV_PCT(100), LV_SIZE_CONTENT); lv_obj_set_size(ptr_sens_wrapper, LV_PCT(100), LV_SIZE_CONTENT);
lv_obj_set_style_pad_hor(ptr_sens_wrapper, 0, LV_STATE_DEFAULT); lv_obj_set_style_pad_hor(ptr_sens_wrapper, 0, LV_STATE_DEFAULT);
lv_obj_set_style_border_width(ptr_sens_wrapper, 0, LV_STATE_DEFAULT); lv_obj_set_style_border_width(ptr_sens_wrapper, 0, LV_STATE_DEFAULT);
if (ui_density != hal::UiDensity::Compact) { if (ui_density != LVGL_UI_DENSITY_COMPACT) {
lv_obj_set_style_pad_ver(ptr_sens_wrapper, 4, LV_STATE_DEFAULT); lv_obj_set_style_pad_ver(ptr_sens_wrapper, 4, LV_STATE_DEFAULT);
} }

View File

@ -1,5 +1,10 @@
#include <Tactility/network/HttpdReq.h> #include <format>
#include <string>
#include <set>
#include <tactility/lvgl_module.h>
#include <Tactility/network/HttpdReq.h>
#include <Tactility/app/wifimanage/View.h> #include <Tactility/app/wifimanage/View.h>
#include <Tactility/app/wifimanage/WifiManagePrivate.h> #include <Tactility/app/wifimanage/WifiManagePrivate.h>
#include <Tactility/Logger.h> #include <Tactility/Logger.h>
@ -9,10 +14,6 @@
#include <Tactility/service/wifi/WifiSettings.h> #include <Tactility/service/wifi/WifiSettings.h>
#include <Tactility/Tactility.h> #include <Tactility/Tactility.h>
#include <format>
#include <string>
#include <set>
namespace tt::app::wifimanage { namespace tt::app::wifimanage {
static const auto LOGGER = Logger("WifiManageView"); static const auto LOGGER = Logger("WifiManageView");
@ -162,7 +163,7 @@ void View::updateNetworkList() {
lv_obj_add_event_cb(enable_on_boot_switch, onEnableOnBootSwitchChanged, LV_EVENT_VALUE_CHANGED, bindings); lv_obj_add_event_cb(enable_on_boot_switch, onEnableOnBootSwitchChanged, LV_EVENT_VALUE_CHANGED, bindings);
lv_obj_add_event_cb(enable_on_boot_wrapper, onEnableOnBootParentClicked, LV_EVENT_SHORT_CLICKED, enable_on_boot_switch); lv_obj_add_event_cb(enable_on_boot_wrapper, onEnableOnBootParentClicked, LV_EVENT_SHORT_CLICKED, enable_on_boot_switch);
if (hal::getConfiguration()->uiDensity == hal::UiDensity::Compact) { if (lvgl_get_ui_density() == LVGL_UI_DENSITY_COMPACT) {
lv_obj_set_style_pad_ver(enable_on_boot_wrapper, 2, LV_STATE_DEFAULT); lv_obj_set_style_pad_ver(enable_on_boot_wrapper, 2, LV_STATE_DEFAULT);
} else { } else {
lv_obj_set_style_pad_ver(enable_on_boot_wrapper, 8, LV_STATE_DEFAULT); lv_obj_set_style_pad_ver(enable_on_boot_wrapper, 8, LV_STATE_DEFAULT);

View File

@ -14,6 +14,7 @@
#include <tactility/check.h> #include <tactility/check.h>
#include <tactility/lvgl_fonts.h> #include <tactility/lvgl_fonts.h>
#include <tactility/lvgl_module.h>
#include <lvgl.h> #include <lvgl.h>
@ -172,8 +173,8 @@ lv_obj_t* statusbar_create(lv_obj_t* parent) {
lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_ROW); lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_ROW);
lv_obj_set_flex_align(obj, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); lv_obj_set_flex_align(obj, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
auto icon_size = lvgl_get_statusbar_icon_font_height(); auto icon_size = lvgl_get_statusbar_icon_font_height();
auto ui_density = hal::getConfiguration()->uiDensity; auto ui_density = lvgl_get_ui_density();
auto icon_padding = (ui_density != hal::UiDensity::Compact) ? static_cast<uint32_t>(icon_size * 0.2f) : 2; auto icon_padding = (ui_density != LVGL_UI_DENSITY_COMPACT) ? static_cast<uint32_t>(icon_size * 0.2f) : 2;
lv_obj_set_style_pad_column(obj, icon_padding, LV_STATE_DEFAULT); lv_obj_set_style_pad_column(obj, icon_padding, LV_STATE_DEFAULT);
statusbar->time = lv_label_create(obj); statusbar->time = lv_label_create(obj);

View File

@ -2,41 +2,43 @@
#include <Tactility/Tactility.h> #include <Tactility/Tactility.h>
#include <Tactility/lvgl/Toolbar.h> #include <Tactility/lvgl/Toolbar.h>
#include <Tactility/lvgl/Spinner.h> #include <Tactility/lvgl/Spinner.h>
#include <Tactility/service/loader/Loader.h> #include <Tactility/service/loader/Loader.h>
#include <tactility/check.h> #include <tactility/check.h>
#include <tactility/lvgl_fonts.h> #include <tactility/lvgl_fonts.h>
#include <tactility/lvgl_module.h>
namespace tt::lvgl { namespace tt::lvgl {
static uint32_t getToolbarHeight(hal::UiDensity uiDensity) { static uint32_t getToolbarHeight(UiDensity uiDensity) {
if (uiDensity == hal::UiDensity::Compact) { if (uiDensity == LVGL_UI_DENSITY_COMPACT) {
return lvgl_get_text_font_height(FONT_SIZE_DEFAULT) * 1.4f; return lvgl_get_text_font_height(FONT_SIZE_DEFAULT) * 1.4f;
} else { } else {
return lvgl_get_text_font_height(FONT_SIZE_LARGE) * 2.2f; return lvgl_get_text_font_height(FONT_SIZE_LARGE) * 2.2f;
} }
} }
static const _lv_font_t* getToolbarFont(hal::UiDensity uiDensity) { static const _lv_font_t* getToolbarFont(UiDensity uiDensity) {
if (uiDensity == hal::UiDensity::Compact) { if (uiDensity == LVGL_UI_DENSITY_COMPACT) {
return lvgl_get_text_font(FONT_SIZE_DEFAULT); return lvgl_get_text_font(FONT_SIZE_DEFAULT);
} else { } else {
return lvgl_get_text_font(FONT_SIZE_LARGE); return lvgl_get_text_font(FONT_SIZE_LARGE);
} }
} }
static uint32_t getActionIconPadding(hal::UiDensity ui_density) { static uint32_t getActionIconPadding(UiDensity uiDensity) {
auto toolbar_height = getToolbarHeight(ui_density); auto toolbar_height = getToolbarHeight(uiDensity);
// Minimal 8 pixels total padding for selection/animation (4+4 pixels) // Minimal 8 pixels total padding for selection/animation (4+4 pixels)
return (ui_density != hal::UiDensity::Compact) ? (uint32_t)(toolbar_height * 0.2f) : 8; return (uiDensity != LVGL_UI_DENSITY_COMPACT) ? (uint32_t)(toolbar_height * 0.2f) : 8;
} }
/** /**
* Helps with button expansion and also with vertical alignment of content, * Helps with button expansion and also with vertical alignment of content,
* as the parent flex doesn't allow for vertical alignment * as the parent flex doesn't allow for vertical alignment
*/ */
static lv_obj_t* create_action_wrapper(lv_obj_t* parent, hal::UiDensity ui_density) { static lv_obj_t* create_action_wrapper(lv_obj_t* parent, UiDensity ui_density) {
auto* wrapper = lv_obj_create(parent); auto* wrapper = lv_obj_create(parent);
auto toolbar_height = getToolbarHeight(ui_density); auto toolbar_height = getToolbarHeight(ui_density);
lv_obj_set_size(wrapper, LV_SIZE_CONTENT, toolbar_height); lv_obj_set_size(wrapper, LV_SIZE_CONTENT, toolbar_height);
@ -89,7 +91,7 @@ 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_obj_t* toolbar_create(lv_obj_t* parent, const std::string& title) {
auto ui_density = hal::getConfiguration()->uiDensity; auto ui_density = lvgl_get_ui_density();
auto toolbar_height = getToolbarHeight(ui_density); auto toolbar_height = getToolbarHeight(ui_density);
toolbar_class.height_def = toolbar_height; toolbar_class.height_def = toolbar_height;
lv_obj_t* obj = lv_obj_class_create_obj(&toolbar_class, parent); lv_obj_t* obj = lv_obj_class_create_obj(&toolbar_class, parent);
@ -109,7 +111,7 @@ lv_obj_t* toolbar_create(lv_obj_t* parent, const std::string& title) {
auto* close_button_wrapper = create_action_wrapper(obj, ui_density); auto* close_button_wrapper = create_action_wrapper(obj, ui_density);
toolbar->close_button = lv_button_create(close_button_wrapper); toolbar->close_button = lv_button_create(close_button_wrapper);
if (ui_density == hal::UiDensity::Compact) { 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_style_bg_opa(toolbar->close_button, LV_OPA_TRANSP, LV_STATE_DEFAULT);
} }
@ -121,8 +123,8 @@ lv_obj_t* toolbar_create(lv_obj_t* parent, const std::string& title) {
lv_obj_align(toolbar->close_button_image, LV_ALIGN_CENTER, 0, 0); lv_obj_align(toolbar->close_button_image, LV_ALIGN_CENTER, 0, 0);
auto* title_wrapper = lv_obj_create(obj); auto* title_wrapper = lv_obj_create(obj);
uint32_t title_left_padding = (ui_density != hal::UiDensity::Compact) ? icon_padding : 2; uint32_t title_left_padding = (ui_density != LVGL_UI_DENSITY_COMPACT) ? icon_padding : 2;
uint32_t title_right_padding = (ui_density != hal::UiDensity::Compact) ? (icon_padding / 2) : 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_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_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_left(title_wrapper, title_left_padding, LV_STATE_DEFAULT);
@ -179,7 +181,7 @@ lv_obj_t* toolbar_add_button_action(lv_obj_t* obj, const char* imageOrButton, bo
check(toolbar->action_count < TOOLBAR_ACTION_LIMIT, "max actions reached"); check(toolbar->action_count < TOOLBAR_ACTION_LIMIT, "max actions reached");
toolbar->action_count++; toolbar->action_count++;
auto ui_density = hal::getConfiguration()->uiDensity; auto ui_density = lvgl_get_ui_density();
auto toolbar_height = getToolbarHeight(ui_density); auto toolbar_height = getToolbarHeight(ui_density);
auto* wrapper = create_action_wrapper(toolbar->action_container, ui_density); auto* wrapper = create_action_wrapper(toolbar->action_container, ui_density);
@ -190,7 +192,7 @@ lv_obj_t* toolbar_add_button_action(lv_obj_t* obj, const char* imageOrButton, bo
lv_obj_set_size(action_button, toolbar_height - padding, toolbar_height - padding); 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_set_style_pad_all(action_button, 0, LV_STATE_DEFAULT);
lv_obj_align(action_button, LV_ALIGN_CENTER, 0, 0); lv_obj_align(action_button, LV_ALIGN_CENTER, 0, 0);
if (ui_density == hal::UiDensity::Compact) { if (ui_density == LVGL_UI_DENSITY_COMPACT) {
lv_obj_set_style_bg_opa(action_button, LV_OPA_TRANSP, LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(action_button, LV_OPA_TRANSP, LV_STATE_DEFAULT);
} }
@ -219,7 +221,7 @@ lv_obj_t* toolbar_add_text_button_action(lv_obj_t* obj, const char* text, lv_eve
lv_obj_t* toolbar_add_switch_action(lv_obj_t* obj) { lv_obj_t* toolbar_add_switch_action(lv_obj_t* obj) {
auto* toolbar = reinterpret_cast<Toolbar*>(obj); auto* toolbar = reinterpret_cast<Toolbar*>(obj);
auto ui_density = hal::getConfiguration()->uiDensity; auto ui_density = lvgl_get_ui_density();
auto* wrapper = create_action_wrapper(toolbar->action_container, 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_set_style_pad_hor(wrapper, 4, LV_STATE_DEFAULT);
@ -231,7 +233,7 @@ lv_obj_t* toolbar_add_switch_action(lv_obj_t* obj) {
lv_obj_t* toolbar_add_spinner_action(lv_obj_t* obj) { lv_obj_t* toolbar_add_spinner_action(lv_obj_t* obj) {
auto* toolbar = reinterpret_cast<Toolbar*>(obj); auto* toolbar = reinterpret_cast<Toolbar*>(obj);
auto ui_density = hal::getConfiguration()->uiDensity; auto ui_density = lvgl_get_ui_density();
auto* wrapper = create_action_wrapper(toolbar->action_container, ui_density); auto* wrapper = create_action_wrapper(toolbar->action_container, ui_density);
auto* spinner = spinner_create(wrapper); auto* spinner = spinner_create(wrapper);

View File

@ -1,9 +1,9 @@
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
#include <Tactility/Tactility.h>
#include <lvgl.h> #include <lvgl.h>
#include <tactility/lvgl_module.h>
extern "C" { extern "C" {
extern lv_obj_t* __real_lv_button_create(lv_obj_t* parent); extern lv_obj_t* __real_lv_button_create(lv_obj_t* parent);
@ -11,7 +11,7 @@ extern lv_obj_t* __real_lv_button_create(lv_obj_t* parent);
lv_obj_t* __wrap_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); auto button = __real_lv_button_create(parent);
if (tt::hal::getConfiguration()->uiDensity == tt::hal::UiDensity::Compact) { if (lvgl_get_ui_density() == LVGL_UI_DENSITY_COMPACT) {
lv_obj_set_style_pad_all(button, 2, LV_STATE_DEFAULT); lv_obj_set_style_pad_all(button, 2, LV_STATE_DEFAULT);
lv_obj_set_style_radius(button, 3, LV_STATE_DEFAULT); lv_obj_set_style_radius(button, 3, LV_STATE_DEFAULT);
} }

View File

@ -1,9 +1,9 @@
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
#include <Tactility/Tactility.h>
#include <lvgl.h> #include <lvgl.h>
#include <tactility/lvgl_module.h>
extern "C" { extern "C" {
extern lv_obj_t* __real_lv_dropdown_create(lv_obj_t* parent); extern lv_obj_t* __real_lv_dropdown_create(lv_obj_t* parent);
@ -11,7 +11,7 @@ extern lv_obj_t* __real_lv_dropdown_create(lv_obj_t* parent);
lv_obj_t* __wrap_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); auto dropdown = __real_lv_dropdown_create(parent);
if (tt::hal::getConfiguration()->uiDensity == tt::hal::UiDensity::Compact) { if (lvgl_get_ui_density() == LVGL_UI_DENSITY_COMPACT) {
lv_obj_set_style_pad_all(dropdown, 2, LV_STATE_DEFAULT); lv_obj_set_style_pad_all(dropdown, 2, LV_STATE_DEFAULT);
} }

View File

@ -1,9 +1,9 @@
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
#include <Tactility/Tactility.h>
#include <lvgl.h> #include <lvgl.h>
#include <tactility/lvgl_module.h>
extern "C" { extern "C" {
extern lv_obj_t* __real_lv_list_create(lv_obj_t* parent); extern lv_obj_t* __real_lv_list_create(lv_obj_t* parent);
@ -12,7 +12,7 @@ extern lv_obj_t* __real_lv_list_add_button(lv_obj_t* list, const void* icon, con
lv_obj_t* __wrap_lv_list_create(lv_obj_t* parent) { lv_obj_t* __wrap_lv_list_create(lv_obj_t* parent) {
auto* list = __real_lv_list_create(parent); auto* list = __real_lv_list_create(parent);
if (tt::hal::getConfiguration()->uiDensity == tt::hal::UiDensity::Compact) { if (lvgl_get_ui_density() == LVGL_UI_DENSITY_COMPACT) {
lv_obj_set_style_pad_row(list, 2, LV_STATE_DEFAULT); lv_obj_set_style_pad_row(list, 2, LV_STATE_DEFAULT);
lv_obj_set_style_pad_column(list, 2, LV_STATE_DEFAULT); lv_obj_set_style_pad_column(list, 2, LV_STATE_DEFAULT);
lv_obj_set_style_pad_all(list, 2, LV_STATE_DEFAULT); lv_obj_set_style_pad_all(list, 2, LV_STATE_DEFAULT);
@ -24,7 +24,7 @@ lv_obj_t* __wrap_lv_list_create(lv_obj_t* parent) {
lv_obj_t* __wrap_lv_list_add_button(lv_obj_t* list, const void* icon, const char* txt) { 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); auto* button = __real_lv_list_add_button(list, icon, txt);
if (tt::hal::getConfiguration()->uiDensity == tt::hal::UiDensity::Compact) { if (lvgl_get_ui_density() == LVGL_UI_DENSITY_COMPACT) {
lv_obj_set_style_pad_ver(button, 2, LV_STATE_DEFAULT); lv_obj_set_style_pad_ver(button, 2, LV_STATE_DEFAULT);
} }

View File

@ -1,9 +1,9 @@
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
#include <Tactility/Tactility.h>
#include <lvgl.h> #include <lvgl.h>
#include <tactility/lvgl_module.h>
extern "C" { extern "C" {
extern void __real_lv_obj_set_flex_flow(lv_obj_t* obj, lv_flex_flow_t flow); extern void __real_lv_obj_set_flex_flow(lv_obj_t* obj, lv_flex_flow_t flow);
@ -12,14 +12,14 @@ 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) { void __wrap_lv_obj_set_flex_flow(lv_obj_t* obj, lv_flex_flow_t flow) {
__real_lv_obj_set_flex_flow(obj, flow); __real_lv_obj_set_flex_flow(obj, flow);
if (tt::hal::getConfiguration()->uiDensity == tt::hal::UiDensity::Compact) { if (lvgl_get_ui_density() == LVGL_UI_DENSITY_COMPACT) {
lv_obj_set_style_pad_gap(obj, 4, LV_STATE_DEFAULT); lv_obj_set_style_pad_gap(obj, 4, LV_STATE_DEFAULT);
} }
} }
lv_obj_t* __wrap_lv_obj_create(lv_obj_t* parent) { lv_obj_t* __wrap_lv_obj_create(lv_obj_t* parent) {
auto obj = __real_lv_obj_create(parent); auto obj = __real_lv_obj_create(parent);
if (tt::hal::getConfiguration()->uiDensity == tt::hal::UiDensity::Compact) { if (lvgl_get_ui_density() == LVGL_UI_DENSITY_COMPACT) {
lv_obj_set_style_pad_all(obj, 2, LV_STATE_DEFAULT); lv_obj_set_style_pad_all(obj, 2, LV_STATE_DEFAULT);
lv_obj_set_style_pad_gap(obj, 2, LV_STATE_DEFAULT); lv_obj_set_style_pad_gap(obj, 2, LV_STATE_DEFAULT);
lv_obj_set_style_radius(obj, 3, LV_STATE_DEFAULT); lv_obj_set_style_radius(obj, 3, LV_STATE_DEFAULT);

View File

@ -1,9 +1,9 @@
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
#include <Tactility/Tactility.h>
#include <lvgl.h> #include <lvgl.h>
#include <tactility/lvgl_module.h>
extern "C" { extern "C" {
extern lv_obj_t* __real_lv_switch_create(lv_obj_t* parent); extern lv_obj_t* __real_lv_switch_create(lv_obj_t* parent);
@ -11,7 +11,7 @@ extern lv_obj_t* __real_lv_switch_create(lv_obj_t* parent);
lv_obj_t* __wrap_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); auto widget = __real_lv_switch_create(parent);
if (tt::hal::getConfiguration()->uiDensity == tt::hal::UiDensity::Compact) { if (lvgl_get_ui_density() == LVGL_UI_DENSITY_COMPACT) {
lv_obj_set_style_size(widget, 25, 15, LV_STATE_DEFAULT); lv_obj_set_style_size(widget, 25, 15, LV_STATE_DEFAULT);
} }

View File

@ -1,8 +1,10 @@
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
#include <Tactility/app/App.h> #include <lvgl.h>
#include <tactility/lvgl_module.h>
#include <Tactility/service/gui/GuiService.h> #include <Tactility/service/gui/GuiService.h>
#include <Tactility/Tactility.h>
extern "C" { extern "C" {
@ -11,7 +13,7 @@ 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); auto textarea = __real_lv_textarea_create(parent);
if (tt::hal::getConfiguration()->uiDensity == tt::hal::UiDensity::Compact) { if (lvgl_get_ui_density() == LVGL_UI_DENSITY_COMPACT) {
lv_obj_set_style_pad_all(textarea, 2, LV_STATE_DEFAULT); lv_obj_set_style_pad_all(textarea, 2, LV_STATE_DEFAULT);
} }

View File

@ -1,32 +0,0 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
/** Affects LVGL widget style */
typedef enum {
/** Ideal for very small non-touch screen devices (e.g. Waveshare S3 LCD 1.3") */
UiDensityCompact,
/** Nothing was changed in the LVGL UI/UX */
UiDensityDefault
} UiDensity;
/** @deprecated use UiDensity */
typedef enum {
UiScaleSmallest, // UiDensityCompact
UiScaleDefault // UiDensityDefault
} UiScale;
/**
* @deprecated Use UiDensity
* @return the UI scaling setting for this device.
*/
UiScale tt_hal_configuration_get_ui_scale();
/** @return the UI scaling setting for this device. */
UiDensity tt_hal_configuration_get_ui_density();
#ifdef __cplusplus
}
#endif

View File

@ -1,18 +0,0 @@
#include "tt_hal.h"
#include <Tactility/Tactility.h>
#include <Tactility/hal/Configuration.h>
extern "C" {
UiDensity tt_hal_configuration_get_ui_density() {
auto density = tt::hal::getConfiguration()->uiDensity;
return static_cast<UiDensity>(density);
}
UiScale tt_hal_configuration_get_ui_scale() {
auto density = tt::hal::getConfiguration()->uiDensity;
return static_cast<UiScale>(density);
}
}

View File

@ -1,18 +0,0 @@
#include "tt_hal_gpio.h"
#include <Tactility/hal/gpio/Gpio.h>
#include <tactility/device.h>
#include <tactility/drivers/gpio_controller.h>
extern "C" {
using namespace tt::hal;
bool tt_hal_gpio_get_level(GpioPin pin) {
return false;
}
int tt_hal_gpio_get_pin_count() {
return 0;
}
}

View File

@ -5,10 +5,8 @@
#include "tt_app_selectiondialog.h" #include "tt_app_selectiondialog.h"
#include "tt_bundle.h" #include "tt_bundle.h"
#include "tt_gps.h" #include "tt_gps.h"
#include "tt_hal.h"
#include "tt_hal_device.h" #include "tt_hal_device.h"
#include "tt_hal_display.h" #include "tt_hal_display.h"
#include "tt_hal_gpio.h"
#include "tt_hal_touch.h" #include "tt_hal_touch.h"
#include "tt_hal_uart.h" #include "tt_hal_uart.h"
#include <tt_lock.h> #include <tt_lock.h>
@ -272,8 +270,6 @@ const esp_elfsym main_symbols[] {
ESP_ELFSYM_EXPORT(tt_bundle_put_string), ESP_ELFSYM_EXPORT(tt_bundle_put_string),
ESP_ELFSYM_EXPORT(tt_gps_has_coordinates), ESP_ELFSYM_EXPORT(tt_gps_has_coordinates),
ESP_ELFSYM_EXPORT(tt_gps_get_coordinates), ESP_ELFSYM_EXPORT(tt_gps_get_coordinates),
ESP_ELFSYM_EXPORT(tt_hal_configuration_get_ui_scale),
ESP_ELFSYM_EXPORT(tt_hal_configuration_get_ui_density),
ESP_ELFSYM_EXPORT(tt_hal_device_find), ESP_ELFSYM_EXPORT(tt_hal_device_find),
ESP_ELFSYM_EXPORT(tt_hal_display_driver_alloc), ESP_ELFSYM_EXPORT(tt_hal_display_driver_alloc),
ESP_ELFSYM_EXPORT(tt_hal_display_driver_draw_bitmap), ESP_ELFSYM_EXPORT(tt_hal_display_driver_draw_bitmap),
@ -284,8 +280,6 @@ const esp_elfsym main_symbols[] {
ESP_ELFSYM_EXPORT(tt_hal_display_driver_lock), ESP_ELFSYM_EXPORT(tt_hal_display_driver_lock),
ESP_ELFSYM_EXPORT(tt_hal_display_driver_unlock), ESP_ELFSYM_EXPORT(tt_hal_display_driver_unlock),
ESP_ELFSYM_EXPORT(tt_hal_display_driver_supported), ESP_ELFSYM_EXPORT(tt_hal_display_driver_supported),
ESP_ELFSYM_EXPORT(tt_hal_gpio_get_level),
ESP_ELFSYM_EXPORT(tt_hal_gpio_get_pin_count),
ESP_ELFSYM_EXPORT(tt_hal_touch_driver_supported), ESP_ELFSYM_EXPORT(tt_hal_touch_driver_supported),
ESP_ELFSYM_EXPORT(tt_hal_touch_driver_alloc), ESP_ELFSYM_EXPORT(tt_hal_touch_driver_alloc),
ESP_ELFSYM_EXPORT(tt_hal_touch_driver_free), ESP_ELFSYM_EXPORT(tt_hal_touch_driver_free),