From b7a2503a210b547f28b21bec056829a74b0c2a0e Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 15 Feb 2026 16:06:35 +0100 Subject: [PATCH 1/8] Add I2C register8 functions --- .../source/drivers/esp32_i2c.cpp | 6 ++-- .../tactility/drivers/i2c_controller.h | 8 ++++++ .../source/drivers/i2c_controller.cpp | 28 +++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/Platforms/platform-esp32/source/drivers/esp32_i2c.cpp b/Platforms/platform-esp32/source/drivers/esp32_i2c.cpp index 42330eea7..163597414 100644 --- a/Platforms/platform-esp32/source/drivers/esp32_i2c.cpp +++ b/Platforms/platform-esp32/source/drivers/esp32_i2c.cpp @@ -237,7 +237,7 @@ static error_t stop(Device* device) { return ERROR_NONE; } -const static I2cControllerApi esp32_i2c_api = { +static constexpr I2cControllerApi ESP32_I2C_API = { .read = read, .write = write, .write_read = write_read, @@ -245,14 +245,14 @@ const static I2cControllerApi esp32_i2c_api = { .write_register = write_register }; -extern struct Module platform_module; +extern Module platform_module; Driver esp32_i2c_driver = { .name = "esp32_i2c", .compatible = (const char*[]) { "espressif,esp32-i2c", nullptr }, .start_device = start, .stop_device = stop, - .api = (void*)&esp32_i2c_api, + .api = &ESP32_I2C_API, .device_type = &I2C_CONTROLLER_TYPE, .owner = &platform_module, .internal = nullptr diff --git a/TactilityKernel/include/tactility/drivers/i2c_controller.h b/TactilityKernel/include/tactility/drivers/i2c_controller.h index 96ce39fd7..3dbae2f67 100644 --- a/TactilityKernel/include/tactility/drivers/i2c_controller.h +++ b/TactilityKernel/include/tactility/drivers/i2c_controller.h @@ -143,6 +143,14 @@ error_t i2c_controller_read_register(struct Device* device, uint8_t address, uin */ error_t i2c_controller_write_register(struct Device* device, uint8_t address, uint8_t reg, const uint8_t* data, uint16_t dataSize, TickType_t timeout); +error_t i2c_controller_register8_set(struct Device* device, uint8_t address, uint8_t reg, uint8_t value, TickType_t timeout); + +error_t i2c_controller_register8_get(struct Device* device, uint8_t address, uint8_t reg, uint8_t* value, TickType_t timeout); + +error_t i2c_controller_register8_set_bits(struct Device* device, uint8_t address, uint8_t reg, uint8_t bits_to_set, TickType_t timeout); + +error_t i2c_controller_register8_reset_bits(struct Device* device, uint8_t address, uint8_t reg, uint8_t bits_to_reset, TickType_t timeout); + /** * @brief Writes an array of register-value pairs to an I2C device. * @param[in] device the I2C controller device diff --git a/TactilityKernel/source/drivers/i2c_controller.cpp b/TactilityKernel/source/drivers/i2c_controller.cpp index 0fbafaf38..c82a9f2d4 100644 --- a/TactilityKernel/source/drivers/i2c_controller.cpp +++ b/TactilityKernel/source/drivers/i2c_controller.cpp @@ -31,6 +31,34 @@ error_t i2c_controller_write_register(Device* device, uint8_t address, uint8_t r return I2C_DRIVER_API(driver)->write_register(device, address, reg, data, dataSize, timeout); } +error_t i2c_controller_register8_set(Device* device, uint8_t address, uint8_t reg, uint8_t value, TickType_t timeout) { + const auto* driver = device_get_driver(device); + return I2C_DRIVER_API(driver)->write_register(device, address, reg, &value, 1, timeout); +} + +error_t i2c_controller_register8_get(Device* device, uint8_t address, uint8_t reg, uint8_t* value, TickType_t timeout) { + const auto* driver = device_get_driver(device); + return I2C_DRIVER_API(driver)->read_register(device, address, reg, value, 1, timeout); +} + +error_t i2c_controller_register8_set_bits(Device* device, uint8_t address, uint8_t reg, uint8_t bits_to_set, TickType_t timeout) { + const auto* driver = device_get_driver(device); + uint8_t data = 0; + auto error = I2C_DRIVER_API(driver)->read_register(device, address, reg, &data, 1, timeout); + if (error != ERROR_NONE) return error; + data |= bits_to_set; + return I2C_DRIVER_API(driver)->write_register(device, address, reg, &data, 1, timeout); +} + +error_t i2c_controller_register8_reset_bits(Device* device, uint8_t address, uint8_t reg, uint8_t bits_to_reset, TickType_t timeout) { + const auto* driver = device_get_driver(device); + uint8_t data = 0; + auto error = I2C_DRIVER_API(driver)->read_register(device, address, reg, &data, 1, timeout); + if (error != ERROR_NONE) return error; + data &= ~bits_to_reset; + return I2C_DRIVER_API(driver)->write_register(device, address, reg, &data, 1, timeout); +} + error_t i2c_controller_write_register_array(Device* device, uint8_t address, const uint8_t* data, uint16_t dataSize, TickType_t timeout) { const auto* driver = device_get_driver(device); if (dataSize % 2 != 0) { From c3961fdde797d7857e53184455636a4546313667 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 15 Feb 2026 16:06:53 +0100 Subject: [PATCH 2/8] Implement Tab5 audio init and update power init sequence --- Devices/m5stack-tab5/Source/Configuration.cpp | 102 ++++++++++++++++-- Devices/m5stack-tab5/m5stack,tab5.dts | 16 ++- 2 files changed, 106 insertions(+), 12 deletions(-) diff --git a/Devices/m5stack-tab5/Source/Configuration.cpp b/Devices/m5stack-tab5/Source/Configuration.cpp index 6de4c5187..4ce591177 100644 --- a/Devices/m5stack-tab5/Source/Configuration.cpp +++ b/Devices/m5stack-tab5/Source/Configuration.cpp @@ -2,12 +2,14 @@ #include "devices/SdCard.h" #include +#include + #include #include using namespace tt::hal; -static const auto LOGGER = tt::Logger("Tab5"); +static constexpr auto* TAG = "Tab5"; static DeviceVector createDevices() { return { @@ -16,7 +18,7 @@ static DeviceVector createDevices() { }; } -static bool initBoot() { +static error_t initPower(::Device* i2c_controller) { /* PI4IOE5V6408-1 (0x43) - Bit 0: RF internal/external switch @@ -63,26 +65,106 @@ static bool initBoot() { }; constexpr auto IO_EXPANDER1_ADDRESS = 0x43; - if (!i2c::masterWriteRegisterArray(I2C_NUM_0, IO_EXPANDER1_ADDRESS, reg_data_io1_1, sizeof(reg_data_io1_1))) { - LOGGER.error("IO expander 1 init failed in phase 1"); - return false; + auto error = i2c_controller_write_register_array(i2c_controller, IO_EXPANDER1_ADDRESS, reg_data_io1_1, sizeof(reg_data_io1_1), pdMS_TO_TICKS(100)); + if (error != ERROR_NONE) { + LOG_E(TAG, "IO expander 1 init failed in phase 1"); + return ERROR_UNDEFINED; } constexpr auto IO_EXPANDER2_ADDRESS = 0x44; - if (!i2c::masterWriteRegisterArray(I2C_NUM_0, IO_EXPANDER2_ADDRESS, reg_data_io2, sizeof(reg_data_io2))) { - LOGGER.error("IO expander 2 init failed"); - return false; + error = i2c_controller_write_register_array(i2c_controller, IO_EXPANDER2_ADDRESS, reg_data_io2, sizeof(reg_data_io2), pdMS_TO_TICKS(100)); + if (error != ERROR_NONE) { + LOG_E(TAG, "IO expander 2 init failed"); + return ERROR_UNDEFINED; } // The M5Stack code applies this, but it's not known why // TODO: Remove and test it extensively tt::kernel::delayTicks(10); - if (!i2c::masterWriteRegisterArray(I2C_NUM_0, IO_EXPANDER1_ADDRESS, reg_data_io1_2, sizeof(reg_data_io1_2))) { - LOGGER.error("IO expander 1 init failed in phase 2"); + error = i2c_controller_write_register_array(i2c_controller, IO_EXPANDER1_ADDRESS, reg_data_io1_2, sizeof(reg_data_io1_2), pdMS_TO_TICKS(100)); + if (error != ERROR_NONE) { + LOG_E(TAG, "IO expander 1 init failed in phase 2"); + return ERROR_UNDEFINED; + } + + return ERROR_NONE; +} + +static error_t initSound(::Device* i2c_controller) { + // Init data from M5Unified: + // https://github.com/m5stack/M5Unified/blob/master/src/M5Unified.cpp + static constexpr uint8_t ES8388_I2C_ADDR = 0x10; + static constexpr uint8_t ENABLED_BULK_DATA[] = { + 0, 0x80, // RESET/ CSM POWER ON + 0, 0x00, + 0, 0x00, + 0, 0x0E, + 1, 0x00, + 2, 0x0A, // CHIP POWER: power up all + 3, 0xFF, // ADC POWER: power down all + 4, 0x3C, // DAC POWER: power up and LOUT1/ROUT1/LOUT2/ROUT2 enable + 5, 0x00, // ChipLowPower1 + 6, 0x00, // ChipLowPower2 + 7, 0x7C, // VSEL + 8, 0x00, // set I2S slave mode + // reg9-22 == adc + 23, 0x18, // I2S format (16bit) + 24, 0x00, // I2S MCLK ratio (128) + 25, 0x20, // DAC unmute + 26, 0x00, // LDACVOL 0x00~0xC0 + 27, 0x00, // RDACVOL 0x00~0xC0 + 28, 0x08, // enable digital click free power up and down + 29, 0x00, + 38, 0x00, // DAC CTRL16 + 39, 0xB8, // LEFT Ch MIX + 42, 0xB8, // RIGHTCh MIX + 43, 0x08, // ADC and DAC separate + 45, 0x00, // 0x00=1.5k VREF analog output / 0x10=40kVREF analog output + 46, 0x21, + 47, 0x21, + 48, 0x21, + 49, 0x21 + }; + + error_t error = i2c_controller_write_register_array( + i2c_controller, + ES8388_I2C_ADDR, + ENABLED_BULK_DATA, + sizeof(ENABLED_BULK_DATA), + pdMS_TO_TICKS(1000) + ); + if (error != ERROR_NONE) { + LOG_E(TAG, "Failed to enable ES8388: %s", error_to_string(error)); + return error; + } + + constexpr auto IO_EXPANDER1_ADDRESS = 0x43; + constexpr auto AMP_REGISTER = 0x05; + // Note: to disable the amplifier, reset the bits + error = i2c_controller_register8_set_bits(i2c_controller, IO_EXPANDER1_ADDRESS, AMP_REGISTER, 0b00000010 , pdMS_TO_TICKS(100)); + if (error != ERROR_NONE) { + LOG_E(TAG, "Failed to enable amplifier: %s", error_to_string(error)); + return error; + } + + return ERROR_NONE; +} + +static bool initBoot() { + auto* i2c0 = device_find_by_name("i2c0"); + check(i2c0, "i2c0 not found"); + + auto error = initPower(i2c0); + if (initPower(i2c0) != ERROR_NONE) { return false; } + error = initSound(i2c0); + if (error != ERROR_NONE) { + LOG_E(TAG, "Failed to enable ES8388"); + } + return true; } diff --git a/Devices/m5stack-tab5/m5stack,tab5.dts b/Devices/m5stack-tab5/m5stack,tab5.dts index 044c842eb..ecc811759 100644 --- a/Devices/m5stack-tab5/m5stack,tab5.dts +++ b/Devices/m5stack-tab5/m5stack,tab5.dts @@ -3,6 +3,7 @@ #include #include #include +#include #include / { @@ -14,7 +15,7 @@ gpio-count = <57>; }; - i2c_internal { + i2c_internal: i2c0 { compatible = "espressif,esp32-i2c"; port = ; clock-frequency = <400000>; @@ -22,7 +23,7 @@ pin-scl = <&gpio0 32 GPIO_FLAG_NONE>; }; - i2c_port_a { + i2c_port_a: i2c1 { compatible = "espressif,esp32-i2c"; port = ; clock-frequency = <400000>; @@ -37,4 +38,15 @@ pin-miso = <&gpio0 39 GPIO_FLAG_NONE>; pin-sclk = <&gpio0 43 GPIO_FLAG_NONE>; }; + + // ES8388 and ES7210 + i2s0 { + compatible = "espressif,esp32-i2s"; + port = ; + pin-bclk = <&gpio0 27 GPIO_FLAG_NONE>; + pin-ws = <&gpio0 29 GPIO_FLAG_NONE>; + pin-data-out = <&gpio0 26 GPIO_FLAG_NONE>; + pin-data-in = <&gpio0 28 GPIO_FLAG_NONE>; + pin-mclk = <&gpio0 30 GPIO_FLAG_NONE>; + }; }; From 8c9d86eb360e0d3538eebd7d2ae7064543037c5e Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 15 Feb 2026 16:17:34 +0100 Subject: [PATCH 3/8] Document I2C controller functions --- .../tactility/drivers/i2c_controller.h | 52 ++++++++++++++++--- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/TactilityKernel/include/tactility/drivers/i2c_controller.h b/TactilityKernel/include/tactility/drivers/i2c_controller.h index 3dbae2f67..6a50d9142 100644 --- a/TactilityKernel/include/tactility/drivers/i2c_controller.h +++ b/TactilityKernel/include/tactility/drivers/i2c_controller.h @@ -143,14 +143,6 @@ error_t i2c_controller_read_register(struct Device* device, uint8_t address, uin */ error_t i2c_controller_write_register(struct Device* device, uint8_t address, uint8_t reg, const uint8_t* data, uint16_t dataSize, TickType_t timeout); -error_t i2c_controller_register8_set(struct Device* device, uint8_t address, uint8_t reg, uint8_t value, TickType_t timeout); - -error_t i2c_controller_register8_get(struct Device* device, uint8_t address, uint8_t reg, uint8_t* value, TickType_t timeout); - -error_t i2c_controller_register8_set_bits(struct Device* device, uint8_t address, uint8_t reg, uint8_t bits_to_set, TickType_t timeout); - -error_t i2c_controller_register8_reset_bits(struct Device* device, uint8_t address, uint8_t reg, uint8_t bits_to_reset, TickType_t timeout); - /** * @brief Writes an array of register-value pairs to an I2C device. * @param[in] device the I2C controller device @@ -171,6 +163,50 @@ error_t i2c_controller_write_register_array(struct Device* device, uint8_t addre */ error_t i2c_controller_has_device_at_address(struct Device* device, uint8_t address, TickType_t timeout); +/** + * @brief Sets the value of an 8-bit register of an I2C device. + * @param[in] device the I2C controller device + * @param[in] address the 7-bit I2C address of the slave device + * @param[in] reg the register address to set + * @param[in] value the value to set the register to + * @param[in] timeout the maximum time to wait for the operation to complete + * @retval ERROR_NONE when the write operation was successful + */ +error_t i2c_controller_register8_set(struct Device* device, uint8_t address, uint8_t reg, uint8_t value, TickType_t timeout); + +/** + * @brief Gets the value of an 8-bit register of an I2C device. + * @param[in] device the I2C controller device + * @param[in] address the 7-bit I2C address of the slave device + * @param[in] reg the register address to get + * @param[out] value a pointer to the variable to store the register value + * @param[in] timeout the maximum time to wait for the operation to complete + * @retval ERROR_NONE when the read operation was successful + */ +error_t i2c_controller_register8_get(struct Device* device, uint8_t address, uint8_t reg, uint8_t* value, TickType_t timeout); + +/** + * @brief Sets specific bits in an 8-bit register of an I2C device. + * @param[in] device the I2C controller device + * @param[in] address the 7-bit I2C address of the slave device + * @param[in] reg the register address + * @param[in] bits_to_set a bitmask of bits to set (set to 1) + * @param[in] timeout the maximum time to wait for the operation to complete + * @retval ERROR_NONE when the operation was successful + */ +error_t i2c_controller_register8_set_bits(struct Device* device, uint8_t address, uint8_t reg, uint8_t bits_to_set, TickType_t timeout); + +/** + * @brief Resets specific bits in an 8-bit register of an I2C device. + * @param[in] device the I2C controller device + * @param[in] address the 7-bit I2C address of the slave device + * @param[in] reg the register address + * @param[in] bits_to_reset a bitmask of bits to reset (set to 0) + * @param[in] timeout the maximum time to wait for the operation to complete + * @retval ERROR_NONE when the operation was successful + */ +error_t i2c_controller_register8_reset_bits(struct Device* device, uint8_t address, uint8_t reg, uint8_t bits_to_reset, TickType_t timeout); + extern const struct DeviceType I2C_CONTROLLER_TYPE; #ifdef __cplusplus From 02b9b5497a693243b549912413ac09dddf64b8c3 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 15 Feb 2026 16:17:41 +0100 Subject: [PATCH 4/8] Add missing symbols to kernel export --- TactilityKernel/source/kernel_symbols.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/TactilityKernel/source/kernel_symbols.c b/TactilityKernel/source/kernel_symbols.c index 904fbb2ca..094271247 100644 --- a/TactilityKernel/source/kernel_symbols.c +++ b/TactilityKernel/source/kernel_symbols.c @@ -80,6 +80,10 @@ const struct ModuleSymbol KERNEL_SYMBOLS[] = { DEFINE_MODULE_SYMBOL(i2c_controller_write_register), DEFINE_MODULE_SYMBOL(i2c_controller_write_register_array), DEFINE_MODULE_SYMBOL(i2c_controller_has_device_at_address), + DEFINE_MODULE_SYMBOL(i2c_controller_register8_set), + DEFINE_MODULE_SYMBOL(i2c_controller_register8_get), + DEFINE_MODULE_SYMBOL(i2c_controller_register8_set_bits), + DEFINE_MODULE_SYMBOL(i2c_controller_register8_reset_bits), DEFINE_MODULE_SYMBOL(I2C_CONTROLLER_TYPE), // drivers/i2s_controller DEFINE_MODULE_SYMBOL(i2s_controller_read), @@ -94,6 +98,7 @@ const struct ModuleSymbol KERNEL_SYMBOLS[] = { DEFINE_MODULE_SYMBOL(spi_controller_lock), DEFINE_MODULE_SYMBOL(spi_controller_try_lock), DEFINE_MODULE_SYMBOL(spi_controller_unlock), + DEFINE_MODULE_SYMBOL(SPI_CONTROLLER_TYPE), // drivers/uart_controller DEFINE_MODULE_SYMBOL(uart_controller_open), DEFINE_MODULE_SYMBOL(uart_controller_close), From 6d47488c86fbb528ac52498fc0380170d7445238 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 15 Feb 2026 16:20:16 +0100 Subject: [PATCH 5/8] Add kernel readme --- TactilityKernel/README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 TactilityKernel/README.md diff --git a/TactilityKernel/README.md b/TactilityKernel/README.md new file mode 100644 index 000000000..d4b747df5 --- /dev/null +++ b/TactilityKernel/README.md @@ -0,0 +1,21 @@ +# TactilityKernel + +TactilityKernel is the core component of the Tactility project, providing a hardware abstraction layer (HAL) and essential kernel services for embedded systems. + +## Features + +- **Device and Driver Model**: A flexible system for managing hardware devices and their corresponding drivers. +- **Peripheral Support**: Standard interfaces for common peripherals: + - GPIO (General Purpose Input/Output) + - I2C (Inter-Integrated Circuit) + - I2S (Inter-IC Sound) + - SPI (Serial Peripheral Interface) + - UART (Universal Asynchronous Receiver-Transmitter) +- **Concurrency Primitives**: Built-in support for multi-threaded environments, including: + - Threads and Dispatchers + - Mutexes and Recursive Mutexes + - Event Groups + - Timers +- **Module System**: Support for loadable modules that can export symbols and provide runtime-extensible functionality. +- **Device Tree Integration**: Utilizes a devicetree-like system for hardware configuration and initialization. +- **Cross-Platform**: Designed to run on both embedded platforms (such as ESP32) and desktop environments (Linux) for simulation and testing. From ce890d93caf81e841a7c75d9e0544d6deb30cf61 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 15 Feb 2026 18:04:05 +0100 Subject: [PATCH 6/8] Move UiDensity to lvgl-module and remove some symbols from TactilityC --- Buildscripts/properties.cmake | 56 +++++++++++++++++++ .../Source/Configuration.cpp | 1 - .../heltec-wifi-lora-32-v3/device.properties | 1 + .../lilygo-tdisplay/Source/Configuration.cpp | 1 - Devices/lilygo-tdisplay/device.properties | 2 +- .../Source/Configuration.cpp | 1 - Devices/lilygo-tdongle-s3/device.properties | 1 + .../Source/Configuration.cpp | 1 - .../m5stack-cardputer-adv/device.properties | 1 + .../Source/Configuration.cpp | 1 - Devices/m5stack-cardputer/device.properties | 1 + .../Source/Configuration.cpp | 1 - Devices/m5stack-stickc-plus/device.properties | 1 + .../Source/Configuration.cpp | 1 - .../m5stack-stickc-plus2/device.properties | 1 + Devices/simulator/device.properties | 13 +++++ .../Source/Configuration.cpp | 1 - .../waveshare-esp32-s3-geek/device.properties | 1 + .../Source/Configuration.cpp | 1 - Devices/waveshare-s3-lcd-13/device.properties | 1 + .../Source/Configuration.cpp | 1 - .../device.properties | 1 + .../Source/Configuration.cpp | 1 - .../device.properties | 1 + Modules/lvgl-module/CMakeLists.txt | 33 ++++++++++- .../include/tactility/lvgl_module.h | 16 ++++++ Modules/lvgl-module/source/arch/lvgl_posix.c | 2 +- Modules/lvgl-module/source/module.c | 4 ++ Modules/lvgl-module/source/symbols.c | 1 + .../Include/Tactility/hal/Configuration.h | 11 ---- Tactility/Source/app/display/Display.cpp | 7 ++- Tactility/Source/app/launcher/Launcher.cpp | 9 +-- .../Source/app/systeminfo/SystemInfo.cpp | 11 ++-- .../app/trackball/TrackballSettings.cpp | 16 +++--- Tactility/Source/app/wifimanage/View.cpp | 13 +++-- Tactility/Source/lvgl/Statusbar.cpp | 5 +- Tactility/Source/lvgl/Toolbar.cpp | 34 +++++------ Tactility/Source/lvgl/wrappers/button.cpp | 6 +- Tactility/Source/lvgl/wrappers/dropdown.cpp | 6 +- Tactility/Source/lvgl/wrappers/list.cpp | 8 +-- Tactility/Source/lvgl/wrappers/obj.cpp | 8 +-- Tactility/Source/lvgl/wrappers/switch.cpp | 6 +- Tactility/Source/lvgl/wrappers/textarea.cpp | 8 ++- TactilityC/Include/tt_hal.h | 32 ----------- TactilityC/Source/tt_hal.cpp | 18 ------ TactilityC/Source/tt_hal_gpio.cpp | 18 ------ TactilityC/Source/tt_init.cpp | 6 -- 47 files changed, 207 insertions(+), 163 deletions(-) create mode 100644 Devices/simulator/device.properties delete mode 100644 TactilityC/Include/tt_hal.h delete mode 100644 TactilityC/Source/tt_hal.cpp delete mode 100644 TactilityC/Source/tt_hal_gpio.cpp diff --git a/Buildscripts/properties.cmake b/Buildscripts/properties.cmake index 654497330..e25beaa58 100644 --- a/Buildscripts/properties.cmake +++ b/Buildscripts/properties.cmake @@ -21,3 +21,59 @@ function(GET_PROPERTY_FILE_CONTENT PROPERTY_FILE RESULT_VAR) set(${RESULT_VAR} "${file_content}" PARENT_SCOPE) 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() + diff --git a/Devices/heltec-wifi-lora-32-v3/Source/Configuration.cpp b/Devices/heltec-wifi-lora-32-v3/Source/Configuration.cpp index f0097608a..70fb18d39 100644 --- a/Devices/heltec-wifi-lora-32-v3/Source/Configuration.cpp +++ b/Devices/heltec-wifi-lora-32-v3/Source/Configuration.cpp @@ -44,6 +44,5 @@ static std::vector> createDevices() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .uiDensity = UiDensity::Compact, .createDevices = createDevices }; diff --git a/Devices/heltec-wifi-lora-32-v3/device.properties b/Devices/heltec-wifi-lora-32-v3/device.properties index 9692f452d..73ce3992e 100644 --- a/Devices/heltec-wifi-lora-32-v3/device.properties +++ b/Devices/heltec-wifi-lora-32-v3/device.properties @@ -26,3 +26,4 @@ infoMessage=Due to the small size of the screen, the icons don't render properly theme=Mono colorDepth=16 uiScale=70 +uiDensity=compact diff --git a/Devices/lilygo-tdisplay/Source/Configuration.cpp b/Devices/lilygo-tdisplay/Source/Configuration.cpp index 3a6e99c9b..fc238bd95 100644 --- a/Devices/lilygo-tdisplay/Source/Configuration.cpp +++ b/Devices/lilygo-tdisplay/Source/Configuration.cpp @@ -19,6 +19,5 @@ static std::vector> createDevices() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .uiDensity = UiDensity::Compact, .createDevices = createDevices }; diff --git a/Devices/lilygo-tdisplay/device.properties b/Devices/lilygo-tdisplay/device.properties index 94bd4f418..357be5d0e 100644 --- a/Devices/lilygo-tdisplay/device.properties +++ b/Devices/lilygo-tdisplay/device.properties @@ -20,4 +20,4 @@ dpi=242 [lvgl] colorDepth=16 - +uiDensity=compact diff --git a/Devices/lilygo-tdongle-s3/Source/Configuration.cpp b/Devices/lilygo-tdongle-s3/Source/Configuration.cpp index 8ae458446..8358fd2e9 100644 --- a/Devices/lilygo-tdongle-s3/Source/Configuration.cpp +++ b/Devices/lilygo-tdongle-s3/Source/Configuration.cpp @@ -16,6 +16,5 @@ static std::vector> createDevices() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .uiDensity = UiDensity::Compact, .createDevices = createDevices }; diff --git a/Devices/lilygo-tdongle-s3/device.properties b/Devices/lilygo-tdongle-s3/device.properties index a44180073..28622b83d 100644 --- a/Devices/lilygo-tdongle-s3/device.properties +++ b/Devices/lilygo-tdongle-s3/device.properties @@ -21,3 +21,4 @@ dpi=186 [lvgl] colorDepth=16 +uiDensity=compact diff --git a/Devices/m5stack-cardputer-adv/Source/Configuration.cpp b/Devices/m5stack-cardputer-adv/Source/Configuration.cpp index 8b297dffa..bd3475621 100644 --- a/Devices/m5stack-cardputer-adv/Source/Configuration.cpp +++ b/Devices/m5stack-cardputer-adv/Source/Configuration.cpp @@ -28,6 +28,5 @@ static DeviceVector createDevices() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .uiDensity = UiDensity::Compact, .createDevices = createDevices }; diff --git a/Devices/m5stack-cardputer-adv/device.properties b/Devices/m5stack-cardputer-adv/device.properties index 0a7ddf66d..63dd51268 100644 --- a/Devices/m5stack-cardputer-adv/device.properties +++ b/Devices/m5stack-cardputer-adv/device.properties @@ -20,3 +20,4 @@ dpi=139 [lvgl] colorDepth=16 +uiDensity=compact diff --git a/Devices/m5stack-cardputer/Source/Configuration.cpp b/Devices/m5stack-cardputer/Source/Configuration.cpp index 85d0ba8ea..80989e044 100644 --- a/Devices/m5stack-cardputer/Source/Configuration.cpp +++ b/Devices/m5stack-cardputer/Source/Configuration.cpp @@ -26,6 +26,5 @@ static DeviceVector createDevices() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .uiDensity = UiDensity::Compact, .createDevices = createDevices }; diff --git a/Devices/m5stack-cardputer/device.properties b/Devices/m5stack-cardputer/device.properties index 7e3ebc1e0..76936fc6b 100644 --- a/Devices/m5stack-cardputer/device.properties +++ b/Devices/m5stack-cardputer/device.properties @@ -20,3 +20,4 @@ dpi=139 [lvgl] colorDepth=16 +uiDensity=compact diff --git a/Devices/m5stack-stickc-plus/Source/Configuration.cpp b/Devices/m5stack-stickc-plus/Source/Configuration.cpp index 9e35b6833..15e09bfdc 100644 --- a/Devices/m5stack-stickc-plus/Source/Configuration.cpp +++ b/Devices/m5stack-stickc-plus/Source/Configuration.cpp @@ -25,6 +25,5 @@ static DeviceVector createDevices() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .uiDensity = UiDensity::Compact, .createDevices = createDevices }; diff --git a/Devices/m5stack-stickc-plus/device.properties b/Devices/m5stack-stickc-plus/device.properties index 895787449..f15835911 100644 --- a/Devices/m5stack-stickc-plus/device.properties +++ b/Devices/m5stack-stickc-plus/device.properties @@ -20,3 +20,4 @@ dpi=242 [lvgl] colorDepth=16 +uiDensity=compact diff --git a/Devices/m5stack-stickc-plus2/Source/Configuration.cpp b/Devices/m5stack-stickc-plus2/Source/Configuration.cpp index ccef04bf6..d6307a618 100644 --- a/Devices/m5stack-stickc-plus2/Source/Configuration.cpp +++ b/Devices/m5stack-stickc-plus2/Source/Configuration.cpp @@ -28,6 +28,5 @@ static DeviceVector createDevices() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .uiDensity = UiDensity::Compact, .createDevices = createDevices }; diff --git a/Devices/m5stack-stickc-plus2/device.properties b/Devices/m5stack-stickc-plus2/device.properties index a0ec6a845..1b3074e0a 100644 --- a/Devices/m5stack-stickc-plus2/device.properties +++ b/Devices/m5stack-stickc-plus2/device.properties @@ -22,3 +22,4 @@ dpi=242 [lvgl] colorDepth=16 +uiDensity=compact diff --git a/Devices/simulator/device.properties b/Devices/simulator/device.properties new file mode 100644 index 000000000..ef614416f --- /dev/null +++ b/Devices/simulator/device.properties @@ -0,0 +1,13 @@ +[general] +vendor=Simulator +name=Tab5Simulator + +[apps] +launcherAppId=Launcher + +[hardware] +target=POSIX + +[lvgl] +colorDepth=16 +fontSize=14 diff --git a/Devices/waveshare-esp32-s3-geek/Source/Configuration.cpp b/Devices/waveshare-esp32-s3-geek/Source/Configuration.cpp index 55d33578b..422ab5a83 100644 --- a/Devices/waveshare-esp32-s3-geek/Source/Configuration.cpp +++ b/Devices/waveshare-esp32-s3-geek/Source/Configuration.cpp @@ -21,6 +21,5 @@ static bool initBoot() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .uiDensity = UiDensity::Compact, .createDevices = createDevices }; \ No newline at end of file diff --git a/Devices/waveshare-esp32-s3-geek/device.properties b/Devices/waveshare-esp32-s3-geek/device.properties index 5c7f45b7d..6861b7255 100644 --- a/Devices/waveshare-esp32-s3-geek/device.properties +++ b/Devices/waveshare-esp32-s3-geek/device.properties @@ -23,6 +23,7 @@ dpi=143 [lvgl] colorDepth=16 +uiDensity=compact [sdkconfig] # Fix error "PSRAM space not enough for the Flash instructions" on boot: diff --git a/Devices/waveshare-s3-lcd-13/Source/Configuration.cpp b/Devices/waveshare-s3-lcd-13/Source/Configuration.cpp index a5a590378..aef2df4b9 100644 --- a/Devices/waveshare-s3-lcd-13/Source/Configuration.cpp +++ b/Devices/waveshare-s3-lcd-13/Source/Configuration.cpp @@ -20,6 +20,5 @@ static bool initBoot() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .uiDensity = UiDensity::Compact, .createDevices = createDevices }; diff --git a/Devices/waveshare-s3-lcd-13/device.properties b/Devices/waveshare-s3-lcd-13/device.properties index 6cc6c4152..918f3fd93 100644 --- a/Devices/waveshare-s3-lcd-13/device.properties +++ b/Devices/waveshare-s3-lcd-13/device.properties @@ -23,3 +23,4 @@ dpi=261 [lvgl] colorDepth=16 +uiDensity=compact diff --git a/Devices/waveshare-s3-touch-lcd-128/Source/Configuration.cpp b/Devices/waveshare-s3-touch-lcd-128/Source/Configuration.cpp index 9afbdb088..5a2a1ca53 100644 --- a/Devices/waveshare-s3-touch-lcd-128/Source/Configuration.cpp +++ b/Devices/waveshare-s3-touch-lcd-128/Source/Configuration.cpp @@ -20,6 +20,5 @@ static bool initBoot() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .uiDensity = UiDensity::Compact, .createDevices = createDevices }; diff --git a/Devices/waveshare-s3-touch-lcd-128/device.properties b/Devices/waveshare-s3-touch-lcd-128/device.properties index 44d60d4cd..9038d7875 100644 --- a/Devices/waveshare-s3-touch-lcd-128/device.properties +++ b/Devices/waveshare-s3-touch-lcd-128/device.properties @@ -23,6 +23,7 @@ dpi=265 [lvgl] colorDepth=16 +uiDensity=compact [sdkconfig] # Fix error "PSRAM space not enough for the Flash instructions" on boot: diff --git a/Devices/waveshare-s3-touch-lcd-147/Source/Configuration.cpp b/Devices/waveshare-s3-touch-lcd-147/Source/Configuration.cpp index 8ae458446..8358fd2e9 100644 --- a/Devices/waveshare-s3-touch-lcd-147/Source/Configuration.cpp +++ b/Devices/waveshare-s3-touch-lcd-147/Source/Configuration.cpp @@ -16,6 +16,5 @@ static std::vector> createDevices() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .uiDensity = UiDensity::Compact, .createDevices = createDevices }; diff --git a/Devices/waveshare-s3-touch-lcd-147/device.properties b/Devices/waveshare-s3-touch-lcd-147/device.properties index b644e38c9..df7fb19e7 100644 --- a/Devices/waveshare-s3-touch-lcd-147/device.properties +++ b/Devices/waveshare-s3-touch-lcd-147/device.properties @@ -26,3 +26,4 @@ warningMessage=Touch doesn't work yet [lvgl] colorDepth=16 +uiDensity=compact diff --git a/Modules/lvgl-module/CMakeLists.txt b/Modules/lvgl-module/CMakeLists.txt index 24954ec83..dd605e5e5 100644 --- a/Modules/lvgl-module/CMakeLists.txt +++ b/Modules/lvgl-module/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.20) # #################################### -# Read properties +# Read sdkconfig properties # #################################### 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_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) else () # Default values for simulator set(font_size_small 10) @@ -33,6 +34,31 @@ message(" - statusbar: ${statusbar_symbol_size}") message(" - launcher: ${launcher_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 # #################################### @@ -66,17 +92,22 @@ tactility_add_module(lvgl-module tactility_get_module_name("lvgl-module" MODULE_NAME) target_compile_definitions(${MODULE_NAME} PUBLIC + # Ensure it loads "-DLV_LVGL_H_INCLUDE_SIMPLE" + # Text fonts "-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_DEFAULT_SIZE=${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_SYMBOL=lv_font_montserrat_${font_size_large}" + # Icon fonts "-DTT_LVGL_STATUSBAR_FONT_ICON_SIZE=${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_SYMBOL=material_symbols_launcher_${launcher_symbol_size}" "-DTT_LVGL_SHARED_FONT_ICON_SIZE=${shared_symbol_size}" "-DTT_LVGL_SHARED_FONT_ICON_SYMBOL=material_symbols_shared_${shared_symbol_size}" + # UiDensity + "-DTT_LVGL_UI_DENSITY=${ui_density}" ) diff --git a/Modules/lvgl-module/include/tactility/lvgl_module.h b/Modules/lvgl-module/include/tactility/lvgl_module.h index 62e631e50..4548305d4 100644 --- a/Modules/lvgl-module/include/tactility/lvgl_module.h +++ b/Modules/lvgl-module/include/tactility/lvgl_module.h @@ -16,6 +16,14 @@ extern "C" { #include #include +/** 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. */ @@ -86,6 +94,14 @@ void lvgl_unlock(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 } #endif diff --git a/Modules/lvgl-module/source/arch/lvgl_posix.c b/Modules/lvgl-module/source/arch/lvgl_posix.c index 0efcbb6f3..3698b6867 100644 --- a/Modules/lvgl-module/source/arch/lvgl_posix.c +++ b/Modules/lvgl-module/source/arch/lvgl_posix.c @@ -10,7 +10,7 @@ #include -#include "tactility/lvgl_module.h" +#include extern struct LvglModuleConfig lvgl_module_config; diff --git a/Modules/lvgl-module/source/module.c b/Modules/lvgl-module/source/module.c index 6dce36944..6db5b597a 100644 --- a/Modules/lvgl-module/source/module.c +++ b/Modules/lvgl-module/source/module.c @@ -60,6 +60,10 @@ bool lvgl_is_running() { return is_running; } +enum UiDensity lvgl_get_ui_density(void) { + return TT_LVGL_UI_DENSITY; +} + struct Module lvgl_module = { .name = "lvgl", .start = start, diff --git a/Modules/lvgl-module/source/symbols.c b/Modules/lvgl-module/source/symbols.c index b542d0c96..5e7625171 100644 --- a/Modules/lvgl-module/source/symbols.c +++ b/Modules/lvgl-module/source/symbols.c @@ -11,6 +11,7 @@ const struct ModuleSymbol lvgl_module_symbols[] = { DEFINE_MODULE_SYMBOL(lvgl_try_lock), DEFINE_MODULE_SYMBOL(lvgl_unlock), DEFINE_MODULE_SYMBOL(lvgl_is_running), + DEFINE_MODULE_SYMBOL(lvgl_get_ui_density), // lvgl_fonts DEFINE_MODULE_SYMBOL(lvgl_get_shared_icon_font), DEFINE_MODULE_SYMBOL(lvgl_get_shared_icon_font_height), diff --git a/Tactility/Include/Tactility/hal/Configuration.h b/Tactility/Include/Tactility/hal/Configuration.h index 00dd76a53..8b085bb2e 100644 --- a/Tactility/Include/Tactility/hal/Configuration.h +++ b/Tactility/Include/Tactility/hal/Configuration.h @@ -12,23 +12,12 @@ typedef std::vector> DeviceVector; typedef std::shared_ptr (*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 { /** * Used for powering on the peripherals manually. */ const InitBoot initBoot = nullptr; - /** Modify LVGL widget size */ - const UiDensity uiDensity = UiDensity::Default; - const std::function createDevices = [] { return DeviceVector(); }; }; diff --git a/Tactility/Source/app/display/Display.cpp b/Tactility/Source/app/display/Display.cpp index 0e9a95070..ab0b64603 100644 --- a/Tactility/Source/app/display/Display.cpp +++ b/Tactility/Source/app/display/Display.cpp @@ -12,6 +12,7 @@ #include #include +#include namespace tt::app::display { @@ -122,7 +123,7 @@ class DisplayApp final : public App { void onShow(AppContext& app, lv_obj_t* parent) override { 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_style_pad_row(parent, 0, LV_STATE_DEFAULT); @@ -144,7 +145,7 @@ class DisplayApp final : public App { 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_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); } @@ -168,7 +169,7 @@ class DisplayApp final : public App { 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_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); } diff --git a/Tactility/Source/app/launcher/Launcher.cpp b/Tactility/Source/app/launcher/Launcher.cpp index 3b6cc8d25..79efc4fd6 100644 --- a/Tactility/Source/app/launcher/Launcher.cpp +++ b/Tactility/Source/app/launcher/Launcher.cpp @@ -12,13 +12,14 @@ #include #include +#include namespace tt::app::launcher { static const auto LOGGER = Logger("Launcher"); -static uint32_t getButtonPadding(hal::UiDensity density, uint32_t buttonSize) { - if (density == hal::UiDensity::Compact) { +static uint32_t getButtonPadding(UiDensity density, uint32_t buttonSize) { + if (density == LVGL_UI_DENSITY_COMPACT) { return 0; } else { return buttonSize / 8; @@ -27,7 +28,7 @@ static uint32_t getButtonPadding(hal::UiDensity density, uint32_t buttonSize) { 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_padding = getButtonPadding(uiDensity, button_size); auto* apps_button = lv_button_create(parent); @@ -119,7 +120,7 @@ class LauncherApp final : public App { void onShow(AppContext& app, lv_obj_t* parent) override { 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_padding = getButtonPadding(ui_density, button_size); const auto total_button_size = button_size + (button_padding * 2); diff --git a/Tactility/Source/app/systeminfo/SystemInfo.cpp b/Tactility/Source/app/systeminfo/SystemInfo.cpp index c42cece2e..6d5c3171f 100644 --- a/Tactility/Source/app/systeminfo/SystemInfo.cpp +++ b/Tactility/Source/app/systeminfo/SystemInfo.cpp @@ -1,19 +1,20 @@ #include #include #include - #include #include #include #include +#include #include #include -#include +#include + #include +#include #include -#include -#include +#include #ifdef ESP_PLATFORM #include @@ -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_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); } else { lv_obj_set_style_pad_bottom(bottom_label, 12, LV_STATE_DEFAULT); diff --git a/Tactility/Source/app/trackball/TrackballSettings.cpp b/Tactility/Source/app/trackball/TrackballSettings.cpp index 477fed7e6..727408988 100644 --- a/Tactility/Source/app/trackball/TrackballSettings.cpp +++ b/Tactility/Source/app/trackball/TrackballSettings.cpp @@ -1,13 +1,13 @@ #ifdef ESP_PLATFORM -#include - -#include -#include - #include #include +#include + +#include +#include +#include // Forward declare driver functions namespace trackball { @@ -109,7 +109,7 @@ class TrackballSettingsApp final : public App { public: void onShow(AppContext& app, lv_obj_t* parent) override { tbSettings = settings::trackball::loadOrGetDefault(); - auto ui_density = hal::getConfiguration()->uiDensity; + auto ui_density = lvgl_get_ui_density(); updated = false; lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN); @@ -154,7 +154,7 @@ class TrackballSettingsApp final : public App { 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_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); } @@ -178,7 +178,7 @@ class TrackballSettingsApp final : public App { 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_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); } diff --git a/Tactility/Source/app/wifimanage/View.cpp b/Tactility/Source/app/wifimanage/View.cpp index a7d9aafc1..f0ccc96c1 100644 --- a/Tactility/Source/app/wifimanage/View.cpp +++ b/Tactility/Source/app/wifimanage/View.cpp @@ -1,5 +1,10 @@ -#include +#include +#include +#include + +#include +#include #include #include #include @@ -9,10 +14,6 @@ #include #include -#include -#include -#include - namespace tt::app::wifimanage { 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_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); } else { lv_obj_set_style_pad_ver(enable_on_boot_wrapper, 8, LV_STATE_DEFAULT); diff --git a/Tactility/Source/lvgl/Statusbar.cpp b/Tactility/Source/lvgl/Statusbar.cpp index 2e7947884..42ebb6d0a 100644 --- a/Tactility/Source/lvgl/Statusbar.cpp +++ b/Tactility/Source/lvgl/Statusbar.cpp @@ -14,6 +14,7 @@ #include #include +#include #include @@ -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_align(obj, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); auto icon_size = lvgl_get_statusbar_icon_font_height(); - auto ui_density = hal::getConfiguration()->uiDensity; - auto icon_padding = (ui_density != hal::UiDensity::Compact) ? static_cast(icon_size * 0.2f) : 2; + auto ui_density = lvgl_get_ui_density(); + auto icon_padding = (ui_density != LVGL_UI_DENSITY_COMPACT) ? static_cast(icon_size * 0.2f) : 2; lv_obj_set_style_pad_column(obj, icon_padding, LV_STATE_DEFAULT); statusbar->time = lv_label_create(obj); diff --git a/Tactility/Source/lvgl/Toolbar.cpp b/Tactility/Source/lvgl/Toolbar.cpp index f8b627070..8f78cb987 100644 --- a/Tactility/Source/lvgl/Toolbar.cpp +++ b/Tactility/Source/lvgl/Toolbar.cpp @@ -2,41 +2,43 @@ #include #include + #include #include #include #include +#include namespace tt::lvgl { -static uint32_t getToolbarHeight(hal::UiDensity uiDensity) { - if (uiDensity == hal::UiDensity::Compact) { +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(hal::UiDensity uiDensity) { - if (uiDensity == hal::UiDensity::Compact) { +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(hal::UiDensity ui_density) { - auto toolbar_height = getToolbarHeight(ui_density); +static uint32_t getActionIconPadding(UiDensity uiDensity) { + auto toolbar_height = getToolbarHeight(uiDensity); // 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, * 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 toolbar_height = getToolbarHeight(ui_density); 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) { - auto ui_density = hal::getConfiguration()->uiDensity; + 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); @@ -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); 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); } @@ -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); auto* title_wrapper = lv_obj_create(obj); - uint32_t title_left_padding = (ui_density != hal::UiDensity::Compact) ? icon_padding : 2; - uint32_t title_right_padding = (ui_density != hal::UiDensity::Compact) ? (icon_padding / 2) : 2; + 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); @@ -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"); toolbar->action_count++; - auto ui_density = hal::getConfiguration()->uiDensity; + auto ui_density = lvgl_get_ui_density(); auto toolbar_height = getToolbarHeight(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_style_pad_all(action_button, 0, LV_STATE_DEFAULT); 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); } @@ -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) { auto* toolbar = reinterpret_cast(obj); - auto ui_density = hal::getConfiguration()->uiDensity; + 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); @@ -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) { auto* toolbar = reinterpret_cast(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* spinner = spinner_create(wrapper); diff --git a/Tactility/Source/lvgl/wrappers/button.cpp b/Tactility/Source/lvgl/wrappers/button.cpp index d32e95aba..0dbbb52e9 100644 --- a/Tactility/Source/lvgl/wrappers/button.cpp +++ b/Tactility/Source/lvgl/wrappers/button.cpp @@ -1,9 +1,9 @@ #ifdef ESP_PLATFORM -#include - #include +#include + extern "C" { 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) { 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_radius(button, 3, LV_STATE_DEFAULT); } diff --git a/Tactility/Source/lvgl/wrappers/dropdown.cpp b/Tactility/Source/lvgl/wrappers/dropdown.cpp index 3019239d1..c07566a85 100644 --- a/Tactility/Source/lvgl/wrappers/dropdown.cpp +++ b/Tactility/Source/lvgl/wrappers/dropdown.cpp @@ -1,9 +1,9 @@ #ifdef ESP_PLATFORM -#include - #include +#include + extern "C" { 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) { 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); } diff --git a/Tactility/Source/lvgl/wrappers/list.cpp b/Tactility/Source/lvgl/wrappers/list.cpp index c01123ca8..e1a0fa878 100644 --- a/Tactility/Source/lvgl/wrappers/list.cpp +++ b/Tactility/Source/lvgl/wrappers/list.cpp @@ -1,9 +1,9 @@ #ifdef ESP_PLATFORM -#include - #include +#include + extern "C" { 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) { 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_column(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) { 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); } diff --git a/Tactility/Source/lvgl/wrappers/obj.cpp b/Tactility/Source/lvgl/wrappers/obj.cpp index aec7da584..93494a3e5 100644 --- a/Tactility/Source/lvgl/wrappers/obj.cpp +++ b/Tactility/Source/lvgl/wrappers/obj.cpp @@ -1,9 +1,9 @@ #ifdef ESP_PLATFORM -#include - #include +#include + extern "C" { 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) { __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_t* __wrap_lv_obj_create(lv_obj_t* 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_gap(obj, 2, LV_STATE_DEFAULT); lv_obj_set_style_radius(obj, 3, LV_STATE_DEFAULT); diff --git a/Tactility/Source/lvgl/wrappers/switch.cpp b/Tactility/Source/lvgl/wrappers/switch.cpp index ca6767413..0e065591b 100644 --- a/Tactility/Source/lvgl/wrappers/switch.cpp +++ b/Tactility/Source/lvgl/wrappers/switch.cpp @@ -1,9 +1,9 @@ #ifdef ESP_PLATFORM -#include - #include +#include + extern "C" { 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) { 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); } diff --git a/Tactility/Source/lvgl/wrappers/textarea.cpp b/Tactility/Source/lvgl/wrappers/textarea.cpp index 0feffcbb5..3f173b49f 100644 --- a/Tactility/Source/lvgl/wrappers/textarea.cpp +++ b/Tactility/Source/lvgl/wrappers/textarea.cpp @@ -1,8 +1,10 @@ #ifdef ESP_PLATFORM -#include +#include + +#include + #include -#include 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) { 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); } diff --git a/TactilityC/Include/tt_hal.h b/TactilityC/Include/tt_hal.h deleted file mode 100644 index 65c4f5bca..000000000 --- a/TactilityC/Include/tt_hal.h +++ /dev/null @@ -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 diff --git a/TactilityC/Source/tt_hal.cpp b/TactilityC/Source/tt_hal.cpp deleted file mode 100644 index 875716e48..000000000 --- a/TactilityC/Source/tt_hal.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "tt_hal.h" - -#include -#include - -extern "C" { - -UiDensity tt_hal_configuration_get_ui_density() { - auto density = tt::hal::getConfiguration()->uiDensity; - return static_cast(density); -} - -UiScale tt_hal_configuration_get_ui_scale() { - auto density = tt::hal::getConfiguration()->uiDensity; - return static_cast(density); -} - -} diff --git a/TactilityC/Source/tt_hal_gpio.cpp b/TactilityC/Source/tt_hal_gpio.cpp deleted file mode 100644 index 114055a2b..000000000 --- a/TactilityC/Source/tt_hal_gpio.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "tt_hal_gpio.h" -#include -#include -#include - -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; -} - -} diff --git a/TactilityC/Source/tt_init.cpp b/TactilityC/Source/tt_init.cpp index 977e4d8c3..fe9c16d93 100644 --- a/TactilityC/Source/tt_init.cpp +++ b/TactilityC/Source/tt_init.cpp @@ -5,10 +5,8 @@ #include "tt_app_selectiondialog.h" #include "tt_bundle.h" #include "tt_gps.h" -#include "tt_hal.h" #include "tt_hal_device.h" #include "tt_hal_display.h" -#include "tt_hal_gpio.h" #include "tt_hal_touch.h" #include "tt_hal_uart.h" #include @@ -272,8 +270,6 @@ const esp_elfsym main_symbols[] { ESP_ELFSYM_EXPORT(tt_bundle_put_string), ESP_ELFSYM_EXPORT(tt_gps_has_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_display_driver_alloc), 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_unlock), 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_alloc), ESP_ELFSYM_EXPORT(tt_hal_touch_driver_free), From b9c01c339a5927de7bdd2e3745552e1e2906c0d9 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 15 Feb 2026 18:06:11 +0100 Subject: [PATCH 7/8] Fix for parsing density --- Modules/lvgl-module/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/lvgl-module/CMakeLists.txt b/Modules/lvgl-module/CMakeLists.txt index dd605e5e5..6c6484e8a 100644 --- a/Modules/lvgl-module/CMakeLists.txt +++ b/Modules/lvgl-module/CMakeLists.txt @@ -48,7 +48,7 @@ READ_PROPERTIES_TO_MAP( GET_VALUE_FROM_MAP(device_properties "[lvgl]uiDensity" ui_density) # Define UiDensity enum value if (ui_scale) - if (ui_scale == "normal") + if (ui_scale == "default") set(ui_density "LVGL_UI_DENSITY_DEFAULT") elif (ui_scale == "compact") set(ui_density "LVGL_UI_DENSITY_COMPACT") From 819e3ac966adeca566a30c5b2a0e03b389f81b33 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 15 Feb 2026 18:31:11 +0100 Subject: [PATCH 8/8] Fixes --- Devices/m5stack-tab5/Source/Configuration.cpp | 4 ++-- Modules/lvgl-module/CMakeLists.txt | 18 ++++++++++-------- .../include/tactility/lvgl_module.h | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Devices/m5stack-tab5/Source/Configuration.cpp b/Devices/m5stack-tab5/Source/Configuration.cpp index 4ce591177..1d31ba39b 100644 --- a/Devices/m5stack-tab5/Source/Configuration.cpp +++ b/Devices/m5stack-tab5/Source/Configuration.cpp @@ -142,7 +142,7 @@ static error_t initSound(::Device* i2c_controller) { constexpr auto IO_EXPANDER1_ADDRESS = 0x43; constexpr auto AMP_REGISTER = 0x05; // Note: to disable the amplifier, reset the bits - error = i2c_controller_register8_set_bits(i2c_controller, IO_EXPANDER1_ADDRESS, AMP_REGISTER, 0b00000010 , pdMS_TO_TICKS(100)); + error = i2c_controller_register8_set_bits(i2c_controller, IO_EXPANDER1_ADDRESS, AMP_REGISTER, 0b00000010, pdMS_TO_TICKS(100)); if (error != ERROR_NONE) { LOG_E(TAG, "Failed to enable amplifier: %s", error_to_string(error)); return error; @@ -156,7 +156,7 @@ static bool initBoot() { check(i2c0, "i2c0 not found"); auto error = initPower(i2c0); - if (initPower(i2c0) != ERROR_NONE) { + if (error != ERROR_NONE) { return false; } diff --git a/Modules/lvgl-module/CMakeLists.txt b/Modules/lvgl-module/CMakeLists.txt index 6c6484e8a..f0afa8aa0 100644 --- a/Modules/lvgl-module/CMakeLists.txt +++ b/Modules/lvgl-module/CMakeLists.txt @@ -14,7 +14,6 @@ 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_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) else () # Default values for simulator set(font_size_small 10) @@ -47,16 +46,19 @@ READ_PROPERTIES_TO_MAP( # Read UI density GET_VALUE_FROM_MAP(device_properties "[lvgl]uiDensity" ui_density) # Define UiDensity enum value -if (ui_scale) - if (ui_scale == "default") - set(ui_density "LVGL_UI_DENSITY_DEFAULT") - elif (ui_scale == "compact") - set(ui_density "LVGL_UI_DENSITY_COMPACT") +if (ui_density) + if (ui_density STREQUAL "default") + set(ui_density_variable "LVGL_UI_DENSITY_DEFAULT") + elseif (ui_density STREQUAL "compact") + set(ui_density_variable "LVGL_UI_DENSITY_COMPACT") else () message(FATAL_ERROR "Invalid [lvgl]uiDensity: '${ui_density}'. Must be either 'default' or 'compact'") endif () + message("UI density set to '${ui_density}' via properties") else () - set(ui_density "LVGL_UI_DENSITY_DEFAULT") + set(ui_density "default") + set(ui_density_variable "LVGL_UI_DENSITY_DEFAULT") + message("UI density set to default: ${ui_density}") endif () # #################################### @@ -109,5 +111,5 @@ target_compile_definitions(${MODULE_NAME} PUBLIC "-DTT_LVGL_SHARED_FONT_ICON_SIZE=${shared_symbol_size}" "-DTT_LVGL_SHARED_FONT_ICON_SYMBOL=material_symbols_shared_${shared_symbol_size}" # UiDensity - "-DTT_LVGL_UI_DENSITY=${ui_density}" + "-DTT_LVGL_UI_DENSITY=${ui_density_variable}" ) diff --git a/Modules/lvgl-module/include/tactility/lvgl_module.h b/Modules/lvgl-module/include/tactility/lvgl_module.h index 4548305d4..4fd5d9fda 100644 --- a/Modules/lvgl-module/include/tactility/lvgl_module.h +++ b/Modules/lvgl-module/include/tactility/lvgl_module.h @@ -97,7 +97,7 @@ 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. + * This setting is read by CMakeLists.txt and passed as a target compile definition of the LVGL module. * @return the UI density */ enum UiDensity lvgl_get_ui_density(void);