From f4df5f6890707385acdd38376b6f76bd28e079c9 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 8 Feb 2026 15:37:12 +0100 Subject: [PATCH] WIP --- .../cyd-2432s024c/Source/devices/Display.h | 1 - .../cyd-2432s028r/Source/devices/Display.h | 1 - .../cyd-2432s028rv3/Source/devices/Display.h | 1 - .../cyd-2432s032c/Source/devices/Display.h | 1 - Devices/cyd-e32r28t/Source/devices/Display.h | 1 - Devices/cyd-e32r32p/Source/devices/Display.h | 1 - .../Source/Configuration.cpp | 53 +-------- .../Source/devices/Display.h | 1 - .../Source/devices/SdCard.cpp | 7 +- .../elecrow,crowpanel-advance-28.dts | 23 ++++ .../Source/Configuration.cpp | 55 +-------- .../Source/devices/SdCard.cpp | 7 +- .../elecrow,crowpanel-advance-35.dts | 23 ++++ .../Source/Configuration.cpp | 28 +---- .../Source/devices/SdCard.cpp | 8 +- .../elecrow,crowpanel-advance-50.dts | 12 ++ .../Source/Configuration.cpp | 57 +--------- .../Source/devices/SdCard.cpp | 7 +- .../elecrow,crowpanel-basic-28.dts | 23 ++++ .../Source/Configuration.cpp | 59 +--------- .../Source/devices/SdCard.cpp | 7 +- .../elecrow,crowpanel-basic-35.dts | 23 ++++ .../Source/Configuration.cpp | 28 +---- .../Source/devices/SdCard.cpp | 7 +- .../elecrow,crowpanel-basic-50.dts | 12 ++ .../Source/Configuration.cpp | 53 +-------- .../Source/devices/Display.h | 1 - .../Source/devices/SdCard.cpp | 11 +- .../guition,jc2432w328c.dts | 23 ++++ .../Source/Axs15231b/Axs15231bDisplay.cpp | 1 - .../Source/Axs15231b/Axs15231bDisplay.h | 2 +- .../Source/Configuration.cpp | 57 +--------- .../Source/devices/SdCard.cpp | 10 +- .../guition,jc3248w535c.dts | 23 ++++ .../Source/Configuration.cpp | 28 +---- .../Source/devices/SdCard.cpp | 13 ++- .../guition,jc8048w550c.dts | 12 ++ .../Source/Configuration.cpp | 15 +-- .../Source/Configuration.cpp | 20 +--- Devices/lilygo-tdisplay-s3/Source/Init.cpp | 5 +- .../lilygo-tdisplay-s3/lilygo,tdisplay-s3.dts | 12 ++ .../lilygo-tdisplay/Source/Configuration.cpp | 28 +---- .../lilygo-tdisplay/Source/devices/Display.h | 1 - Devices/lilygo-tdisplay/lilygo,tdisplay.dts | 12 ++ .../Source/Configuration.cpp | 30 +---- .../Source/devices/Display.cpp | 2 +- .../lilygo-tdongle-s3/lilygo,tdongle-s3.dts | 12 ++ Devices/unphone/Source/Configuration.cpp | 2 - .../Source/Configuration.cpp | 2 +- Documentation/ideas.md | 3 + Drivers/ILI9488/Source/Ili9488Display.h | 1 - Drivers/RgbDisplay/Source/RgbDisplay.h | 7 +- Drivers/SSD1306/Source/Ssd1306Display.h | 1 - Drivers/ST7735/Source/St7735Display.h | 6 +- Drivers/XPT2046/Source/Xpt2046Power.cpp | 105 ------------------ Drivers/XPT2046/Source/Xpt2046Power.h | 28 ----- Drivers/XPT2046/Source/Xpt2046Touch.cpp | 16 --- Drivers/XPT2046/Source/Xpt2046Touch.h | 2 - Firmware/idf_component.yml | 2 +- Modules/lvgl-module/Source/arch/lvgl_esp32.c | 4 +- .../Include/Tactility/hal/Configuration.h | 10 +- Tactility/Source/service/wifi/WifiEsp.cpp | 28 +---- TactilityC/Source/tt_init.cpp | 28 +++-- .../tactility/concurrent/recursive_mutex.h | 3 +- 64 files changed, 327 insertions(+), 738 deletions(-) delete mode 100644 Drivers/XPT2046/Source/Xpt2046Power.cpp delete mode 100644 Drivers/XPT2046/Source/Xpt2046Power.h diff --git a/Devices/cyd-2432s024c/Source/devices/Display.h b/Devices/cyd-2432s024c/Source/devices/Display.h index f030fafa..da6b56e6 100644 --- a/Devices/cyd-2432s024c/Source/devices/Display.h +++ b/Devices/cyd-2432s024c/Source/devices/Display.h @@ -14,6 +14,5 @@ constexpr auto LCD_HORIZONTAL_RESOLUTION = 240; constexpr auto LCD_VERTICAL_RESOLUTION = 320; constexpr auto LCD_BUFFER_HEIGHT = LCD_VERTICAL_RESOLUTION / 10; constexpr auto LCD_BUFFER_SIZE = LCD_HORIZONTAL_RESOLUTION * LCD_BUFFER_HEIGHT; -constexpr auto LCD_SPI_TRANSFER_SIZE_LIMIT = LCD_BUFFER_SIZE * LV_COLOR_DEPTH / 8; std::shared_ptr createDisplay(); diff --git a/Devices/cyd-2432s028r/Source/devices/Display.h b/Devices/cyd-2432s028r/Source/devices/Display.h index 75b1c355..d3428a78 100644 --- a/Devices/cyd-2432s028r/Source/devices/Display.h +++ b/Devices/cyd-2432s028r/Source/devices/Display.h @@ -13,7 +13,6 @@ constexpr auto LCD_HORIZONTAL_RESOLUTION = 240; constexpr auto LCD_VERTICAL_RESOLUTION = 320; constexpr auto LCD_BUFFER_HEIGHT = LCD_VERTICAL_RESOLUTION / 10; constexpr auto LCD_BUFFER_SIZE = LCD_HORIZONTAL_RESOLUTION * LCD_BUFFER_HEIGHT; -constexpr auto LCD_SPI_TRANSFER_SIZE_LIMIT = LCD_BUFFER_SIZE * LV_COLOR_DEPTH / 8; // Display backlight (PWM) constexpr auto LCD_PIN_BACKLIGHT = GPIO_NUM_21; diff --git a/Devices/cyd-2432s028rv3/Source/devices/Display.h b/Devices/cyd-2432s028rv3/Source/devices/Display.h index 368b6aeb..67a09799 100644 --- a/Devices/cyd-2432s028rv3/Source/devices/Display.h +++ b/Devices/cyd-2432s028rv3/Source/devices/Display.h @@ -16,7 +16,6 @@ constexpr auto LCD_HORIZONTAL_RESOLUTION = 240; constexpr auto LCD_VERTICAL_RESOLUTION = 320; constexpr auto LCD_BUFFER_HEIGHT = LCD_VERTICAL_RESOLUTION / 10; constexpr auto LCD_BUFFER_SIZE = LCD_HORIZONTAL_RESOLUTION * LCD_BUFFER_HEIGHT; -constexpr auto LCD_SPI_TRANSFER_SIZE_LIMIT = LCD_BUFFER_SIZE * LV_COLOR_DEPTH / 8; // Touch (Software SPI) constexpr auto TOUCH_MISO_PIN = GPIO_NUM_39; diff --git a/Devices/cyd-2432s032c/Source/devices/Display.h b/Devices/cyd-2432s032c/Source/devices/Display.h index 541c3498..8a54f1e1 100644 --- a/Devices/cyd-2432s032c/Source/devices/Display.h +++ b/Devices/cyd-2432s032c/Source/devices/Display.h @@ -14,6 +14,5 @@ constexpr auto LCD_HORIZONTAL_RESOLUTION = 240; constexpr auto LCD_VERTICAL_RESOLUTION = 320; constexpr auto LCD_BUFFER_HEIGHT = LCD_VERTICAL_RESOLUTION / 10; constexpr auto LCD_BUFFER_SIZE = LCD_HORIZONTAL_RESOLUTION * LCD_BUFFER_HEIGHT; -constexpr auto LCD_SPI_TRANSFER_SIZE_LIMIT = LCD_BUFFER_SIZE * LV_COLOR_DEPTH / 8; std::shared_ptr createDisplay(); diff --git a/Devices/cyd-e32r28t/Source/devices/Display.h b/Devices/cyd-e32r28t/Source/devices/Display.h index b8cca620..fbe79f5a 100644 --- a/Devices/cyd-e32r28t/Source/devices/Display.h +++ b/Devices/cyd-e32r28t/Source/devices/Display.h @@ -13,7 +13,6 @@ constexpr auto LCD_HORIZONTAL_RESOLUTION = 240; constexpr auto LCD_VERTICAL_RESOLUTION = 320; constexpr auto LCD_BUFFER_HEIGHT = (LCD_VERTICAL_RESOLUTION / 10); constexpr auto LCD_BUFFER_SIZE = (LCD_HORIZONTAL_RESOLUTION * LCD_BUFFER_HEIGHT); -constexpr auto LCD_SPI_TRANSFER_SIZE_LIMIT = LCD_BUFFER_SIZE * LV_COLOR_DEPTH / 8; // Touch (Software SPI) constexpr auto TOUCH_MISO_PIN = GPIO_NUM_39; diff --git a/Devices/cyd-e32r32p/Source/devices/Display.h b/Devices/cyd-e32r32p/Source/devices/Display.h index 90eae75a..0106b091 100644 --- a/Devices/cyd-e32r32p/Source/devices/Display.h +++ b/Devices/cyd-e32r32p/Source/devices/Display.h @@ -14,7 +14,6 @@ constexpr auto DISPLAY_VERTICAL_RESOLUTION = 320; constexpr auto DISPLAY_DRAW_BUFFER_HEIGHT = (DISPLAY_VERTICAL_RESOLUTION / 10); constexpr auto DISPLAY_DRAW_BUFFER_SIZE = (DISPLAY_HORIZONTAL_RESOLUTION * DISPLAY_DRAW_BUFFER_HEIGHT); constexpr auto DISPLAY_BACKLIGHT_PIN = GPIO_NUM_27; -constexpr auto DISPLAY_SPI_TRANSFER_SIZE_LIMIT = DISPLAY_DRAW_BUFFER_SIZE * sizeof(lv_color_t); // Touch (XPT2046, resistive, shared SPI with display) constexpr auto TOUCH_MISO_PIN = GPIO_NUM_12; diff --git a/Devices/elecrow-crowpanel-advance-28/Source/Configuration.cpp b/Devices/elecrow-crowpanel-advance-28/Source/Configuration.cpp index 51cc6e32..09a0ca1f 100644 --- a/Devices/elecrow-crowpanel-advance-28/Source/Configuration.cpp +++ b/Devices/elecrow-crowpanel-advance-28/Source/Configuration.cpp @@ -4,7 +4,6 @@ #include #include -#include using namespace tt::hal; @@ -21,55 +20,5 @@ static DeviceVector createDevices() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .createDevices = createDevices, - .spi { - // Display - spi::Configuration { - .device = SPI2_HOST, - .dma = SPI_DMA_DISABLED, - .config = { - .mosi_io_num = GPIO_NUM_39, - .miso_io_num = GPIO_NUM_NC, - .sclk_io_num = GPIO_NUM_42, - .quadwp_io_num = GPIO_NUM_NC, - .quadhd_io_num = GPIO_NUM_NC, - .data4_io_num = GPIO_NUM_NC, - .data5_io_num = GPIO_NUM_NC, - .data6_io_num = GPIO_NUM_NC, - .data7_io_num = GPIO_NUM_NC, - .data_io_default_level = false, - .max_transfer_sz = LCD_SPI_TRANSFER_SIZE_LIMIT, - .flags = 0, - .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, - .intr_flags = 0 - }, - .initMode = spi::InitMode::ByTactility, - .isMutable = false, - .lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display - }, - // SD card - spi::Configuration { - .device = SPI3_HOST, - .dma = SPI_DMA_CH_AUTO, - .config = { - .mosi_io_num = GPIO_NUM_6, - .miso_io_num = GPIO_NUM_4, - .sclk_io_num = GPIO_NUM_5, - .quadwp_io_num = GPIO_NUM_NC, - .quadhd_io_num = GPIO_NUM_NC, - .data4_io_num = GPIO_NUM_NC, - .data5_io_num = GPIO_NUM_NC, - .data6_io_num = GPIO_NUM_NC, - .data7_io_num = GPIO_NUM_NC, - .data_io_default_level = false, - .max_transfer_sz = 32768, - .flags = 0, - .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, - .intr_flags = 0 - }, - .initMode = spi::InitMode::ByTactility, - .isMutable = false, - .lock = nullptr // No custom lock needed - } - } + .createDevices = createDevices }; diff --git a/Devices/elecrow-crowpanel-advance-28/Source/devices/Display.h b/Devices/elecrow-crowpanel-advance-28/Source/devices/Display.h index 6f986d05..7d579c12 100644 --- a/Devices/elecrow-crowpanel-advance-28/Source/devices/Display.h +++ b/Devices/elecrow-crowpanel-advance-28/Source/devices/Display.h @@ -12,6 +12,5 @@ constexpr auto LCD_HORIZONTAL_RESOLUTION = 240; constexpr auto LCD_VERTICAL_RESOLUTION = 320; constexpr auto LCD_BUFFER_HEIGHT = LCD_VERTICAL_RESOLUTION / 10; constexpr auto LCD_BUFFER_SIZE = LCD_HORIZONTAL_RESOLUTION * LCD_BUFFER_HEIGHT; -constexpr auto LCD_SPI_TRANSFER_SIZE_LIMIT = LCD_BUFFER_SIZE * LV_COLOR_DEPTH / 8; std::shared_ptr createDisplay(); diff --git a/Devices/elecrow-crowpanel-advance-28/Source/devices/SdCard.cpp b/Devices/elecrow-crowpanel-advance-28/Source/devices/SdCard.cpp index 1c011c3c..aba0191c 100644 --- a/Devices/elecrow-crowpanel-advance-28/Source/devices/SdCard.cpp +++ b/Devices/elecrow-crowpanel-advance-28/Source/devices/SdCard.cpp @@ -1,5 +1,6 @@ #include "SdCard.h" +#include #include #include @@ -19,7 +20,11 @@ std::shared_ptr createSdCard() { SPI3_HOST ); + auto* spi_controller = device_find_by_name("spi1"); + check(spi_controller, "spi1 not found"); + return std::make_shared( - std::move(configuration) + std::move(configuration), + spi_controller ); } diff --git a/Devices/elecrow-crowpanel-advance-28/elecrow,crowpanel-advance-28.dts b/Devices/elecrow-crowpanel-advance-28/elecrow,crowpanel-advance-28.dts index 9e729f0a..b798d91a 100644 --- a/Devices/elecrow-crowpanel-advance-28/elecrow,crowpanel-advance-28.dts +++ b/Devices/elecrow-crowpanel-advance-28/elecrow,crowpanel-advance-28.dts @@ -3,6 +3,7 @@ #include #include #include +#include #include / { @@ -24,6 +25,28 @@ pin-scl-pullup; }; + display_spi: spi0 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <39>; + pin-miso = ; + pin-sclk = <42>; + pin-wp = ; + pin-hd = ; + max-transfer-size = <0>; + }; + + sdcard_spi: spi1 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <6>; + pin-miso = <4>; + pin-sclk = <5>; + pin-wp = ; + pin-hd = ; + max-transfer-size = <0>; + }; + uart0 { compatible = "espressif,esp32-uart"; port = ; diff --git a/Devices/elecrow-crowpanel-advance-35/Source/Configuration.cpp b/Devices/elecrow-crowpanel-advance-35/Source/Configuration.cpp index 90f32beb..33bdf334 100644 --- a/Devices/elecrow-crowpanel-advance-35/Source/Configuration.cpp +++ b/Devices/elecrow-crowpanel-advance-35/Source/Configuration.cpp @@ -3,11 +3,8 @@ #include #include -#include #include -#define CROWPANEL_SPI_TRANSFER_SIZE_LIMIT (CROWPANEL_LCD_HORIZONTAL_RESOLUTION * CROWPANEL_LCD_SPI_TRANSFER_HEIGHT * (LV_COLOR_DEPTH / 8)) - using namespace tt::hal; static bool initBoot() { @@ -23,55 +20,5 @@ static DeviceVector createDevices() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .createDevices = createDevices, - .spi { - // Display - spi::Configuration { - .device = SPI2_HOST, - .dma = SPI_DMA_DISABLED, - .config = { - .mosi_io_num = GPIO_NUM_39, - .miso_io_num = GPIO_NUM_NC, - .sclk_io_num = GPIO_NUM_42, - .quadwp_io_num = GPIO_NUM_NC, - .quadhd_io_num = GPIO_NUM_NC, - .data4_io_num = GPIO_NUM_NC, - .data5_io_num = GPIO_NUM_NC, - .data6_io_num = GPIO_NUM_NC, - .data7_io_num = GPIO_NUM_NC, - .data_io_default_level = false, - .max_transfer_sz = CROWPANEL_SPI_TRANSFER_SIZE_LIMIT, - .flags = 0, - .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, - .intr_flags = 0 - }, - .initMode = spi::InitMode::ByTactility, - .isMutable = false, - .lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display - }, - // SD card - spi::Configuration { - .device = SPI3_HOST, - .dma = SPI_DMA_CH_AUTO, - .config = { - .mosi_io_num = GPIO_NUM_6, - .miso_io_num = GPIO_NUM_4, - .sclk_io_num = GPIO_NUM_5, - .quadwp_io_num = GPIO_NUM_NC, - .quadhd_io_num = GPIO_NUM_NC, - .data4_io_num = GPIO_NUM_NC, - .data5_io_num = GPIO_NUM_NC, - .data6_io_num = GPIO_NUM_NC, - .data7_io_num = GPIO_NUM_NC, - .data_io_default_level = false, - .max_transfer_sz = 32768, - .flags = 0, - .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, - .intr_flags = 0 - }, - .initMode = spi::InitMode::ByTactility, - .isMutable = false, - .lock = nullptr // No custom lock needed - } - } + .createDevices = createDevices }; diff --git a/Devices/elecrow-crowpanel-advance-35/Source/devices/SdCard.cpp b/Devices/elecrow-crowpanel-advance-35/Source/devices/SdCard.cpp index 1c011c3c..aba0191c 100644 --- a/Devices/elecrow-crowpanel-advance-35/Source/devices/SdCard.cpp +++ b/Devices/elecrow-crowpanel-advance-35/Source/devices/SdCard.cpp @@ -1,5 +1,6 @@ #include "SdCard.h" +#include #include #include @@ -19,7 +20,11 @@ std::shared_ptr createSdCard() { SPI3_HOST ); + auto* spi_controller = device_find_by_name("spi1"); + check(spi_controller, "spi1 not found"); + return std::make_shared( - std::move(configuration) + std::move(configuration), + spi_controller ); } diff --git a/Devices/elecrow-crowpanel-advance-35/elecrow,crowpanel-advance-35.dts b/Devices/elecrow-crowpanel-advance-35/elecrow,crowpanel-advance-35.dts index ba5260fa..ae6afc60 100644 --- a/Devices/elecrow-crowpanel-advance-35/elecrow,crowpanel-advance-35.dts +++ b/Devices/elecrow-crowpanel-advance-35/elecrow,crowpanel-advance-35.dts @@ -3,6 +3,7 @@ #include #include #include +#include #include / { @@ -24,6 +25,28 @@ pin-scl-pullup; }; + display_spi: spi0 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <39>; + pin-miso = ; + pin-sclk = <42>; + pin-wp = ; + pin-hd = ; + max-transfer-size = <0>; + }; + + sdcard_spi: spi1 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <6>; + pin-miso = <4>; + pin-sclk = <5>; + pin-wp = ; + pin-hd = ; + max-transfer-size = <0>; + }; + uart0 { compatible = "espressif,esp32-uart"; port = ; diff --git a/Devices/elecrow-crowpanel-advance-50/Source/Configuration.cpp b/Devices/elecrow-crowpanel-advance-50/Source/Configuration.cpp index 293c1f30..76b3a79d 100644 --- a/Devices/elecrow-crowpanel-advance-50/Source/Configuration.cpp +++ b/Devices/elecrow-crowpanel-advance-50/Source/Configuration.cpp @@ -31,31 +31,5 @@ static DeviceVector createDevices() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .createDevices = createDevices, - .spi { - // SD card - spi::Configuration { - .device = SPI2_HOST, - .dma = SPI_DMA_CH_AUTO, - .config = { - .mosi_io_num = GPIO_NUM_6, - .miso_io_num = GPIO_NUM_4, - .sclk_io_num = GPIO_NUM_5, - .quadwp_io_num = GPIO_NUM_NC, - .quadhd_io_num = GPIO_NUM_NC, - .data4_io_num = GPIO_NUM_NC, - .data5_io_num = GPIO_NUM_NC, - .data6_io_num = GPIO_NUM_NC, - .data7_io_num = GPIO_NUM_NC, - .data_io_default_level = false, - .max_transfer_sz = 8192, - .flags = 0, - .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, - .intr_flags = 0 - }, - .initMode = spi::InitMode::ByTactility, - .isMutable = false, - .lock = nullptr // No custom lock needed - } - } + .createDevices = createDevices }; diff --git a/Devices/elecrow-crowpanel-advance-50/Source/devices/SdCard.cpp b/Devices/elecrow-crowpanel-advance-50/Source/devices/SdCard.cpp index 3087262a..048f57ca 100644 --- a/Devices/elecrow-crowpanel-advance-50/Source/devices/SdCard.cpp +++ b/Devices/elecrow-crowpanel-advance-50/Source/devices/SdCard.cpp @@ -1,7 +1,7 @@ #include "SdCard.h" +#include #include -#include using tt::hal::sdcard::SpiSdCardDevice; @@ -15,7 +15,11 @@ std::shared_ptr createSdCard() { SdCardDevice::MountBehaviour::AtBoot ); + auto* spi_controller = device_find_by_name("spi0"); + check(spi_controller, "spi0 not found"); + return std::make_shared( - std::move(configuration) + std::move(configuration), + spi_controller ); } diff --git a/Devices/elecrow-crowpanel-advance-50/elecrow,crowpanel-advance-50.dts b/Devices/elecrow-crowpanel-advance-50/elecrow,crowpanel-advance-50.dts index ef593256..ef5d4554 100644 --- a/Devices/elecrow-crowpanel-advance-50/elecrow,crowpanel-advance-50.dts +++ b/Devices/elecrow-crowpanel-advance-50/elecrow,crowpanel-advance-50.dts @@ -3,6 +3,7 @@ #include #include #include +#include #include / { @@ -24,6 +25,17 @@ pin-scl-pullup; }; + sdcard_spi: spi0 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <6>; + pin-miso = <4>; + pin-sclk = <5>; + pin-wp = ; + pin-hd = ; + max-transfer-size = <0>; + }; + uart0 { compatible = "espressif,esp32-uart"; port = ; diff --git a/Devices/elecrow-crowpanel-basic-28/Source/Configuration.cpp b/Devices/elecrow-crowpanel-basic-28/Source/Configuration.cpp index f81c3f78..d773cbaa 100644 --- a/Devices/elecrow-crowpanel-basic-28/Source/Configuration.cpp +++ b/Devices/elecrow-crowpanel-basic-28/Source/Configuration.cpp @@ -4,8 +4,6 @@ #include #include -#include -#include using namespace tt::hal; @@ -15,63 +13,12 @@ static bool initBoot() { static DeviceVector createDevices() { return { - std::make_shared(), createDisplay(), - createSdCard(), + createSdCard() }; } extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .createDevices = createDevices, - .spi { - // Display - spi::Configuration { - .device = SPI2_HOST, - .dma = SPI_DMA_DISABLED, - .config = { - .mosi_io_num = GPIO_NUM_13, - .miso_io_num = GPIO_NUM_12, - .sclk_io_num = GPIO_NUM_14, - .quadwp_io_num = GPIO_NUM_NC, - .quadhd_io_num = GPIO_NUM_NC, - .data4_io_num = GPIO_NUM_NC, - .data5_io_num = GPIO_NUM_NC, - .data6_io_num = GPIO_NUM_NC, - .data7_io_num = GPIO_NUM_NC, - .data_io_default_level = false, - .max_transfer_sz = LCD_SPI_TRANSFER_SIZE_LIMIT, - .flags = 0, - .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, - .intr_flags = 0 - }, - .initMode = spi::InitMode::ByTactility, - .isMutable = false, - .lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display - }, - // SD card - spi::Configuration { - .device = SPI3_HOST, - .dma = SPI_DMA_CH_AUTO, - .config = { - .mosi_io_num = GPIO_NUM_23, - .miso_io_num = GPIO_NUM_19, - .sclk_io_num = GPIO_NUM_18, - .quadwp_io_num = GPIO_NUM_NC, - .quadhd_io_num = GPIO_NUM_NC, - .data4_io_num = GPIO_NUM_NC, - .data5_io_num = GPIO_NUM_NC, - .data6_io_num = GPIO_NUM_NC, - .data7_io_num = GPIO_NUM_NC, - .data_io_default_level = false, - .max_transfer_sz = 32768, - .flags = 0, - .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, - .intr_flags = 0 - }, - .initMode = spi::InitMode::ByTactility, - .isMutable = false, - .lock = nullptr // No custom lock needed - } - } + .createDevices = createDevices }; diff --git a/Devices/elecrow-crowpanel-basic-28/Source/devices/SdCard.cpp b/Devices/elecrow-crowpanel-basic-28/Source/devices/SdCard.cpp index 3103ad3d..38cfc75b 100644 --- a/Devices/elecrow-crowpanel-basic-28/Source/devices/SdCard.cpp +++ b/Devices/elecrow-crowpanel-basic-28/Source/devices/SdCard.cpp @@ -1,5 +1,6 @@ #include "SdCard.h" +#include #include #include @@ -17,7 +18,11 @@ std::shared_ptr createSdCard() { SPI3_HOST ); + auto* spi_controller = device_find_by_name("spi1"); + check(spi_controller, "spi1 not found"); + return std::make_shared( - std::move(configuration) + std::move(configuration), + spi_controller ); } diff --git a/Devices/elecrow-crowpanel-basic-28/elecrow,crowpanel-basic-28.dts b/Devices/elecrow-crowpanel-basic-28/elecrow,crowpanel-basic-28.dts index 5b60dbab..e151ef58 100644 --- a/Devices/elecrow-crowpanel-basic-28/elecrow,crowpanel-basic-28.dts +++ b/Devices/elecrow-crowpanel-basic-28/elecrow,crowpanel-basic-28.dts @@ -3,6 +3,7 @@ #include #include #include +#include #include / { @@ -24,6 +25,28 @@ pin-scl-pullup; }; + display_spi: spi0 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <13>; + pin-miso = <12>; + pin-sclk = <14>; + pin-wp = ; + pin-hd = ; + max-transfer-size = <0>; + }; + + sdcard_spi: spi1 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <23>; + pin-miso = <19>; + pin-sclk = <18>; + pin-wp = ; + pin-hd = ; + max-transfer-size = <0>; + }; + uart1 { compatible = "espressif,esp32-uart"; port = ; diff --git a/Devices/elecrow-crowpanel-basic-35/Source/Configuration.cpp b/Devices/elecrow-crowpanel-basic-35/Source/Configuration.cpp index 88244420..d773cbaa 100644 --- a/Devices/elecrow-crowpanel-basic-35/Source/Configuration.cpp +++ b/Devices/elecrow-crowpanel-basic-35/Source/Configuration.cpp @@ -1,13 +1,9 @@ #include "PwmBacklight.h" -#include "Tactility/lvgl/LvglSync.h" #include "devices/Display.h" #include "devices/SdCard.h" #include #include -#include - -constexpr auto CROWPANEL_SPI_TRANSFER_SIZE_LIMIT = (CROWPANEL_LCD_HORIZONTAL_RESOLUTION * CROWPANEL_LCD_SPI_TRANSFER_HEIGHT * (LV_COLOR_DEPTH / 8)); using namespace tt::hal; @@ -17,63 +13,12 @@ static bool initBoot() { static DeviceVector createDevices() { return { - std::make_shared(), createDisplay(), - createSdCard(), + createSdCard() }; } extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .createDevices = createDevices, - .spi { - // Display - spi::Configuration { - .device = SPI2_HOST, - .dma = SPI_DMA_DISABLED, - .config = { - .mosi_io_num = GPIO_NUM_13, - .miso_io_num = GPIO_NUM_33, - .sclk_io_num = GPIO_NUM_14, - .quadwp_io_num = GPIO_NUM_NC, - .quadhd_io_num = GPIO_NUM_NC, - .data4_io_num = GPIO_NUM_NC, - .data5_io_num = GPIO_NUM_NC, - .data6_io_num = GPIO_NUM_NC, - .data7_io_num = GPIO_NUM_NC, - .data_io_default_level = false, - .max_transfer_sz = CROWPANEL_SPI_TRANSFER_SIZE_LIMIT, - .flags = 0, - .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, - .intr_flags = 0 - }, - .initMode = spi::InitMode::ByTactility, - .isMutable = false, - .lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display - }, - // SD card - spi::Configuration { - .device = SPI3_HOST, - .dma = SPI_DMA_CH_AUTO, - .config = { - .mosi_io_num = GPIO_NUM_23, - .miso_io_num = GPIO_NUM_19, - .sclk_io_num = GPIO_NUM_18, - .quadwp_io_num = GPIO_NUM_NC, - .quadhd_io_num = GPIO_NUM_NC, - .data4_io_num = GPIO_NUM_NC, - .data5_io_num = GPIO_NUM_NC, - .data6_io_num = GPIO_NUM_NC, - .data7_io_num = GPIO_NUM_NC, - .data_io_default_level = false, - .max_transfer_sz = 32768, - .flags = 0, - .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, - .intr_flags = 0 - }, - .initMode = spi::InitMode::ByTactility, - .isMutable = false, - .lock = nullptr // No custom lock needed - } - } + .createDevices = createDevices }; diff --git a/Devices/elecrow-crowpanel-basic-35/Source/devices/SdCard.cpp b/Devices/elecrow-crowpanel-basic-35/Source/devices/SdCard.cpp index 3103ad3d..38cfc75b 100644 --- a/Devices/elecrow-crowpanel-basic-35/Source/devices/SdCard.cpp +++ b/Devices/elecrow-crowpanel-basic-35/Source/devices/SdCard.cpp @@ -1,5 +1,6 @@ #include "SdCard.h" +#include #include #include @@ -17,7 +18,11 @@ std::shared_ptr createSdCard() { SPI3_HOST ); + auto* spi_controller = device_find_by_name("spi1"); + check(spi_controller, "spi1 not found"); + return std::make_shared( - std::move(configuration) + std::move(configuration), + spi_controller ); } diff --git a/Devices/elecrow-crowpanel-basic-35/elecrow,crowpanel-basic-35.dts b/Devices/elecrow-crowpanel-basic-35/elecrow,crowpanel-basic-35.dts index 1978876e..aada9daa 100644 --- a/Devices/elecrow-crowpanel-basic-35/elecrow,crowpanel-basic-35.dts +++ b/Devices/elecrow-crowpanel-basic-35/elecrow,crowpanel-basic-35.dts @@ -3,6 +3,7 @@ #include #include #include +#include #include / { @@ -24,6 +25,28 @@ pin-scl-pullup; }; + display_spi: spi0 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <13>; + pin-miso = <33>; + pin-sclk = <14>; + pin-wp = ; + pin-hd = ; + max-transfer-size = <0>; + }; + + sdcard_spi: spi1 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <23>; + pin-miso = <19>; + pin-sclk = <18>; + pin-wp = ; + pin-hd = ; + max-transfer-size = <0>; + }; + uart1 { compatible = "espressif,esp32-uart"; port = ; diff --git a/Devices/elecrow-crowpanel-basic-50/Source/Configuration.cpp b/Devices/elecrow-crowpanel-basic-50/Source/Configuration.cpp index b9da4fd2..9df5ad4a 100644 --- a/Devices/elecrow-crowpanel-basic-50/Source/Configuration.cpp +++ b/Devices/elecrow-crowpanel-basic-50/Source/Configuration.cpp @@ -21,31 +21,5 @@ static DeviceVector createDevices() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .createDevices = createDevices, - .spi { - // SD card - spi::Configuration { - .device = SPI2_HOST, - .dma = SPI_DMA_CH_AUTO, - .config = { - .mosi_io_num = GPIO_NUM_11, - .miso_io_num = GPIO_NUM_13, - .sclk_io_num = GPIO_NUM_12, - .quadwp_io_num = GPIO_NUM_NC, - .quadhd_io_num = GPIO_NUM_NC, - .data4_io_num = GPIO_NUM_NC, - .data5_io_num = GPIO_NUM_NC, - .data6_io_num = GPIO_NUM_NC, - .data7_io_num = GPIO_NUM_NC, - .data_io_default_level = false, - .max_transfer_sz = 8192, - .flags = 0, - .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, - .intr_flags = 0 - }, - .initMode = spi::InitMode::ByTactility, - .isMutable = false, - .lock = nullptr - } - } + .createDevices = createDevices }; diff --git a/Devices/elecrow-crowpanel-basic-50/Source/devices/SdCard.cpp b/Devices/elecrow-crowpanel-basic-50/Source/devices/SdCard.cpp index a27db36c..dbf0f03f 100644 --- a/Devices/elecrow-crowpanel-basic-50/Source/devices/SdCard.cpp +++ b/Devices/elecrow-crowpanel-basic-50/Source/devices/SdCard.cpp @@ -1,5 +1,6 @@ #include "SdCard.h" +#include #include using tt::hal::sdcard::SpiSdCardDevice; @@ -13,7 +14,11 @@ std::shared_ptr createSdCard() { SdCardDevice::MountBehaviour::AtBoot ); + auto* spi_controller = device_find_by_name("spi0"); + check(spi_controller, "spi0 not found"); + return std::make_shared( - std::move(configuration) + std::move(configuration), + spi_controller ); } diff --git a/Devices/elecrow-crowpanel-basic-50/elecrow,crowpanel-basic-50.dts b/Devices/elecrow-crowpanel-basic-50/elecrow,crowpanel-basic-50.dts index 43493e3a..02d14548 100644 --- a/Devices/elecrow-crowpanel-basic-50/elecrow,crowpanel-basic-50.dts +++ b/Devices/elecrow-crowpanel-basic-50/elecrow,crowpanel-basic-50.dts @@ -3,6 +3,7 @@ #include #include #include +#include #include / { @@ -24,6 +25,17 @@ pin-scl-pullup; }; + sdcard_spi: spi0 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <11>; + pin-miso = <13>; + pin-sclk = <12>; + pin-wp = ; + pin-hd = ; + max-transfer-size = <0>; + }; + uart0 { compatible = "espressif,esp32-uart"; port = ; diff --git a/Devices/guition-jc2432w328c/Source/Configuration.cpp b/Devices/guition-jc2432w328c/Source/Configuration.cpp index 4ad1382a..ee79f6c6 100644 --- a/Devices/guition-jc2432w328c/Source/Configuration.cpp +++ b/Devices/guition-jc2432w328c/Source/Configuration.cpp @@ -4,7 +4,6 @@ #include #include -#include using namespace tt::hal; @@ -31,55 +30,5 @@ static DeviceVector createDevices() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .createDevices = createDevices, - .spi { - //Display - spi::Configuration { - .device = SPI2_HOST, - .dma = SPI_DMA_CH_AUTO, - .config = { - .mosi_io_num = GPIO_NUM_13, - .miso_io_num = GPIO_NUM_NC, - .sclk_io_num = GPIO_NUM_14, - .quadwp_io_num = GPIO_NUM_NC, - .quadhd_io_num = GPIO_NUM_NC, - .data4_io_num = GPIO_NUM_NC, - .data5_io_num = GPIO_NUM_NC, - .data6_io_num = GPIO_NUM_NC, - .data7_io_num = GPIO_NUM_NC, - .data_io_default_level = false, - .max_transfer_sz = LCD_SPI_TRANSFER_SIZE_LIMIT, - .flags = 0, - .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, - .intr_flags = 0 - }, - .initMode = spi::InitMode::ByTactility, - .isMutable = false, - .lock = tt::lvgl::getSyncLock() - }, - //SD Card - spi::Configuration { - .device = SPI3_HOST, - .dma = SPI_DMA_CH_AUTO, - .config = { - .mosi_io_num = GPIO_NUM_23, - .miso_io_num = GPIO_NUM_19, - .sclk_io_num = GPIO_NUM_18, - .quadwp_io_num = GPIO_NUM_NC, - .quadhd_io_num = GPIO_NUM_NC, - .data4_io_num = GPIO_NUM_NC, - .data5_io_num = GPIO_NUM_NC, - .data6_io_num = GPIO_NUM_NC, - .data7_io_num = GPIO_NUM_NC, - .data_io_default_level = false, - .max_transfer_sz = 8192, - .flags = 0, - .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, - .intr_flags = 0 - }, - .initMode = spi::InitMode::ByTactility, - .isMutable = false, - .lock = nullptr - } - } + .createDevices = createDevices }; diff --git a/Devices/guition-jc2432w328c/Source/devices/Display.h b/Devices/guition-jc2432w328c/Source/devices/Display.h index 5a00ee0c..26e2214a 100644 --- a/Devices/guition-jc2432w328c/Source/devices/Display.h +++ b/Devices/guition-jc2432w328c/Source/devices/Display.h @@ -18,6 +18,5 @@ constexpr auto LCD_HORIZONTAL_RESOLUTION = 240; constexpr auto LCD_VERTICAL_RESOLUTION = 320; constexpr auto LCD_BUFFER_HEIGHT = LCD_VERTICAL_RESOLUTION / 10; constexpr auto LCD_BUFFER_SIZE = LCD_HORIZONTAL_RESOLUTION * LCD_BUFFER_HEIGHT; -constexpr auto LCD_SPI_TRANSFER_SIZE_LIMIT = LCD_BUFFER_SIZE * LV_COLOR_DEPTH / 8; std::shared_ptr createDisplay(); diff --git a/Devices/guition-jc2432w328c/Source/devices/SdCard.cpp b/Devices/guition-jc2432w328c/Source/devices/SdCard.cpp index 84360cfa..45238df8 100644 --- a/Devices/guition-jc2432w328c/Source/devices/SdCard.cpp +++ b/Devices/guition-jc2432w328c/Source/devices/SdCard.cpp @@ -1,8 +1,7 @@ #include "SdCard.h" +#include #include -#include -#include constexpr auto SDCARD_SPI_HOST = SPI3_HOST; constexpr auto SDCARD_PIN_CS = GPIO_NUM_5; @@ -16,13 +15,17 @@ std::shared_ptr createSdCard() { GPIO_NUM_NC, GPIO_NUM_NC, SdCardDevice::MountBehaviour::AtBoot, - std::make_shared(), + nullptr, std::vector(), SDCARD_SPI_HOST ); + auto* spi_controller = device_find_by_name("spi1"); + check(spi_controller, "spi1 not found"); + return std::make_shared( - std::move(configuration) + std::move(configuration), + spi_controller ); } diff --git a/Devices/guition-jc2432w328c/guition,jc2432w328c.dts b/Devices/guition-jc2432w328c/guition,jc2432w328c.dts index 24c50b62..82735e0c 100644 --- a/Devices/guition-jc2432w328c/guition,jc2432w328c.dts +++ b/Devices/guition-jc2432w328c/guition,jc2432w328c.dts @@ -3,6 +3,7 @@ #include #include #include +#include #include / { @@ -31,6 +32,28 @@ pin-scl = <22>; }; + display_spi: spi0 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <13>; + pin-miso = ; + pin-sclk = <14>; + pin-wp = ; + pin-hd = ; + max-transfer-size = <0>; + }; + + sdcard_spi: spi1 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <23>; + pin-miso = <19>; + pin-sclk = <18>; + pin-wp = ; + pin-hd = ; + max-transfer-size = <0>; + }; + // CN1 header, JST SH 1.25, GND / IO22 / IO21 / 3.3V uart1 { compatible = "espressif,esp32-uart"; diff --git a/Devices/guition-jc3248w535c/Source/Axs15231b/Axs15231bDisplay.cpp b/Devices/guition-jc3248w535c/Source/Axs15231b/Axs15231bDisplay.cpp index 644dfa44..e2c8bc4e 100644 --- a/Devices/guition-jc3248w535c/Source/Axs15231b/Axs15231bDisplay.cpp +++ b/Devices/guition-jc3248w535c/Source/Axs15231b/Axs15231bDisplay.cpp @@ -485,7 +485,6 @@ std::shared_ptr Axs15231bDisplay::getDisplayDri if (displayDriver == nullptr) { displayDriver = std::make_shared( panelHandle, - tt::lvgl::getSyncLock(), configuration->horizontalResolution, configuration->verticalResolution, tt::hal::display::ColorFormat::RGB565Swapped diff --git a/Devices/guition-jc3248w535c/Source/Axs15231b/Axs15231bDisplay.h b/Devices/guition-jc3248w535c/Source/Axs15231b/Axs15231bDisplay.h index 397d0388..18a3040d 100644 --- a/Devices/guition-jc3248w535c/Source/Axs15231b/Axs15231bDisplay.h +++ b/Devices/guition-jc3248w535c/Source/Axs15231b/Axs15231bDisplay.h @@ -25,7 +25,7 @@ public: gpio_num_t csPin, gpio_num_t dcPin, gpio_num_t resetPin, - + gpio_num_t tePin, unsigned int horizontalResolution, unsigned int verticalResolution, std::shared_ptr touch, diff --git a/Devices/guition-jc3248w535c/Source/Configuration.cpp b/Devices/guition-jc3248w535c/Source/Configuration.cpp index 29c1d713..0ceef45a 100644 --- a/Devices/guition-jc3248w535c/Source/Configuration.cpp +++ b/Devices/guition-jc3248w535c/Source/Configuration.cpp @@ -3,13 +3,10 @@ #include #include -#include #include using namespace tt::hal; -static constexpr int SPI_TRANSFER_SIZE_LIMIT = 320 * 10; - static DeviceVector createDevices() { return { createDisplay(), @@ -23,57 +20,5 @@ static bool initBoot() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .createDevices = createDevices, - //I2C Internal - Touch - //I2C External - P3 (JST SH 1.0)/ P4 (JST SH 1.25) headers - GND 3.3V IO17 IO18 - .spi { - //Display - spi::Configuration { - .device = SPI2_HOST, - .dma = SPI_DMA_CH_AUTO, - .config = { - .data0_io_num = GPIO_NUM_21, - .data1_io_num = GPIO_NUM_48, - .sclk_io_num = GPIO_NUM_47, - .data2_io_num = GPIO_NUM_40, - .data3_io_num = GPIO_NUM_39, - .data4_io_num = -1, - .data5_io_num = -1, - .data6_io_num = -1, - .data7_io_num = -1, - .data_io_default_level = false, - .max_transfer_sz = SPI_TRANSFER_SIZE_LIMIT, - .flags = 0, - .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, - .intr_flags = 0 - }, - .initMode = spi::InitMode::ByTactility, - .isMutable = false, - .lock = tt::lvgl::getSyncLock() - }, - //SD Card - spi::Configuration { - .device = SPI3_HOST, - .dma = SPI_DMA_CH_AUTO, - .config = { - .mosi_io_num = GPIO_NUM_11, - .miso_io_num = GPIO_NUM_13, - .sclk_io_num = GPIO_NUM_12, - .quadwp_io_num = -1, - .quadhd_io_num = -1, - .data4_io_num = -1, - .data5_io_num = -1, - .data6_io_num = -1, - .data7_io_num = -1, - .data_io_default_level = false, - .max_transfer_sz = 8192, - .flags = 0, - .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, - .intr_flags = 0 - }, - .initMode = spi::InitMode::ByTactility, - .isMutable = false, - .lock = nullptr - } - } + .createDevices = createDevices }; diff --git a/Devices/guition-jc3248w535c/Source/devices/SdCard.cpp b/Devices/guition-jc3248w535c/Source/devices/SdCard.cpp index 8648798b..e4b2e234 100644 --- a/Devices/guition-jc3248w535c/Source/devices/SdCard.cpp +++ b/Devices/guition-jc3248w535c/Source/devices/SdCard.cpp @@ -1,7 +1,7 @@ #include "SdCard.h" +#include #include -#include constexpr auto SDCARD_SPI_HOST = SPI3_HOST; constexpr auto SDCARD_PIN_CS = GPIO_NUM_10; @@ -15,12 +15,16 @@ std::shared_ptr createSdCard() { GPIO_NUM_NC, GPIO_NUM_NC, SdCardDevice::MountBehaviour::AtBoot, - std::make_shared(), + nullptr, std::vector(), SDCARD_SPI_HOST ); + auto* spi_controller = device_find_by_name("spi1"); + check(spi_controller, "spi1 not found"); + return std::make_shared( - std::move(configuration) + std::move(configuration), + spi_controller ); } diff --git a/Devices/guition-jc3248w535c/guition,jc3248w535c.dts b/Devices/guition-jc3248w535c/guition,jc3248w535c.dts index 326df34c..16d548f0 100644 --- a/Devices/guition-jc3248w535c/guition,jc3248w535c.dts +++ b/Devices/guition-jc3248w535c/guition,jc3248w535c.dts @@ -3,6 +3,7 @@ #include #include #include +#include #include / { @@ -34,6 +35,28 @@ pin-scl-pullup; }; + display_spi: spi0 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <21>; + pin-miso = <48>; + pin-sclk = <47>; + pin-wp = <40>; + pin-hd = <39>; + max-transfer-size = <0>; + }; + + sdcard_spi: spi1 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <11>; + pin-miso = <13>; + pin-sclk = <12>; + pin-wp = ; + pin-hd = ; + max-transfer-size = <0>; + }; + // P1 header uart0 { compatible = "espressif,esp32-uart"; diff --git a/Devices/guition-jc8048w550c/Source/Configuration.cpp b/Devices/guition-jc8048w550c/Source/Configuration.cpp index a6e82c6a..174ca14f 100644 --- a/Devices/guition-jc8048w550c/Source/Configuration.cpp +++ b/Devices/guition-jc8048w550c/Source/Configuration.cpp @@ -20,31 +20,5 @@ static DeviceVector createDevices() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .createDevices = createDevices, - .spi { - //SD Card - spi::Configuration { - .device = SPI2_HOST, - .dma = SPI_DMA_CH_AUTO, - .config = { - .mosi_io_num = GPIO_NUM_11, - .miso_io_num = GPIO_NUM_13, - .sclk_io_num = GPIO_NUM_12, - .quadwp_io_num = GPIO_NUM_NC, - .quadhd_io_num = GPIO_NUM_NC, - .data4_io_num = GPIO_NUM_NC, - .data5_io_num = GPIO_NUM_NC, - .data6_io_num = GPIO_NUM_NC, - .data7_io_num = GPIO_NUM_NC, - .data_io_default_level = false, - .max_transfer_sz = 8192, - .flags = 0, - .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, - .intr_flags = 0 - }, - .initMode = spi::InitMode::ByTactility, - .isMutable = false, - .lock = nullptr - } - } + .createDevices = createDevices }; diff --git a/Devices/guition-jc8048w550c/Source/devices/SdCard.cpp b/Devices/guition-jc8048w550c/Source/devices/SdCard.cpp index 153440cf..876fca40 100644 --- a/Devices/guition-jc8048w550c/Source/devices/SdCard.cpp +++ b/Devices/guition-jc8048w550c/Source/devices/SdCard.cpp @@ -1,5 +1,6 @@ #include "SdCard.h" +#include #include #include #include @@ -13,14 +14,16 @@ std::shared_ptr createSdCard() { GPIO_NUM_NC, GPIO_NUM_NC, SdCardDevice::MountBehaviour::AtBoot, - std::make_shared(), + nullptr, std::vector(), SPI2_HOST ); - auto sdcard = std::make_shared( - std::move(config) - ); + auto* spi_controller = device_find_by_name("spi0"); + check(spi_controller, "spi0 not found"); - return std::static_pointer_cast(sdcard); + return std::make_shared( + std::move(config), + spi_controller + ); } diff --git a/Devices/guition-jc8048w550c/guition,jc8048w550c.dts b/Devices/guition-jc8048w550c/guition,jc8048w550c.dts index b0514a67..1c71247d 100644 --- a/Devices/guition-jc8048w550c/guition,jc8048w550c.dts +++ b/Devices/guition-jc8048w550c/guition,jc8048w550c.dts @@ -3,6 +3,7 @@ #include #include #include +#include #include / { @@ -34,6 +35,17 @@ pin-scl-pullup; }; + spi0 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <11>; + pin-miso = <13>; + pin-sclk = <12>; + pin-wp = ; + pin-hd = ; + max-transfer-size = <0>; + }; + uart1 { compatible = "espressif,esp32-uart"; port = ; diff --git a/Devices/heltec-wifi-lora-32-v3/Source/Configuration.cpp b/Devices/heltec-wifi-lora-32-v3/Source/Configuration.cpp index 48eca3dd..c6d3b1f0 100644 --- a/Devices/heltec-wifi-lora-32-v3/Source/Configuration.cpp +++ b/Devices/heltec-wifi-lora-32-v3/Source/Configuration.cpp @@ -2,15 +2,13 @@ #include "devices/Power.h" #include "devices/Constants.h" +#include +#include + #include -#include -#include #include -#include "driver/gpio.h" -#include "driver/i2c.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" +#include static void enableOledPower() { gpio_config_t io_conf = { @@ -24,7 +22,7 @@ static void enableOledPower() { gpio_set_level(DISPLAY_PIN_POWER, 0); // Active low vTaskDelay(pdMS_TO_TICKS(500)); // Add a small delay for power to stabilize - tt::Logger("HeltecV3").info("OLED power enabled"); + LOG_I("HeltecV3", "OLED power enabled"); } static bool initBoot() { @@ -47,6 +45,5 @@ static std::vector> createDevices() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, .uiScale = UiScale::Smallest, - .createDevices = createDevices, - .spi {}, + .createDevices = createDevices }; diff --git a/Devices/lilygo-tdisplay-s3/Source/Configuration.cpp b/Devices/lilygo-tdisplay-s3/Source/Configuration.cpp index 61287a60..bc5b8054 100644 --- a/Devices/lilygo-tdisplay-s3/Source/Configuration.cpp +++ b/Devices/lilygo-tdisplay-s3/Source/Configuration.cpp @@ -1,9 +1,7 @@ #include "devices/Display.h" #include "devices/Power.h" -#include #include -#include #include bool initBoot(); @@ -20,21 +18,5 @@ static std::vector> createDevices() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, - .createDevices = createDevices, - .spi { - spi::Configuration { - .device = SPI2_HOST, - .dma = SPI_DMA_CH_AUTO, - .config = { - .mosi_io_num = GPIO_NUM_7, - .miso_io_num = GPIO_NUM_NC, - .sclk_io_num = GPIO_NUM_6, - .max_transfer_sz = DISPLAY_HORIZONTAL_RESOLUTION * DISPLAY_VERTICAL_RESOLUTION * 2, - .flags = 0 - }, - .initMode = spi::InitMode::ByTactility, - .isMutable = false, - .lock = tt::lvgl::getSyncLock() - } - } + .createDevices = createDevices }; diff --git a/Devices/lilygo-tdisplay-s3/Source/Init.cpp b/Devices/lilygo-tdisplay-s3/Source/Init.cpp index 754b72f5..1ce00d08 100644 --- a/Devices/lilygo-tdisplay-s3/Source/Init.cpp +++ b/Devices/lilygo-tdisplay-s3/Source/Init.cpp @@ -7,9 +7,6 @@ #define TAG "tdisplay-s3" -// Power on - - static bool powerOn() { gpio_config_t power_signal_config = { .pin_bit_mask = BIT64(TDISPLAY_S3_POWERON_GPIO), @@ -27,7 +24,7 @@ static bool powerOn() { return false; } - + return true; } bool initBoot() { diff --git a/Devices/lilygo-tdisplay-s3/lilygo,tdisplay-s3.dts b/Devices/lilygo-tdisplay-s3/lilygo,tdisplay-s3.dts index d626d6b3..723d6dcd 100644 --- a/Devices/lilygo-tdisplay-s3/lilygo,tdisplay-s3.dts +++ b/Devices/lilygo-tdisplay-s3/lilygo,tdisplay-s3.dts @@ -3,6 +3,7 @@ #include #include #include +#include / { compatible = "root"; @@ -12,4 +13,15 @@ compatible = "espressif,esp32-gpio"; gpio-count = <49>; }; + + spi0 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <7>; + pin-miso = ; + pin-sclk = <6>; + pin-wp = ; + pin-hd = ; + max-transfer-size = <0>; + }; }; diff --git a/Devices/lilygo-tdisplay/Source/Configuration.cpp b/Devices/lilygo-tdisplay/Source/Configuration.cpp index 9c049e35..cb68ebfc 100644 --- a/Devices/lilygo-tdisplay/Source/Configuration.cpp +++ b/Devices/lilygo-tdisplay/Source/Configuration.cpp @@ -1,9 +1,7 @@ #include "devices/Display.h" -#include #include #include -#include #include using namespace tt::hal; @@ -22,29 +20,5 @@ static std::vector> createDevices() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, .uiScale = UiScale::Smallest, - .createDevices = createDevices, - .spi { - spi::Configuration { - .device = SPI2_HOST, - .dma = SPI_DMA_CH_AUTO, - .config = { - .mosi_io_num = GPIO_NUM_19, - .miso_io_num = GPIO_NUM_NC, - .sclk_io_num = GPIO_NUM_18, - .quadwp_io_num = GPIO_NUM_NC, - .data4_io_num = GPIO_NUM_NC, - .data5_io_num = GPIO_NUM_NC, - .data6_io_num = GPIO_NUM_NC, - .data7_io_num = GPIO_NUM_NC, - .data_io_default_level = false, - .max_transfer_sz = LCD_SPI_TRANSFER_SIZE_LIMIT, - .flags = 0, - .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, - .intr_flags = 0 - }, - .initMode = spi::InitMode::ByTactility, - .isMutable = false, - .lock = tt::lvgl::getSyncLock() - } - } + .createDevices = createDevices }; diff --git a/Devices/lilygo-tdisplay/Source/devices/Display.h b/Devices/lilygo-tdisplay/Source/devices/Display.h index a11933b3..7a8c13b5 100644 --- a/Devices/lilygo-tdisplay/Source/devices/Display.h +++ b/Devices/lilygo-tdisplay/Source/devices/Display.h @@ -14,6 +14,5 @@ constexpr auto LCD_HORIZONTAL_RESOLUTION = 135; constexpr auto LCD_VERTICAL_RESOLUTION = 240; constexpr auto LCD_BUFFER_HEIGHT = LCD_VERTICAL_RESOLUTION / 3; constexpr auto LCD_BUFFER_SIZE = LCD_HORIZONTAL_RESOLUTION * LCD_BUFFER_HEIGHT; -constexpr auto LCD_SPI_TRANSFER_SIZE_LIMIT = LCD_BUFFER_SIZE * LV_COLOR_DEPTH / 8; std::shared_ptr createDisplay(); diff --git a/Devices/lilygo-tdisplay/lilygo,tdisplay.dts b/Devices/lilygo-tdisplay/lilygo,tdisplay.dts index b7002491..994b065c 100644 --- a/Devices/lilygo-tdisplay/lilygo,tdisplay.dts +++ b/Devices/lilygo-tdisplay/lilygo,tdisplay.dts @@ -3,6 +3,7 @@ #include #include #include +#include / { compatible = "root"; @@ -12,4 +13,15 @@ compatible = "espressif,esp32-gpio"; gpio-count = <49>; }; + + spi0 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <19>; + pin-miso = ; + pin-sclk = <18>; + pin-wp = ; + pin-hd = ; + max-transfer-size = <0>; + }; }; diff --git a/Devices/lilygo-tdongle-s3/Source/Configuration.cpp b/Devices/lilygo-tdongle-s3/Source/Configuration.cpp index 1e1adb26..acec5b45 100644 --- a/Devices/lilygo-tdongle-s3/Source/Configuration.cpp +++ b/Devices/lilygo-tdongle-s3/Source/Configuration.cpp @@ -1,11 +1,7 @@ #include "devices/Display.h" #include "devices/Sdcard.h" -#include #include -#include - -#define TDECK_SPI_TRANSFER_SIZE_LIMIT (80 * 160 * (LV_COLOR_DEPTH / 8)) bool initBoot(); @@ -21,29 +17,5 @@ static std::vector> createDevices() { extern const Configuration hardwareConfiguration = { .initBoot = initBoot, .uiScale = UiScale::Smallest, - .createDevices = createDevices, - .spi { - spi::Configuration { - .device = SPI3_HOST, - .dma = SPI_DMA_CH_AUTO, - .config = { - .mosi_io_num = GPIO_NUM_3, - .miso_io_num = GPIO_NUM_NC, - .sclk_io_num = GPIO_NUM_5, - .quadwp_io_num = GPIO_NUM_NC, - .data4_io_num = GPIO_NUM_NC, - .data5_io_num = GPIO_NUM_NC, - .data6_io_num = GPIO_NUM_NC, - .data7_io_num = GPIO_NUM_NC, - .data_io_default_level = false, - .max_transfer_sz = TDECK_SPI_TRANSFER_SIZE_LIMIT, - .flags = 0, - .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, - .intr_flags = 0 - }, - .initMode = spi::InitMode::ByTactility, - .isMutable = false, - .lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display - }, - } + .createDevices = createDevices }; diff --git a/Devices/lilygo-tdongle-s3/Source/devices/Display.cpp b/Devices/lilygo-tdongle-s3/Source/devices/Display.cpp index 35597a8d..3285ba7c 100644 --- a/Devices/lilygo-tdongle-s3/Source/devices/Display.cpp +++ b/Devices/lilygo-tdongle-s3/Source/devices/Display.cpp @@ -3,7 +3,7 @@ #include #include -#define LCD_SPI_HOST SPI3_HOST +#define LCD_SPI_HOST SPI2_HOST #define LCD_PIN_CS GPIO_NUM_4 #define LCD_PIN_DC GPIO_NUM_2 #define LCD_PIN_RESET GPIO_NUM_1 diff --git a/Devices/lilygo-tdongle-s3/lilygo,tdongle-s3.dts b/Devices/lilygo-tdongle-s3/lilygo,tdongle-s3.dts index bc5b5b34..bcfc2c99 100644 --- a/Devices/lilygo-tdongle-s3/lilygo,tdongle-s3.dts +++ b/Devices/lilygo-tdongle-s3/lilygo,tdongle-s3.dts @@ -3,6 +3,7 @@ #include #include #include +#include #include / { @@ -24,6 +25,17 @@ pin-scl-pullup; }; + spi0 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <3>; + pin-miso = ; + pin-sclk = <5>; + pin-wp = ; + pin-hd = ; + max-transfer-size = <0>; + }; + stemma_qt: uart1 { compatible = "espressif,esp32-uart"; port = ; diff --git a/Devices/unphone/Source/Configuration.cpp b/Devices/unphone/Source/Configuration.cpp index c8d71b5a..5322cf2f 100644 --- a/Devices/unphone/Source/Configuration.cpp +++ b/Devices/unphone/Source/Configuration.cpp @@ -5,7 +5,6 @@ #include #include -#include #define UNPHONE_SPI_TRANSFER_SIZE_LIMIT (UNPHONE_LCD_HORIZONTAL_RESOLUTION * UNPHONE_LCD_SPI_TRANSFER_HEIGHT * LV_COLOR_DEPTH / 8) @@ -13,7 +12,6 @@ bool initBoot(); static tt::hal::DeviceVector createDevices() { return { - std::make_shared(), createDisplay(), createSdCard() }; diff --git a/Devices/waveshare-esp32-s3-geek/Source/Configuration.cpp b/Devices/waveshare-esp32-s3-geek/Source/Configuration.cpp index 5dd262d9..70c85db0 100644 --- a/Devices/waveshare-esp32-s3-geek/Source/Configuration.cpp +++ b/Devices/waveshare-esp32-s3-geek/Source/Configuration.cpp @@ -1,6 +1,6 @@ #include "devices/Display.h" #include "devices/SdCard.h" -#include +#include #include #include diff --git a/Documentation/ideas.md b/Documentation/ideas.md index 9b39c30d..7a3600ea 100644 --- a/Documentation/ideas.md +++ b/Documentation/ideas.md @@ -11,6 +11,9 @@ ## Higher Priority +- Make a root device type so it can be discovered more easily. +- DTS/yaml: Consider support for default values. +- DTS: throw custom exceptions and catch them to show cleaner error messages. - Add font design tokens such as "regular", "title" and "smaller". Perhaps via the LVGL kernel module. - Add kernel listening mechanism so that the root device init can be notified when a device becomes available: Callback for device/start stop with filtering on device type: diff --git a/Drivers/ILI9488/Source/Ili9488Display.h b/Drivers/ILI9488/Source/Ili9488Display.h index 81ba0c0d..8e2fb3f8 100644 --- a/Drivers/ILI9488/Source/Ili9488Display.h +++ b/Drivers/ILI9488/Source/Ili9488Display.h @@ -75,7 +75,6 @@ private: public: explicit Ili9488Display(std::unique_ptr inConfiguration) : - EspLcdDisplay(tt::hal::spi::getLock(inConfiguration->spiHostDevice)), configuration(std::move(inConfiguration) ) { assert(configuration != nullptr); diff --git a/Drivers/RgbDisplay/Source/RgbDisplay.h b/Drivers/RgbDisplay/Source/RgbDisplay.h index bbfb0a66..46635cd0 100644 --- a/Drivers/RgbDisplay/Source/RgbDisplay.h +++ b/Drivers/RgbDisplay/Source/RgbDisplay.h @@ -1,15 +1,12 @@ #pragma once #include -#include #include #include #include class RgbDisplay final : public tt::hal::display::DisplayDevice { - std::shared_ptr lock = std::make_shared(); - public: struct BufferConfiguration final { @@ -75,7 +72,7 @@ public: assert(configuration != nullptr); } - ~RgbDisplay(); + ~RgbDisplay() override; std::string getName() const override { return "RGB Display"; } std::string getDescription() const override { return "RGB Display"; } @@ -108,7 +105,7 @@ public: std::shared_ptr _Nullable getDisplayDriver() override { if (displayDriver == nullptr) { auto config = getLvglPortDisplayConfig(); - displayDriver = std::make_shared(panelHandle, lock, config.hres, config.vres, tt::hal::display::ColorFormat::RGB888); + displayDriver = std::make_shared(panelHandle, config.hres, config.vres, tt::hal::display::ColorFormat::RGB888); } return displayDriver; } diff --git a/Drivers/SSD1306/Source/Ssd1306Display.h b/Drivers/SSD1306/Source/Ssd1306Display.h index aa09dc6d..115982be 100644 --- a/Drivers/SSD1306/Source/Ssd1306Display.h +++ b/Drivers/SSD1306/Source/Ssd1306Display.h @@ -57,7 +57,6 @@ private: public: explicit Ssd1306Display(std::unique_ptr inConfiguration) : - EspLcdDisplay(nullptr), configuration(std::move(inConfiguration)) { assert(configuration != nullptr); diff --git a/Drivers/ST7735/Source/St7735Display.h b/Drivers/ST7735/Source/St7735Display.h index ba90864f..0c2083d8 100644 --- a/Drivers/ST7735/Source/St7735Display.h +++ b/Drivers/ST7735/Source/St7735Display.h @@ -87,12 +87,8 @@ private: public: explicit St7735Display(std::unique_ptr inConfiguration) : - EspLcdDisplay(tt::hal::spi::getLock(inConfiguration->spiHostDevice)), configuration(std::move(inConfiguration) - ) { - assert(configuration != nullptr); - assert(getLock() != nullptr); - } + ) {} std::string getName() const override { return "ST7735"; } diff --git a/Drivers/XPT2046/Source/Xpt2046Power.cpp b/Drivers/XPT2046/Source/Xpt2046Power.cpp deleted file mode 100644 index a68668aa..00000000 --- a/Drivers/XPT2046/Source/Xpt2046Power.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include "Xpt2046Power.h" -#include "Xpt2046Touch.h" - -#include -#include - -static const auto LOGGER = tt::Logger("Xpt2046Power"); - -constexpr auto BATTERY_VOLTAGE_MIN = 3.2f; -constexpr auto BATTERY_VOLTAGE_MAX = 4.2f; -constexpr auto MAX_VOLTAGE_SAMPLES = 15; - -static std::shared_ptr findXp2046TouchDevice() { - // Make a safe copy - auto touch = tt::hal::findFirstDevice(tt::hal::Device::Type::Touch); - if (touch == nullptr) { - LOGGER.error("Touch device not found"); - return nullptr; - } - - if (touch->getName() != "XPT2046") { - LOGGER.error("Touch device name mismatch"); - return nullptr; - } - - return std::reinterpret_pointer_cast(touch); -} - -static uint8_t estimateChargeLevelFromVoltage(uint32_t milliVolt) { - float volts = std::min((float)milliVolt / 1000.f, BATTERY_VOLTAGE_MAX); - float voltage_percentage = (volts - BATTERY_VOLTAGE_MIN) / (BATTERY_VOLTAGE_MAX - BATTERY_VOLTAGE_MIN); - float voltage_factor = std::min(1.0f, voltage_percentage); - auto charge_level = (uint8_t) (voltage_factor * 100.f); - LOGGER.verbose("mV = {}, scaled = {}, factor = {}, result = {}", milliVolt, volts, voltage_factor, charge_level); - return charge_level; -} - -bool Xpt2046Power::supportsMetric(MetricType type) const { - switch (type) { - using enum MetricType; - case BatteryVoltage: - case ChargeLevel: - return true; - default: - return false; - } -} - -bool Xpt2046Power::getMetric(MetricType type, MetricData& data) { - switch (type) { - using enum MetricType; - case BatteryVoltage: - return readBatteryVoltageSampled(data.valueAsUint32); - case ChargeLevel: { - uint32_t milli_volt; - if (readBatteryVoltageSampled(milli_volt)) { - data.valueAsUint8 = estimateChargeLevelFromVoltage(milli_volt); - return true; - } else { - return false; - } - } - default: - return false; - } -} - -bool Xpt2046Power::readBatteryVoltageOnce(uint32_t& output) { - if (xptTouch == nullptr) { - xptTouch = findXp2046TouchDevice(); - if (xptTouch == nullptr) { - LOGGER.error("XPT2046 touch device not found"); - return false; - } - } - - float vbat; - if (!xptTouch->getVBat(vbat)) { - return false; - } - - // Convert to mV - output = (uint32_t)(vbat * 1000.f); - return true; -} - -bool Xpt2046Power::readBatteryVoltageSampled(uint32_t& output) { - size_t samples_read = 0; - uint32_t sample_accumulator = 0; - uint32_t sample_read_buffer; - - for (size_t i = 0; i < MAX_VOLTAGE_SAMPLES; ++i) { - if (readBatteryVoltageOnce(sample_read_buffer)) { - sample_accumulator += sample_read_buffer; - samples_read++; - } - } - - if (samples_read > 0) { - output = sample_accumulator / samples_read; - return true; - } else { - return false; - } -} diff --git a/Drivers/XPT2046/Source/Xpt2046Power.h b/Drivers/XPT2046/Source/Xpt2046Power.h deleted file mode 100644 index f14036ee..00000000 --- a/Drivers/XPT2046/Source/Xpt2046Power.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#include - -class Xpt2046Touch; -using tt::hal::power::PowerDevice; - -/** - * Power management based on the voltage measurement at the LCD panel. - * This estimates the battery power left. - */ -class Xpt2046Power : public PowerDevice { - - std::shared_ptr xptTouch; - - bool readBatteryVoltageOnce(uint32_t& output); - bool readBatteryVoltageSampled(uint32_t& output); - -public: - - ~Xpt2046Power() override = default; - - std::string getName() const final { return "XPT2046 Power Measurement"; } - std::string getDescription() const final { return "Power interface via XPT2046 voltage measurement"; } - - bool supportsMetric(MetricType type) const override; - bool getMetric(MetricType type, MetricData& data) override; -}; diff --git a/Drivers/XPT2046/Source/Xpt2046Touch.cpp b/Drivers/XPT2046/Source/Xpt2046Touch.cpp index 50c5ca15..1695777a 100644 --- a/Drivers/XPT2046/Source/Xpt2046Touch.cpp +++ b/Drivers/XPT2046/Source/Xpt2046Touch.cpp @@ -35,19 +35,3 @@ esp_lcd_touch_config_t Xpt2046Touch::createEspLcdTouchConfig() { .driver_data = nullptr }; } - -bool Xpt2046Touch::getVBat(float& outputVbat) { - auto touch_handle = getTouchHandle(); - if (touch_handle == nullptr) { - return false; - } - - // Shares the SPI bus with the display, so we have to sync/lock as this method might be called from anywhere - if (!tt::lvgl::lock(50 / portTICK_PERIOD_MS)) { - return false; - } - - esp_lcd_touch_xpt2046_read_battery_level(touch_handle, &outputVbat); - tt::lvgl::unlock(); - return true; -} diff --git a/Drivers/XPT2046/Source/Xpt2046Touch.h b/Drivers/XPT2046/Source/Xpt2046Touch.h index fb813b24..91404e4f 100644 --- a/Drivers/XPT2046/Source/Xpt2046Touch.h +++ b/Drivers/XPT2046/Source/Xpt2046Touch.h @@ -56,6 +56,4 @@ public: std::string getName() const final { return "XPT2046"; } std::string getDescription() const final { return "XPT2046 I2C touch driver"; } - - bool getVBat(float& outputVbat); }; diff --git a/Firmware/idf_component.yml b/Firmware/idf_component.yml index 45256943..6d15beae 100644 --- a/Firmware/idf_component.yml +++ b/Firmware/idf_component.yml @@ -21,7 +21,7 @@ dependencies: - if: "target in [esp32, esp32s3]" espressif/esp_lcd_touch: "1.2.1" atanisoft/esp_lcd_touch_xpt2046: - version: "1.0.5" + version: "1.0.6" rules: - if: "target in [esp32, esp32s3]" espressif/esp_lcd_touch_cst816s: "1.0.3" diff --git a/Modules/lvgl-module/Source/arch/lvgl_esp32.c b/Modules/lvgl-module/Source/arch/lvgl_esp32.c index 9c26a6f6..29370019 100644 --- a/Modules/lvgl-module/Source/arch/lvgl_esp32.c +++ b/Modules/lvgl-module/Source/arch/lvgl_esp32.c @@ -12,12 +12,12 @@ extern struct LvglModuleConfig lvgl_module_config; static bool initialized = false; bool lvgl_lock(void) { - if (!initialized) return false; + if (!initialized) return true; // We allow (ake) locking because it's safe to do so as LVGL is not running yet return lvgl_port_lock(portMAX_DELAY); } bool lvgl_try_lock_timed(uint32_t timeout) { - if (!initialized) return false; + if (!initialized) return true; // We allow (ake) locking because it's safe to do so as LVGL is not running yet return lvgl_port_lock(millis_to_ticks(timeout)); } diff --git a/Tactility/Include/Tactility/hal/Configuration.h b/Tactility/Include/Tactility/hal/Configuration.h index 385bd322..966c89f6 100644 --- a/Tactility/Include/Tactility/hal/Configuration.h +++ b/Tactility/Include/Tactility/hal/Configuration.h @@ -10,11 +10,6 @@ typedef std::vector> DeviceVector; typedef std::shared_ptr (*CreateDevice)(); -enum class LvglInit { - Default, - None -}; - /** Affects LVGL widget style */ enum class UiScale { /** Ideal for very small non-touch screen devices (e.g. Waveshare S3 LCD 1.3") */ @@ -30,13 +25,10 @@ struct Configuration { */ const InitBoot initBoot = nullptr; - /** Init behaviour: default (esp_lvgl_port for ESP32, nothing for PC) or None (nothing on any platform). Only used in Tactility, not in TactilityHeadless. */ - const LvglInit lvglInit = LvglInit::Default; - /** Modify LVGL widget size */ const UiScale uiScale = UiScale::Default; - std::function createDevices = [] { return std::vector>(); }; + std::function createDevices = [] { return DeviceVector(); }; }; } // namespace diff --git a/Tactility/Source/service/wifi/WifiEsp.cpp b/Tactility/Source/service/wifi/WifiEsp.cpp index b853b2eb..a5221185 100644 --- a/Tactility/Source/service/wifi/WifiEsp.cpp +++ b/Tactility/Source/service/wifi/WifiEsp.cpp @@ -47,8 +47,8 @@ static void dispatchDisconnectButKeepActive(std::shared_ptr wifi); class Wifi { std::atomic radio_state = RadioState::Off; - bool scan_active = false; - bool secure_connection = false; + std::atomic scan_active = false; + std::atomic secure_connection = false; public: @@ -81,54 +81,34 @@ public: kernel::SystemEventSubscription bootEventSubscription = kernel::NoSystemEventSubscription; RadioState getRadioState() const { - auto lock = dataMutex.asScopedLock(); - lock.lock(); - // TODO: Handle lock failure return radio_state; } void setRadioState(RadioState newState) { - auto lock = dataMutex.asScopedLock(); - lock.lock(); - // TODO: Handle lock failure radio_state = newState; } bool isScanning() const { - auto lock = dataMutex.asScopedLock(); - lock.lock(); - // TODO: Handle lock failure return scan_active; } void setScanning(bool newState) { - auto lock = dataMutex.asScopedLock(); - lock.lock(); - // TODO: Handle lock failure scan_active = newState; } bool isScanActive() const { - auto lock = dataMutex.asScopedLock(); - lock.lock(); return scan_active; } void setScanActive(bool newState) { - auto lock = dataMutex.asScopedLock(); - lock.lock(); scan_active = newState; } bool isSecureConnection() const { - auto lock = dataMutex.asScopedLock(); - lock.lock(); return secure_connection; } void setSecureConnection(bool newState) { - auto lock = dataMutex.asScopedLock(); - lock.lock(); secure_connection = newState; } }; @@ -913,7 +893,9 @@ std::string getIp() { auto wifi = std::static_pointer_cast(wifi_singleton); auto lock = wifi->dataMutex.asScopedLock(); - lock.lock(); + if (!lock.lock(100)) { + return "0.0.0.0"; + } return std::format("{}.{}.{}.{}", IP2STR(&wifi->ip_info.ip)); } diff --git a/TactilityC/Source/tt_init.cpp b/TactilityC/Source/tt_init.cpp index 0b862ef5..e89757de 100644 --- a/TactilityC/Source/tt_init.cpp +++ b/TactilityC/Source/tt_init.cpp @@ -91,18 +91,28 @@ const esp_elfsym main_symbols[] { ESP_ELFSYM_EXPORT(sntp_get_sync_status), // math.h ESP_ELFSYM_EXPORT(atan), + ESP_ELFSYM_EXPORT(atanf), ESP_ELFSYM_EXPORT(cos), - ESP_ELFSYM_EXPORT(sin), - ESP_ELFSYM_EXPORT(tan), - ESP_ELFSYM_EXPORT(tanh), - ESP_ELFSYM_EXPORT(frexp), - ESP_ELFSYM_EXPORT(modf), - ESP_ELFSYM_EXPORT(ceil), - ESP_ELFSYM_EXPORT(fabs), - ESP_ELFSYM_EXPORT(floor), - ESP_ELFSYM_EXPORT(sinf), ESP_ELFSYM_EXPORT(cosf), + ESP_ELFSYM_EXPORT(sin), + ESP_ELFSYM_EXPORT(sinf), + ESP_ELFSYM_EXPORT(tan), + ESP_ELFSYM_EXPORT(tanf), + ESP_ELFSYM_EXPORT(frexp), + ESP_ELFSYM_EXPORT(frexpf), + ESP_ELFSYM_EXPORT(modf), + ESP_ELFSYM_EXPORT(modff), + ESP_ELFSYM_EXPORT(fmodf), + ESP_ELFSYM_EXPORT(ceil), + ESP_ELFSYM_EXPORT(ceilf), + ESP_ELFSYM_EXPORT(fabs), ESP_ELFSYM_EXPORT(fabsf), + ESP_ELFSYM_EXPORT(floor), + ESP_ELFSYM_EXPORT(floorf), + ESP_ELFSYM_EXPORT(fmax), + ESP_ELFSYM_EXPORT(fmaxf), + ESP_ELFSYM_EXPORT(fmin), + ESP_ELFSYM_EXPORT(fminf), #ifndef _REENT_ONLY ESP_ELFSYM_EXPORT(acos), ESP_ELFSYM_EXPORT(acosf), diff --git a/TactilityKernel/Include/tactility/concurrent/recursive_mutex.h b/TactilityKernel/Include/tactility/concurrent/recursive_mutex.h index a7b12299..2c0cae83 100644 --- a/TactilityKernel/Include/tactility/concurrent/recursive_mutex.h +++ b/TactilityKernel/Include/tactility/concurrent/recursive_mutex.h @@ -12,15 +12,14 @@ extern "C" { struct RecursiveMutex { QueueHandle_t handle; + // TODO: Debugging functionality }; inline static void recursive_mutex_construct(struct RecursiveMutex* mutex) { - check(mutex->handle == NULL); mutex->handle = xSemaphoreCreateRecursiveMutex(); } inline static void recursive_mutex_destruct(struct RecursiveMutex* mutex) { - check(mutex->handle != NULL); check(xPortInIsrContext() != pdTRUE); vSemaphoreDelete(mutex->handle); mutex->handle = NULL;