mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-04-18 09:25:06 +00:00
WIP
This commit is contained in:
parent
933f8ad0b2
commit
f4df5f6890
@ -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<tt::hal::display::DisplayDevice> createDisplay();
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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<tt::hal::display::DisplayDevice> createDisplay();
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
#include <driver/gpio.h>
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
@ -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<tt::hal::display::DisplayDevice> createDisplay();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#include "SdCard.h"
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
|
||||
@ -19,7 +20,11 @@ std::shared_ptr<SdCardDevice> createSdCard() {
|
||||
SPI3_HOST
|
||||
);
|
||||
|
||||
auto* spi_controller = device_find_by_name("spi1");
|
||||
check(spi_controller, "spi1 not found");
|
||||
|
||||
return std::make_shared<SpiSdCardDevice>(
|
||||
std::move(configuration)
|
||||
std::move(configuration),
|
||||
spi_controller
|
||||
);
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include <tactility/bindings/root.h>
|
||||
#include <tactility/bindings/esp32_gpio.h>
|
||||
#include <tactility/bindings/esp32_i2c.h>
|
||||
#include <tactility/bindings/esp32_spi.h>
|
||||
#include <tactility/bindings/esp32_uart.h>
|
||||
|
||||
/ {
|
||||
@ -24,6 +25,28 @@
|
||||
pin-scl-pullup;
|
||||
};
|
||||
|
||||
display_spi: spi0 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI2_HOST>;
|
||||
pin-mosi = <39>;
|
||||
pin-miso = <GPIO_PIN_NONE>;
|
||||
pin-sclk = <42>;
|
||||
pin-wp = <GPIO_PIN_NONE>;
|
||||
pin-hd = <GPIO_PIN_NONE>;
|
||||
max-transfer-size = <0>;
|
||||
};
|
||||
|
||||
sdcard_spi: spi1 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI3_HOST>;
|
||||
pin-mosi = <6>;
|
||||
pin-miso = <4>;
|
||||
pin-sclk = <5>;
|
||||
pin-wp = <GPIO_PIN_NONE>;
|
||||
pin-hd = <GPIO_PIN_NONE>;
|
||||
max-transfer-size = <0>;
|
||||
};
|
||||
|
||||
uart0 {
|
||||
compatible = "espressif,esp32-uart";
|
||||
port = <UART_NUM_0>;
|
||||
|
||||
@ -3,11 +3,8 @@
|
||||
#include <driver/gpio.h>
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <PwmBacklight.h>
|
||||
|
||||
#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
|
||||
};
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#include "SdCard.h"
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
|
||||
@ -19,7 +20,11 @@ std::shared_ptr<SdCardDevice> createSdCard() {
|
||||
SPI3_HOST
|
||||
);
|
||||
|
||||
auto* spi_controller = device_find_by_name("spi1");
|
||||
check(spi_controller, "spi1 not found");
|
||||
|
||||
return std::make_shared<SpiSdCardDevice>(
|
||||
std::move(configuration)
|
||||
std::move(configuration),
|
||||
spi_controller
|
||||
);
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include <tactility/bindings/root.h>
|
||||
#include <tactility/bindings/esp32_gpio.h>
|
||||
#include <tactility/bindings/esp32_i2c.h>
|
||||
#include <tactility/bindings/esp32_spi.h>
|
||||
#include <tactility/bindings/esp32_uart.h>
|
||||
|
||||
/ {
|
||||
@ -24,6 +25,28 @@
|
||||
pin-scl-pullup;
|
||||
};
|
||||
|
||||
display_spi: spi0 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI2_HOST>;
|
||||
pin-mosi = <39>;
|
||||
pin-miso = <GPIO_PIN_NONE>;
|
||||
pin-sclk = <42>;
|
||||
pin-wp = <GPIO_PIN_NONE>;
|
||||
pin-hd = <GPIO_PIN_NONE>;
|
||||
max-transfer-size = <0>;
|
||||
};
|
||||
|
||||
sdcard_spi: spi1 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI3_HOST>;
|
||||
pin-mosi = <6>;
|
||||
pin-miso = <4>;
|
||||
pin-sclk = <5>;
|
||||
pin-wp = <GPIO_PIN_NONE>;
|
||||
pin-hd = <GPIO_PIN_NONE>;
|
||||
max-transfer-size = <0>;
|
||||
};
|
||||
|
||||
uart0 {
|
||||
compatible = "espressif,esp32-uart";
|
||||
port = <UART_NUM_0>;
|
||||
|
||||
@ -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
|
||||
};
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#include "SdCard.h"
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
|
||||
using tt::hal::sdcard::SpiSdCardDevice;
|
||||
|
||||
@ -15,7 +15,11 @@ std::shared_ptr<SdCardDevice> createSdCard() {
|
||||
SdCardDevice::MountBehaviour::AtBoot
|
||||
);
|
||||
|
||||
auto* spi_controller = device_find_by_name("spi0");
|
||||
check(spi_controller, "spi0 not found");
|
||||
|
||||
return std::make_shared<SpiSdCardDevice>(
|
||||
std::move(configuration)
|
||||
std::move(configuration),
|
||||
spi_controller
|
||||
);
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include <tactility/bindings/root.h>
|
||||
#include <tactility/bindings/esp32_gpio.h>
|
||||
#include <tactility/bindings/esp32_i2c.h>
|
||||
#include <tactility/bindings/esp32_spi.h>
|
||||
#include <tactility/bindings/esp32_uart.h>
|
||||
|
||||
/ {
|
||||
@ -24,6 +25,17 @@
|
||||
pin-scl-pullup;
|
||||
};
|
||||
|
||||
sdcard_spi: spi0 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI2_HOST>;
|
||||
pin-mosi = <6>;
|
||||
pin-miso = <4>;
|
||||
pin-sclk = <5>;
|
||||
pin-wp = <GPIO_PIN_NONE>;
|
||||
pin-hd = <GPIO_PIN_NONE>;
|
||||
max-transfer-size = <0>;
|
||||
};
|
||||
|
||||
uart0 {
|
||||
compatible = "espressif,esp32-uart";
|
||||
port = <UART_NUM_0>;
|
||||
|
||||
@ -4,8 +4,6 @@
|
||||
#include <driver/gpio.h>
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Xpt2046Power.h>
|
||||
|
||||
using namespace tt::hal;
|
||||
|
||||
@ -15,63 +13,12 @@ static bool initBoot() {
|
||||
|
||||
static DeviceVector createDevices() {
|
||||
return {
|
||||
std::make_shared<Xpt2046Power>(),
|
||||
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
|
||||
};
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#include "SdCard.h"
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
|
||||
@ -17,7 +18,11 @@ std::shared_ptr<SdCardDevice> createSdCard() {
|
||||
SPI3_HOST
|
||||
);
|
||||
|
||||
auto* spi_controller = device_find_by_name("spi1");
|
||||
check(spi_controller, "spi1 not found");
|
||||
|
||||
return std::make_shared<SpiSdCardDevice>(
|
||||
std::move(configuration)
|
||||
std::move(configuration),
|
||||
spi_controller
|
||||
);
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include <tactility/bindings/root.h>
|
||||
#include <tactility/bindings/esp32_gpio.h>
|
||||
#include <tactility/bindings/esp32_i2c.h>
|
||||
#include <tactility/bindings/esp32_spi.h>
|
||||
#include <tactility/bindings/esp32_uart.h>
|
||||
|
||||
/ {
|
||||
@ -24,6 +25,28 @@
|
||||
pin-scl-pullup;
|
||||
};
|
||||
|
||||
display_spi: spi0 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI2_HOST>;
|
||||
pin-mosi = <13>;
|
||||
pin-miso = <12>;
|
||||
pin-sclk = <14>;
|
||||
pin-wp = <GPIO_PIN_NONE>;
|
||||
pin-hd = <GPIO_PIN_NONE>;
|
||||
max-transfer-size = <0>;
|
||||
};
|
||||
|
||||
sdcard_spi: spi1 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI3_HOST>;
|
||||
pin-mosi = <23>;
|
||||
pin-miso = <19>;
|
||||
pin-sclk = <18>;
|
||||
pin-wp = <GPIO_PIN_NONE>;
|
||||
pin-hd = <GPIO_PIN_NONE>;
|
||||
max-transfer-size = <0>;
|
||||
};
|
||||
|
||||
uart1 {
|
||||
compatible = "espressif,esp32-uart";
|
||||
port = <UART_NUM_1>;
|
||||
|
||||
@ -1,13 +1,9 @@
|
||||
#include "PwmBacklight.h"
|
||||
#include "Tactility/lvgl/LvglSync.h"
|
||||
#include "devices/Display.h"
|
||||
#include "devices/SdCard.h"
|
||||
#include <driver/gpio.h>
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
#include <Xpt2046Power.h>
|
||||
|
||||
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<Xpt2046Power>(),
|
||||
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
|
||||
};
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#include "SdCard.h"
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
|
||||
@ -17,7 +18,11 @@ std::shared_ptr<SdCardDevice> createSdCard() {
|
||||
SPI3_HOST
|
||||
);
|
||||
|
||||
auto* spi_controller = device_find_by_name("spi1");
|
||||
check(spi_controller, "spi1 not found");
|
||||
|
||||
return std::make_shared<SpiSdCardDevice>(
|
||||
std::move(configuration)
|
||||
std::move(configuration),
|
||||
spi_controller
|
||||
);
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include <tactility/bindings/root.h>
|
||||
#include <tactility/bindings/esp32_gpio.h>
|
||||
#include <tactility/bindings/esp32_i2c.h>
|
||||
#include <tactility/bindings/esp32_spi.h>
|
||||
#include <tactility/bindings/esp32_uart.h>
|
||||
|
||||
/ {
|
||||
@ -24,6 +25,28 @@
|
||||
pin-scl-pullup;
|
||||
};
|
||||
|
||||
display_spi: spi0 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI2_HOST>;
|
||||
pin-mosi = <13>;
|
||||
pin-miso = <33>;
|
||||
pin-sclk = <14>;
|
||||
pin-wp = <GPIO_PIN_NONE>;
|
||||
pin-hd = <GPIO_PIN_NONE>;
|
||||
max-transfer-size = <0>;
|
||||
};
|
||||
|
||||
sdcard_spi: spi1 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI3_HOST>;
|
||||
pin-mosi = <23>;
|
||||
pin-miso = <19>;
|
||||
pin-sclk = <18>;
|
||||
pin-wp = <GPIO_PIN_NONE>;
|
||||
pin-hd = <GPIO_PIN_NONE>;
|
||||
max-transfer-size = <0>;
|
||||
};
|
||||
|
||||
uart1 {
|
||||
compatible = "espressif,esp32-uart";
|
||||
port = <UART_NUM_1>;
|
||||
|
||||
@ -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
|
||||
};
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#include "SdCard.h"
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
|
||||
using tt::hal::sdcard::SpiSdCardDevice;
|
||||
@ -13,7 +14,11 @@ std::shared_ptr<SdCardDevice> createSdCard() {
|
||||
SdCardDevice::MountBehaviour::AtBoot
|
||||
);
|
||||
|
||||
auto* spi_controller = device_find_by_name("spi0");
|
||||
check(spi_controller, "spi0 not found");
|
||||
|
||||
return std::make_shared<SpiSdCardDevice>(
|
||||
std::move(configuration)
|
||||
std::move(configuration),
|
||||
spi_controller
|
||||
);
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include <tactility/bindings/root.h>
|
||||
#include <tactility/bindings/esp32_gpio.h>
|
||||
#include <tactility/bindings/esp32_i2c.h>
|
||||
#include <tactility/bindings/esp32_spi.h>
|
||||
#include <tactility/bindings/esp32_uart.h>
|
||||
|
||||
/ {
|
||||
@ -24,6 +25,17 @@
|
||||
pin-scl-pullup;
|
||||
};
|
||||
|
||||
sdcard_spi: spi0 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI2_HOST>;
|
||||
pin-mosi = <11>;
|
||||
pin-miso = <13>;
|
||||
pin-sclk = <12>;
|
||||
pin-wp = <GPIO_PIN_NONE>;
|
||||
pin-hd = <GPIO_PIN_NONE>;
|
||||
max-transfer-size = <0>;
|
||||
};
|
||||
|
||||
uart0 {
|
||||
compatible = "espressif,esp32-uart";
|
||||
port = <UART_NUM_0>;
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
|
||||
#include <PwmBacklight.h>
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
@ -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<tt::hal::display::DisplayDevice> createDisplay();
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
#include "SdCard.h"
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
|
||||
constexpr auto SDCARD_SPI_HOST = SPI3_HOST;
|
||||
constexpr auto SDCARD_PIN_CS = GPIO_NUM_5;
|
||||
@ -16,13 +15,17 @@ std::shared_ptr<SdCardDevice> createSdCard() {
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
SdCardDevice::MountBehaviour::AtBoot,
|
||||
std::make_shared<tt::RecursiveMutex>(),
|
||||
nullptr,
|
||||
std::vector<gpio_num_t>(),
|
||||
SDCARD_SPI_HOST
|
||||
);
|
||||
|
||||
auto* spi_controller = device_find_by_name("spi1");
|
||||
check(spi_controller, "spi1 not found");
|
||||
|
||||
return std::make_shared<SpiSdCardDevice>(
|
||||
std::move(configuration)
|
||||
std::move(configuration),
|
||||
spi_controller
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include <tactility/bindings/root.h>
|
||||
#include <tactility/bindings/esp32_gpio.h>
|
||||
#include <tactility/bindings/esp32_i2c.h>
|
||||
#include <tactility/bindings/esp32_spi.h>
|
||||
#include <tactility/bindings/esp32_uart.h>
|
||||
|
||||
/ {
|
||||
@ -31,6 +32,28 @@
|
||||
pin-scl = <22>;
|
||||
};
|
||||
|
||||
display_spi: spi0 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI2_HOST>;
|
||||
pin-mosi = <13>;
|
||||
pin-miso = <GPIO_PIN_NONE>;
|
||||
pin-sclk = <14>;
|
||||
pin-wp = <GPIO_PIN_NONE>;
|
||||
pin-hd = <GPIO_PIN_NONE>;
|
||||
max-transfer-size = <0>;
|
||||
};
|
||||
|
||||
sdcard_spi: spi1 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI3_HOST>;
|
||||
pin-mosi = <23>;
|
||||
pin-miso = <19>;
|
||||
pin-sclk = <18>;
|
||||
pin-wp = <GPIO_PIN_NONE>;
|
||||
pin-hd = <GPIO_PIN_NONE>;
|
||||
max-transfer-size = <0>;
|
||||
};
|
||||
|
||||
// CN1 header, JST SH 1.25, GND / IO22 / IO21 / 3.3V
|
||||
uart1 {
|
||||
compatible = "espressif,esp32-uart";
|
||||
|
||||
@ -485,7 +485,6 @@ std::shared_ptr<tt::hal::display::DisplayDriver> Axs15231bDisplay::getDisplayDri
|
||||
if (displayDriver == nullptr) {
|
||||
displayDriver = std::make_shared<EspLcdDisplayDriver>(
|
||||
panelHandle,
|
||||
tt::lvgl::getSyncLock(),
|
||||
configuration->horizontalResolution,
|
||||
configuration->verticalResolution,
|
||||
tt::hal::display::ColorFormat::RGB565Swapped
|
||||
|
||||
@ -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<tt::hal::touch::TouchDevice> touch,
|
||||
|
||||
@ -3,13 +3,10 @@
|
||||
#include <driver/gpio.h>
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <PwmBacklight.h>
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#include "SdCard.h"
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
|
||||
constexpr auto SDCARD_SPI_HOST = SPI3_HOST;
|
||||
constexpr auto SDCARD_PIN_CS = GPIO_NUM_10;
|
||||
@ -15,12 +15,16 @@ std::shared_ptr<SdCardDevice> createSdCard() {
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
SdCardDevice::MountBehaviour::AtBoot,
|
||||
std::make_shared<tt::RecursiveMutex>(),
|
||||
nullptr,
|
||||
std::vector<gpio_num_t>(),
|
||||
SDCARD_SPI_HOST
|
||||
);
|
||||
|
||||
auto* spi_controller = device_find_by_name("spi1");
|
||||
check(spi_controller, "spi1 not found");
|
||||
|
||||
return std::make_shared<SpiSdCardDevice>(
|
||||
std::move(configuration)
|
||||
std::move(configuration),
|
||||
spi_controller
|
||||
);
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include <tactility/bindings/root.h>
|
||||
#include <tactility/bindings/esp32_gpio.h>
|
||||
#include <tactility/bindings/esp32_i2c.h>
|
||||
#include <tactility/bindings/esp32_spi.h>
|
||||
#include <tactility/bindings/esp32_uart.h>
|
||||
|
||||
/ {
|
||||
@ -34,6 +35,28 @@
|
||||
pin-scl-pullup;
|
||||
};
|
||||
|
||||
display_spi: spi0 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI2_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 = <SPI3_HOST>;
|
||||
pin-mosi = <11>;
|
||||
pin-miso = <13>;
|
||||
pin-sclk = <12>;
|
||||
pin-wp = <GPIO_PIN_NONE>;
|
||||
pin-hd = <GPIO_PIN_NONE>;
|
||||
max-transfer-size = <0>;
|
||||
};
|
||||
|
||||
// P1 header
|
||||
uart0 {
|
||||
compatible = "espressif,esp32-uart";
|
||||
|
||||
@ -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
|
||||
};
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#include "SdCard.h"
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
@ -13,14 +14,16 @@ std::shared_ptr<SdCardDevice> createSdCard() {
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
SdCardDevice::MountBehaviour::AtBoot,
|
||||
std::make_shared<tt::RecursiveMutex>(),
|
||||
nullptr,
|
||||
std::vector<gpio_num_t>(),
|
||||
SPI2_HOST
|
||||
);
|
||||
|
||||
auto sdcard = std::make_shared<SpiSdCardDevice>(
|
||||
std::move(config)
|
||||
);
|
||||
auto* spi_controller = device_find_by_name("spi0");
|
||||
check(spi_controller, "spi0 not found");
|
||||
|
||||
return std::static_pointer_cast<SdCardDevice>(sdcard);
|
||||
return std::make_shared<SpiSdCardDevice>(
|
||||
std::move(config),
|
||||
spi_controller
|
||||
);
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include <tactility/bindings/root.h>
|
||||
#include <tactility/bindings/esp32_gpio.h>
|
||||
#include <tactility/bindings/esp32_i2c.h>
|
||||
#include <tactility/bindings/esp32_spi.h>
|
||||
#include <tactility/bindings/esp32_uart.h>
|
||||
|
||||
/ {
|
||||
@ -34,6 +35,17 @@
|
||||
pin-scl-pullup;
|
||||
};
|
||||
|
||||
spi0 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI2_HOST>;
|
||||
pin-mosi = <11>;
|
||||
pin-miso = <13>;
|
||||
pin-sclk = <12>;
|
||||
pin-wp = <GPIO_PIN_NONE>;
|
||||
pin-hd = <GPIO_PIN_NONE>;
|
||||
max-transfer-size = <0>;
|
||||
};
|
||||
|
||||
uart1 {
|
||||
compatible = "espressif,esp32-uart";
|
||||
port = <UART_NUM_1>;
|
||||
|
||||
@ -2,15 +2,13 @@
|
||||
#include "devices/Power.h"
|
||||
#include "devices/Constants.h"
|
||||
|
||||
#include <tactility/log.h>
|
||||
#include <tactility/freertos/task.h>
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <ButtonControl.h>
|
||||
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/i2c.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include <driver/gpio.h>
|
||||
|
||||
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<std::shared_ptr<tt::hal::Device>> createDevices() {
|
||||
extern const Configuration hardwareConfiguration = {
|
||||
.initBoot = initBoot,
|
||||
.uiScale = UiScale::Smallest,
|
||||
.createDevices = createDevices,
|
||||
.spi {},
|
||||
.createDevices = createDevices
|
||||
};
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
#include "devices/Display.h"
|
||||
#include "devices/Power.h"
|
||||
#include <driver/gpio.h>
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <ButtonControl.h>
|
||||
|
||||
bool initBoot();
|
||||
@ -20,21 +18,5 @@ static std::vector<std::shared_ptr<tt::hal::Device>> 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
|
||||
};
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include <tactility/bindings/root.h>
|
||||
#include <tactility/bindings/esp32_gpio.h>
|
||||
#include <tactility/bindings/esp32_i2c.h>
|
||||
#include <tactility/bindings/esp32_spi.h>
|
||||
|
||||
/ {
|
||||
compatible = "root";
|
||||
@ -12,4 +13,15 @@
|
||||
compatible = "espressif,esp32-gpio";
|
||||
gpio-count = <49>;
|
||||
};
|
||||
|
||||
spi0 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI2_HOST>;
|
||||
pin-mosi = <7>;
|
||||
pin-miso = <GPIO_PIN_NONE>;
|
||||
pin-sclk = <6>;
|
||||
pin-wp = <GPIO_PIN_NONE>;
|
||||
pin-hd = <GPIO_PIN_NONE>;
|
||||
max-transfer-size = <0>;
|
||||
};
|
||||
};
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
#include "devices/Display.h"
|
||||
#include <driver/gpio.h>
|
||||
|
||||
#include <PwmBacklight.h>
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <ButtonControl.h>
|
||||
|
||||
using namespace tt::hal;
|
||||
@ -22,29 +20,5 @@ static std::vector<std::shared_ptr<tt::hal::Device>> 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
|
||||
};
|
||||
|
||||
@ -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<tt::hal::display::DisplayDevice> createDisplay();
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include <tactility/bindings/root.h>
|
||||
#include <tactility/bindings/esp32_gpio.h>
|
||||
#include <tactility/bindings/esp32_i2c.h>
|
||||
#include <tactility/bindings/esp32_spi.h>
|
||||
|
||||
/ {
|
||||
compatible = "root";
|
||||
@ -12,4 +13,15 @@
|
||||
compatible = "espressif,esp32-gpio";
|
||||
gpio-count = <49>;
|
||||
};
|
||||
|
||||
spi0 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI2_HOST>;
|
||||
pin-mosi = <19>;
|
||||
pin-miso = <GPIO_PIN_NONE>;
|
||||
pin-sclk = <18>;
|
||||
pin-wp = <GPIO_PIN_NONE>;
|
||||
pin-hd = <GPIO_PIN_NONE>;
|
||||
max-transfer-size = <0>;
|
||||
};
|
||||
};
|
||||
|
||||
@ -1,11 +1,7 @@
|
||||
#include "devices/Display.h"
|
||||
#include "devices/Sdcard.h"
|
||||
#include <driver/gpio.h>
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
|
||||
#define TDECK_SPI_TRANSFER_SIZE_LIMIT (80 * 160 * (LV_COLOR_DEPTH / 8))
|
||||
|
||||
bool initBoot();
|
||||
|
||||
@ -21,29 +17,5 @@ static std::vector<std::shared_ptr<tt::hal::Device>> 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
|
||||
};
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#include <PwmBacklight.h>
|
||||
#include <St7735Display.h>
|
||||
|
||||
#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
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include <tactility/bindings/root.h>
|
||||
#include <tactility/bindings/esp32_gpio.h>
|
||||
#include <tactility/bindings/esp32_i2c.h>
|
||||
#include <tactility/bindings/esp32_spi.h>
|
||||
#include <tactility/bindings/esp32_uart.h>
|
||||
|
||||
/ {
|
||||
@ -24,6 +25,17 @@
|
||||
pin-scl-pullup;
|
||||
};
|
||||
|
||||
spi0 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI2_HOST>;
|
||||
pin-mosi = <3>;
|
||||
pin-miso = <GPIO_PIN_NONE>;
|
||||
pin-sclk = <5>;
|
||||
pin-wp = <GPIO_PIN_NONE>;
|
||||
pin-hd = <GPIO_PIN_NONE>;
|
||||
max-transfer-size = <0>;
|
||||
};
|
||||
|
||||
stemma_qt: uart1 {
|
||||
compatible = "espressif,esp32-uart";
|
||||
port = <UART_NUM_1>;
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Xpt2046Power.h>
|
||||
|
||||
#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<Xpt2046Power>(),
|
||||
createDisplay(),
|
||||
createSdCard()
|
||||
};
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#include "devices/Display.h"
|
||||
#include "devices/SdCard.h"
|
||||
#include <driver/gpio.h>
|
||||
#include <driver/gpio.h>
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -75,7 +75,6 @@ private:
|
||||
public:
|
||||
|
||||
explicit Ili9488Display(std::unique_ptr<Configuration> inConfiguration) :
|
||||
EspLcdDisplay(tt::hal::spi::getLock(inConfiguration->spiHostDevice)),
|
||||
configuration(std::move(inConfiguration)
|
||||
) {
|
||||
assert(configuration != nullptr);
|
||||
|
||||
@ -1,15 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/display/DisplayDevice.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <EspLcdDisplayDriver.h>
|
||||
#include <esp_lcd_panel_rgb.h>
|
||||
#include <esp_lvgl_port_disp.h>
|
||||
|
||||
class RgbDisplay final : public tt::hal::display::DisplayDevice {
|
||||
|
||||
std::shared_ptr<tt::Lock> lock = std::make_shared<tt::RecursiveMutex>();
|
||||
|
||||
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<tt::hal::display::DisplayDriver> _Nullable getDisplayDriver() override {
|
||||
if (displayDriver == nullptr) {
|
||||
auto config = getLvglPortDisplayConfig();
|
||||
displayDriver = std::make_shared<EspLcdDisplayDriver>(panelHandle, lock, config.hres, config.vres, tt::hal::display::ColorFormat::RGB888);
|
||||
displayDriver = std::make_shared<EspLcdDisplayDriver>(panelHandle, config.hres, config.vres, tt::hal::display::ColorFormat::RGB888);
|
||||
}
|
||||
return displayDriver;
|
||||
}
|
||||
|
||||
@ -57,7 +57,6 @@ private:
|
||||
public:
|
||||
|
||||
explicit Ssd1306Display(std::unique_ptr<Configuration> inConfiguration) :
|
||||
EspLcdDisplay(nullptr),
|
||||
configuration(std::move(inConfiguration))
|
||||
{
|
||||
assert(configuration != nullptr);
|
||||
|
||||
@ -87,12 +87,8 @@ private:
|
||||
public:
|
||||
|
||||
explicit St7735Display(std::unique_ptr<Configuration> 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"; }
|
||||
|
||||
|
||||
@ -1,105 +0,0 @@
|
||||
#include "Xpt2046Power.h"
|
||||
#include "Xpt2046Touch.h"
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
#include <tactility/hal/Device.h>
|
||||
|
||||
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<Xpt2046Touch> findXp2046TouchDevice() {
|
||||
// Make a safe copy
|
||||
auto touch = tt::hal::findFirstDevice<tt::hal::touch::TouchDevice>(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<Xpt2046Touch>(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;
|
||||
}
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/power/PowerDevice.h>
|
||||
|
||||
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<Xpt2046Touch> 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;
|
||||
};
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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));
|
||||
}
|
||||
|
||||
|
||||
@ -10,11 +10,6 @@ typedef std::vector<std::shared_ptr<Device>> DeviceVector;
|
||||
|
||||
typedef std::shared_ptr<Device> (*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<DeviceVector()> createDevices = [] { return std::vector<std::shared_ptr<Device>>(); };
|
||||
std::function<DeviceVector()> createDevices = [] { return DeviceVector(); };
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -47,8 +47,8 @@ static void dispatchDisconnectButKeepActive(std::shared_ptr<Wifi> wifi);
|
||||
class Wifi {
|
||||
|
||||
std::atomic<RadioState> radio_state = RadioState::Off;
|
||||
bool scan_active = false;
|
||||
bool secure_connection = false;
|
||||
std::atomic<bool> scan_active = false;
|
||||
std::atomic<bool> 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>(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));
|
||||
}
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user