Merge develop into main (#316)

- Updated all boards to use `hal::Configuration.createDevices`
- Updated all boards to use new directory structure and file naming convention
- Refactored `Xpt2046SoftSpi` driver.
- Created `Axp2101Power` device in `Drivers/AXP2101`
- Removed global static instances from some drivers (instances that kept a reference to the Device*)
- Improved `SystemInfoApp` UI: better memory labels, hide external memory bar when there's no PSRAM
- Fix for HAL: register touch devices after displays are registered
- Fix for Boot splash hanging on WiFi init: unlock file lock after using it
This commit is contained in:
Ken Van Hoeylandt 2025-09-03 22:05:28 +02:00 committed by GitHub
parent 1deaf4c426
commit 1627b9fa85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
135 changed files with 543 additions and 577 deletions

View File

@ -1,22 +1,26 @@
#include "CYD2432S024C.h" #include "CYD2432S024C.h"
#include "hal/YellowDisplay.h" #include "devices/Display.h"
#include "hal/YellowDisplayConstants.h" #include "devices/SdCard.h"
#include "hal/YellowSdCard.h"
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#define CYD_SPI_TRANSFER_SIZE_LIMIT (TWODOTFOUR_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8) #define CYD_SPI_TRANSFER_SIZE_LIMIT (TWODOTFOUR_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8)
bool initBoot() { static bool initBoot() {
return driver::pwmbacklight::init(TWODOTFOUR_LCD_PIN_BACKLIGHT); return driver::pwmbacklight::init(TWODOTFOUR_LCD_PIN_BACKLIGHT);
} }
static tt::hal::DeviceVector createDevices() {
return {
createDisplay(),
createSdCard()
};
}
const tt::hal::Configuration cyd_2432s024c_config = { const tt::hal::Configuration cyd_2432s024c_config = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createYellowSdCard(),
.power = nullptr,
.i2c = { .i2c = {
tt::hal::i2c::Configuration { tt::hal::i2c::Configuration {
.name = "First", .name = "First",

View File

@ -1,6 +1,5 @@
#include "YellowDisplay.h" #include "Display.h"
#include "Cst816Touch.h" #include "Cst816Touch.h"
#include "YellowDisplayConstants.h"
#include <Ili934xDisplay.h> #include <Ili934xDisplay.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>

View File

@ -1,5 +1,8 @@
#pragma once #pragma once
#include "Tactility/hal/display/DisplayDevice.h"
#include <memory>
#define TWODOTFOUR_LCD_PIN_BACKLIGHT GPIO_NUM_27 #define TWODOTFOUR_LCD_PIN_BACKLIGHT GPIO_NUM_27
// Display // Display
@ -11,3 +14,4 @@
#define TWODOTFOUR_LCD_PIN_CS GPIO_NUM_15 #define TWODOTFOUR_LCD_PIN_CS GPIO_NUM_15
#define TWODOTFOUR_LCD_PIN_DC GPIO_NUM_2 #define TWODOTFOUR_LCD_PIN_DC GPIO_NUM_2
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -1,4 +1,4 @@
#include "YellowSdCard.h" #include "SdCard.h"
#define TAG "twodotfour_sdcard" #define TAG "twodotfour_sdcard"
@ -9,7 +9,7 @@ constexpr auto SDCARD_PIN_CS = GPIO_NUM_5;
using tt::hal::sdcard::SpiSdCardDevice; using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createYellowSdCard() { std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>( auto configuration = std::make_unique<SpiSdCardDevice::Config>(
SDCARD_PIN_CS, SDCARD_PIN_CS,
GPIO_NUM_NC, GPIO_NUM_NC,

View File

@ -1,6 +0,0 @@
#pragma once
#include "Tactility/hal/display/DisplayDevice.h"
#include <memory>
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -1,8 +0,0 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createYellowSdCard();

View File

@ -1,5 +0,0 @@
#pragma once
// Touch
#define TWODOTFOUR_TOUCH_I2C_PORT I2C_NUM_0

View File

@ -1,14 +1,18 @@
#include "CYD2432S028R.h" #include "CYD2432S028R.h"
#include "hal/YellowDisplay.h" #include "devices/Display.h"
#include "hal/YellowConstants.h" #include "devices/SdCard.h"
#include "hal/YellowSdCard.h"
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
// SPI Transfer
#define CYD_SPI_TRANSFER_SIZE_LIMIT (CYD2432S028R_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8)
// Display backlight (PWM)
#define CYD2432S028R_LCD_PIN_BACKLIGHT GPIO_NUM_21
using namespace tt::hal; using namespace tt::hal;
bool initBoot() { static bool initBoot() {
//Set the RGB Led Pins to output and turn them off //Set the RGB Led Pins to output and turn them off
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT)); //Red ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT)); //Red
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_16, GPIO_MODE_OUTPUT)); //Green ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_16, GPIO_MODE_OUTPUT)); //Green
@ -22,16 +26,21 @@ bool initBoot() {
return driver::pwmbacklight::init(CYD2432S028R_LCD_PIN_BACKLIGHT); return driver::pwmbacklight::init(CYD2432S028R_LCD_PIN_BACKLIGHT);
} }
static DeviceVector createDevices() {
return {
createDisplay(),
createSdCard()
};
}
const Configuration cyd_2432s028r_config = { const Configuration cyd_2432s028r_config = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createYellowSdCard(),
.power = nullptr,
.i2c = {}, .i2c = {},
.spi { .spi {
//Display //Display
spi::Configuration { spi::Configuration {
.device = CYD2432S028R_LCD_SPI_HOST, .device = SPI2_HOST,
.dma = SPI_DMA_CH_AUTO, .dma = SPI_DMA_CH_AUTO,
.config = { .config = {
.mosi_io_num = GPIO_NUM_13, .mosi_io_num = GPIO_NUM_13,
@ -56,7 +65,7 @@ const Configuration cyd_2432s028r_config = {
// SDCard // SDCard
spi::Configuration { spi::Configuration {
.device = CYD2432S028R_SDCARD_SPI_HOST, .device = SPI3_HOST,
.dma = SPI_DMA_CH_AUTO, .dma = SPI_DMA_CH_AUTO,
.config = { .config = {
.mosi_io_num = GPIO_NUM_23, .mosi_io_num = GPIO_NUM_23,
@ -74,7 +83,7 @@ const Configuration cyd_2432s028r_config = {
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0 .intr_flags = 0
}, },
.initMode = tt::hal::spi::InitMode::ByTactility, .initMode = spi::InitMode::ByTactility,
.isMutable = false, .isMutable = false,
.lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display .lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display
}, },

View File

@ -1,13 +1,9 @@
#include "YellowDisplay.h" #include "Display.h"
#include "Xpt2046SoftSpi.h" #include "Xpt2046SoftSpi.h"
#include "YellowConstants.h"
#include <Ili934xDisplay.h> #include <Ili934xDisplay.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
static const char* TAG = "YellowDisplay"; constexpr auto* TAG = "CYD";
// Global to hold reference (only needed if calling stop() later)
static std::unique_ptr<Xpt2046SoftSpi> touch;
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() { static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto configuration = std::make_unique<Xpt2046SoftSpi::Configuration>( auto configuration = std::make_unique<Xpt2046SoftSpi::Configuration>(
@ -23,17 +19,15 @@ static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
); );
// Allocate the driver // Allocate the driver
touch = std::make_unique<Xpt2046SoftSpi>(std::move(configuration)); auto touch = std::make_shared<Xpt2046SoftSpi>(std::move(configuration));
// Start the driver // Start the driver
if (!touch->start()) { if (!touch->start()) {
ESP_LOGE(TAG, "Touch driver start failed"); ESP_LOGE(TAG, "Touch driver start failed");
return nullptr; return nullptr;
} }
return std::shared_ptr<tt::hal::touch::TouchDevice>(touch.get(), [](tt::hal::touch::TouchDevice*) { return touch;
// No delete needed; `touch` is managed above
});
} }
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() { std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
// Display backlight (PWM) #include "Tactility/hal/display/DisplayDevice.h"
#define CYD2432S028R_LCD_PIN_BACKLIGHT GPIO_NUM_21 #include <memory>
// Display // Display
#define CYD2432S028R_LCD_SPI_HOST SPI2_HOST #define CYD2432S028R_LCD_SPI_HOST SPI2_HOST
@ -12,10 +12,6 @@
#define CYD2432S028R_LCD_PIN_CS GPIO_NUM_15 #define CYD2432S028R_LCD_PIN_CS GPIO_NUM_15
#define CYD2432S028R_LCD_PIN_DC GPIO_NUM_2 #define CYD2432S028R_LCD_PIN_DC GPIO_NUM_2
// Touch
#define CYD2432S028R_TOUCH_SPI_HOST SPI3_HOST
#define CYD2432S028R_TOUCH_PIN_CS GPIO_NUM_33
// Touch (Software SPI) // Touch (Software SPI)
#define CYD_TOUCH_MISO_PIN GPIO_NUM_39 #define CYD_TOUCH_MISO_PIN GPIO_NUM_39
#define CYD_TOUCH_MOSI_PIN GPIO_NUM_32 #define CYD_TOUCH_MOSI_PIN GPIO_NUM_32
@ -23,9 +19,4 @@
#define CYD_TOUCH_CS_PIN GPIO_NUM_33 #define CYD_TOUCH_CS_PIN GPIO_NUM_33
#define CYD_TOUCH_IRQ_PIN GPIO_NUM_36 #define CYD_TOUCH_IRQ_PIN GPIO_NUM_36
// SDCard std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
#define CYD2432S028R_SDCARD_SPI_HOST SPI3_HOST
#define CYD2432S028R_SDCARD_PIN_CS GPIO_NUM_5
// SPI Transfer
#define CYD_SPI_TRANSFER_SIZE_LIMIT (CYD2432S028R_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8)

View File

@ -0,0 +1,21 @@
#include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h>
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto config = std::make_unique<SpiSdCardDevice::Config>(
GPIO_NUM_5,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
std::make_shared<tt::Mutex>(),
std::vector<gpio_num_t>(),
SPI3_HOST
);
return std::make_shared<SpiSdCardDevice>(std::move(config));
}

View File

@ -1,6 +0,0 @@
#pragma once
#include "Tactility/hal/display/DisplayDevice.h"
#include <memory>
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -1,26 +0,0 @@
#include "YellowSdCard.h"
#include "YellowConstants.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h>
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createYellowSdCard() {
auto* configuration = new SpiSdCardDevice::Config(
CYD2432S028R_SDCARD_PIN_CS,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
std::make_shared<tt::Mutex>(),
std::vector<gpio_num_t>(),
CYD2432S028R_SDCARD_SPI_HOST
);
auto* sdcard = (SdCardDevice*) new SpiSdCardDevice(
std::unique_ptr<SpiSdCardDevice::Config>(configuration)
);
return std::shared_ptr<SdCardDevice>(sdcard);
}

View File

@ -1,8 +0,0 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createYellowSdCard();

View File

@ -1,7 +1,7 @@
#include "CYD2432S032C.h" #include "CYD2432S032C.h"
#include "Tactility/lvgl/LvglSync.h" #include "Tactility/lvgl/LvglSync.h"
#include "hal/CydDisplay.h" #include "devices/Display.h"
#include "hal/CydSdCard.h" #include "devices/SdCard.h"
#include <Tactility/kernel/SystemEvents.h> #include <Tactility/kernel/SystemEvents.h>
@ -25,11 +25,16 @@ bool initBoot() {
return true; return true;
} }
static tt::hal::DeviceVector createDevices() {
return {
createDisplay(),
createSdCard()
};
}
const tt::hal::Configuration cyd_2432S032c_config = { const tt::hal::Configuration cyd_2432S032c_config = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.power = nullptr,
.i2c = { .i2c = {
tt::hal::i2c::Configuration { tt::hal::i2c::Configuration {
.name = "Internal", .name = "Internal",

View File

@ -1,4 +1,4 @@
#include "CydDisplay.h" #include "Display.h"
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <Ili934xDisplay.h> #include <Ili934xDisplay.h>

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <Tactility/hal/display/DisplayDevice.h> #include <Tactility/hal/display/DisplayDevice.h>
#include <memory>
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay(); std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -1,6 +1,4 @@
#include "YellowSdCard.h" #include "SdCard.h"
#define TAG "jc2432w328c_sdcard"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
@ -10,7 +8,7 @@ constexpr auto SDCARD_PIN_CS = GPIO_NUM_5;
using tt::hal::sdcard::SpiSdCardDevice; using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createYellowSdCard() { std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>( auto configuration = std::make_unique<SpiSdCardDevice::Config>(
SDCARD_PIN_CS, SDCARD_PIN_CS,
GPIO_NUM_NC, GPIO_NUM_NC,

View File

@ -0,0 +1,8 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();

View File

@ -1,6 +0,0 @@
#pragma once
#include "Tactility/hal/display/DisplayDevice.h"
#include <memory>
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -1,20 +1,25 @@
#include "CYD4848S040C.h" #include "CYD4848S040C.h"
#include "hal/CydDisplay.h" #include "devices/St7701Display.h"
#include "hal/CydSdCard.h" #include "devices/SdCard.h"
#include <PwmBacklight.h> #include <PwmBacklight.h>
using namespace tt::hal; using namespace tt::hal;
bool initBoot() { static bool initBoot() {
return driver::pwmbacklight::init(GPIO_NUM_38, 1000); return driver::pwmbacklight::init(GPIO_NUM_38, 1000);
} }
static DeviceVector createDevices() {
return {
std::reinterpret_pointer_cast<Device>(std::make_shared<St7701Display>()),
createSdCard()
};
}
const Configuration cyd_4848s040c_config = { const Configuration cyd_4848s040c_config = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.power = nullptr,
.i2c = { .i2c = {
//Touch //Touch
i2c::Configuration { i2c::Configuration {

View File

@ -1,4 +1,4 @@
#include "CydSdCard.h" #include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>

View File

@ -5,3 +5,4 @@
using tt::hal::sdcard::SdCardDevice; using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard(); std::shared_ptr<SdCardDevice> createSdCard();

View File

@ -1,4 +1,4 @@
#include "CydDisplay.h" #include "St7701Display.h"
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
@ -11,7 +11,7 @@
#include <esp_lcd_panel_io_additions.h> #include <esp_lcd_panel_io_additions.h>
#include <esp_lcd_st7701.h> #include <esp_lcd_st7701.h>
constexpr auto TAG = "ST7701"; constexpr auto TAG = "St7701Display";
static const st7701_lcd_init_cmd_t st7701_lcd_init_cmds[] = { static const st7701_lcd_init_cmd_t st7701_lcd_init_cmds[] = {
// {cmd, { data }, data_size, delay_ms} // {cmd, { data }, data_size, delay_ms}
@ -56,7 +56,7 @@ static const st7701_lcd_init_cmd_t st7701_lcd_init_cmds[] = {
{0x29, (uint8_t[]) {0x00}, 0, 0}, //Display On {0x29, (uint8_t[]) {0x00}, 0, 0}, //Display On
}; };
bool CydDisplay::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) { bool St7701Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
spi_line_config_t line_config = { spi_line_config_t line_config = {
.cs_io_type = IO_TYPE_GPIO, .cs_io_type = IO_TYPE_GPIO,
.cs_gpio_num = GPIO_NUM_39, .cs_gpio_num = GPIO_NUM_39,
@ -70,7 +70,7 @@ bool CydDisplay::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
return esp_lcd_new_panel_io_3wire_spi(&panel_io_config, &outHandle) == ESP_OK; return esp_lcd_new_panel_io_3wire_spi(&panel_io_config, &outHandle) == ESP_OK;
} }
bool CydDisplay::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t& panelHandle) { bool St7701Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t& panelHandle) {
const esp_lcd_rgb_panel_config_t rgb_config = { const esp_lcd_rgb_panel_config_t rgb_config = {
.clk_src = LCD_CLK_SRC_DEFAULT, .clk_src = LCD_CLK_SRC_DEFAULT,
.timings = { .timings = {
@ -180,7 +180,7 @@ bool CydDisplay::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_p
return true; return true;
} }
lvgl_port_display_cfg_t CydDisplay::getLvglPortDisplayConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) { lvgl_port_display_cfg_t St7701Display::getLvglPortDisplayConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) {
return { return {
.io_handle = ioHandle, .io_handle = ioHandle,
.panel_handle = panelHandle, .panel_handle = panelHandle,
@ -208,7 +208,7 @@ lvgl_port_display_cfg_t CydDisplay::getLvglPortDisplayConfig(esp_lcd_panel_io_ha
}; };
} }
lvgl_port_display_rgb_cfg_t CydDisplay::getLvglPortDisplayRgbConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) { lvgl_port_display_rgb_cfg_t St7701Display::getLvglPortDisplayRgbConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) {
return { return {
.flags = { .flags = {
.bb_mode = true, .bb_mode = true,
@ -217,7 +217,7 @@ lvgl_port_display_rgb_cfg_t CydDisplay::getLvglPortDisplayRgbConfig(esp_lcd_pane
}; };
} }
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable CydDisplay::getTouchDevice() { std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable St7701Display::getTouchDevice() {
if (touchDevice == nullptr) { if (touchDevice == nullptr) {
auto configuration = std::make_unique<Gt911Touch::Configuration>( auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0, I2C_NUM_0,
@ -231,11 +231,6 @@ std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable CydDisplay::getTouchDevic
return touchDevice; return touchDevice;
} }
void CydDisplay::setBacklightDuty(uint8_t backlightDuty) { void St7701Display::setBacklightDuty(uint8_t backlightDuty) {
driver::pwmbacklight::setBacklightDuty(backlightDuty); driver::pwmbacklight::setBacklightDuty(backlightDuty);
} }
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
auto display = std::make_shared<CydDisplay>();
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
}

View File

@ -5,7 +5,7 @@
#include <EspLcdDisplay.h> #include <EspLcdDisplay.h>
#include <lvgl.h> #include <lvgl.h>
class CydDisplay final : public EspLcdDisplay { class St7701Display final : public EspLcdDisplay {
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable touchDevice; std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable touchDevice;
@ -21,7 +21,7 @@ class CydDisplay final : public EspLcdDisplay {
public: public:
CydDisplay() : EspLcdDisplay(std::make_shared<tt::Mutex>(tt::Mutex::Type::Recursive)) {} St7701Display() : EspLcdDisplay(std::make_shared<tt::Mutex>(tt::Mutex::Type::Recursive)) {}
std::string getName() const override { return "ST7701S"; } std::string getName() const override { return "ST7701S"; }
@ -33,5 +33,3 @@ public:
bool supportsBacklightDuty() const override { return true; } bool supportsBacklightDuty() const override { return true; }
}; };
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -1,21 +1,27 @@
#include "CYD8048S043C.h" // Don't remove, or we get a linker error ("undefined reference to `cyd_8048s043c_config'" - GCC bug?) #include "CYD8048S043C.h" // Don't remove, or we get a linker error ("undefined reference to `cyd_8048s043c_config'" - GCC bug?)
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include "hal/CydDisplay.h" #include "devices/Display.h"
#include "hal/CydSdCard.h" #include "devices/SdCard.h"
using namespace tt::hal; using namespace tt::hal;
bool initBoot() { static bool initBoot() {
// Display backlight
return driver::pwmbacklight::init(GPIO_NUM_2, 200); return driver::pwmbacklight::init(GPIO_NUM_2, 200);
} }
static DeviceVector createDevices() {
return {
createDisplay(),
createSdCard()
};
}
const Configuration cyd_8048s043c_config = { const Configuration cyd_8048s043c_config = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.power = nullptr,
.i2c = { .i2c = {
//Touch // Touch
i2c::Configuration { i2c::Configuration {
.name = "Internal", .name = "Internal",
.port = I2C_NUM_0, .port = I2C_NUM_0,
@ -33,7 +39,7 @@ const Configuration cyd_8048s043c_config = {
.clk_flags = 0 .clk_flags = 0
} }
}, },
//P4 header, JST SH 1.0, GND / 3.3V / IO17 / IO18 // P4 header, JST SH 1.0, GND / 3.3V / IO17 / IO18
i2c::Configuration { i2c::Configuration {
.name = "External", .name = "External",
.port = I2C_NUM_1, .port = I2C_NUM_1,
@ -53,7 +59,7 @@ const Configuration cyd_8048s043c_config = {
} }
}, },
.spi { .spi {
//SD Card // SD Card
spi::Configuration { spi::Configuration {
.device = SPI2_HOST, .device = SPI2_HOST,
.dma = SPI_DMA_CH_AUTO, .dma = SPI_DMA_CH_AUTO,
@ -79,7 +85,7 @@ const Configuration cyd_8048s043c_config = {
} }
}, },
.uart { .uart {
//P4 header, JST SH 1.0, GND / 3.3V / IO17 / IO18 // P4 header, JST SH 1.0, GND / 3.3V / IO17 / IO18
uart::Configuration { uart::Configuration {
.name = "UART1", .name = "UART1",
.port = UART_NUM_1, .port = UART_NUM_1,

View File

@ -1,4 +1,4 @@
#include "CydDisplay.h" #include "Display.h"
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>

View File

@ -1,4 +1,4 @@
#include "CydSdCard.h" #include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>

View File

@ -1,18 +1,16 @@
#include "JC2432W328C.h" #include "JC2432W328C.h"
#include "hal/YellowDisplay.h" #include "devices/Display.h"
#include "hal/YellowDisplayConstants.h" #include "devices/SdCard.h"
#include "hal/YellowSdCard.h"
#include <Tactility/lvgl/LvglSync.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
#include <Tactility/lvgl/LvglSync.h>
using namespace tt::hal; using namespace tt::hal;
#define CYD_SPI_TRANSFER_SIZE_LIMIT (JC2432W328C_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8) #define CYD_SPI_TRANSFER_SIZE_LIMIT (JC2432W328C_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8)
bool initBoot() { static bool initBoot() {
//Set the RGB Led Pins to output and turn them off //Set the RGB Led Pins to output and turn them off
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT)); //Red ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT)); //Red
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_16, GPIO_MODE_OUTPUT)); //Green ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_16, GPIO_MODE_OUTPUT)); //Green
@ -26,11 +24,16 @@ bool initBoot() {
return driver::pwmbacklight::init(JC2432W328C_LCD_PIN_BACKLIGHT); return driver::pwmbacklight::init(JC2432W328C_LCD_PIN_BACKLIGHT);
} }
static DeviceVector createDevices() {
return {
createDisplay(),
createSdCard()
};
}
const Configuration cyd_jc2432w328c_config = { const Configuration cyd_jc2432w328c_config = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createYellowSdCard(),
.power = nullptr,
.i2c = { .i2c = {
//Touch //Touch
i2c::Configuration { i2c::Configuration {

View File

@ -1,9 +1,8 @@
#include "YellowDisplay.h" #include "Display.h"
#include "Cst816Touch.h"
#include "YellowDisplayConstants.h"
#include <St7789Display.h> #include <Cst816Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <St7789Display.h>
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() { static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto configuration = std::make_unique<Cst816sTouch::Configuration>( auto configuration = std::make_unique<Cst816sTouch::Configuration>(

View File

@ -1,5 +1,8 @@
#pragma once #pragma once
#include "Tactility/hal/display/DisplayDevice.h"
#include <memory>
// Display backlight (PWM) // Display backlight (PWM)
#define JC2432W328C_LCD_PIN_BACKLIGHT GPIO_NUM_27 #define JC2432W328C_LCD_PIN_BACKLIGHT GPIO_NUM_27
@ -12,3 +15,4 @@
#define JC2432W328C_LCD_PIN_CS GPIO_NUM_15 #define JC2432W328C_LCD_PIN_CS GPIO_NUM_15
#define JC2432W328C_LCD_PIN_DC GPIO_NUM_2 #define JC2432W328C_LCD_PIN_DC GPIO_NUM_2
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -1,10 +1,10 @@
#include "CydSdCard.h" #include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#define SDCARD_SPI_HOST SPI3_HOST constexpr auto SDCARD_SPI_HOST = SPI3_HOST;
#define SDCARD_PIN_CS GPIO_NUM_5 constexpr auto SDCARD_PIN_CS = GPIO_NUM_5;
using tt::hal::sdcard::SpiSdCardDevice; using tt::hal::sdcard::SpiSdCardDevice;

View File

@ -5,3 +5,4 @@
using tt::hal::sdcard::SdCardDevice; using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard(); std::shared_ptr<SdCardDevice> createSdCard();

View File

@ -1,6 +0,0 @@
#pragma once
#include "Tactility/hal/display/DisplayDevice.h"
#include <memory>
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -1,8 +0,0 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createYellowSdCard();

View File

@ -1,19 +1,24 @@
#include "JC8048W550C.h" // Don't remove, or we get a linker error ("undefined reference to `cyd_jc8048w550c_config'" - GCC bug?) #include "JC8048W550C.h" // Don't remove, or we get a linker error ("undefined reference to `cyd_jc8048w550c_config'" - GCC bug?)
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include "hal/CydDisplay.h" #include "devices/Display.h"
#include "hal/CydSdCard.h" #include "devices/SdCard.h"
using namespace tt::hal; using namespace tt::hal;
bool initBoot() { static bool initBoot() {
return driver::pwmbacklight::init(GPIO_NUM_2); return driver::pwmbacklight::init(GPIO_NUM_2);
} }
static DeviceVector createDevices() {
return {
createDisplay(),
createSdCard()
};
}
const Configuration cyd_jc8048w550c_config = { const Configuration cyd_jc8048w550c_config = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.power = nullptr,
.i2c = { .i2c = {
//Touch //Touch
i2c::Configuration { i2c::Configuration {

View File

@ -1,9 +1,8 @@
#include "RgbDisplay.h" #include "Display.h"
#include "CydDisplay.h"
#include <PwmBacklight.h>
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <RgbDisplay.h>
#include <Tactility/Log.h> #include <Tactility/Log.h>
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() { std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() {

View File

@ -1,4 +1,4 @@
#include "CydSdCard.h" #include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>

View File

@ -0,0 +1,7 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();

View File

@ -1,8 +1,7 @@
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include "Tactility/lvgl/LvglSync.h" #include "Tactility/lvgl/LvglSync.h"
#include "hal/CrowPanelDisplay.h" #include "devices/Display.h"
#include "hal/CrowPanelDisplayConstants.h" #include "devices/SdCard.h"
#include "hal/CrowPanelSdCard.h"
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
@ -10,14 +9,20 @@
using namespace tt::hal; using namespace tt::hal;
bool initBoot() { static bool initBoot() {
return driver::pwmbacklight::init(GPIO_NUM_38); return driver::pwmbacklight::init(GPIO_NUM_38);
} }
static DeviceVector createDevices() {
return {
createDisplay(),
createSdCard()
};
}
extern const Configuration crowpanel_advance_28 = { extern const Configuration crowpanel_advance_28 = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.i2c = { .i2c = {
// There is only 1 (internal for touch, and also serves as "I2C-OUT" port) // There is only 1 (internal for touch, and also serves as "I2C-OUT" port)
// Note: You could repurpose 1 or more UART interfaces as I2C interfaces // Note: You could repurpose 1 or more UART interfaces as I2C interfaces

View File

@ -1,5 +1,4 @@
#include "CrowPanelDisplay.h" #include "Display.h"
#include "CrowPanelDisplayConstants.h"
#include <Ft5x06Touch.h> #include <Ft5x06Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
@ -11,8 +10,8 @@ static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
I2C_NUM_0, I2C_NUM_0,
240, 240,
320, 320,
true, false,
true, false,
false false
); );
@ -26,11 +25,11 @@ std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
CROWPANEL_LCD_SPI_HOST, CROWPANEL_LCD_SPI_HOST,
CROWPANEL_LCD_PIN_CS, CROWPANEL_LCD_PIN_CS,
CROWPANEL_LCD_PIN_DC, CROWPANEL_LCD_PIN_DC,
320,
240, 240,
320,
touch, touch,
true, false,
true, false,
false, false,
true true
); );

View File

@ -1,8 +1,12 @@
#pragma once #pragma once
#include <Tactility/hal/display/DisplayDevice.h>
#define CROWPANEL_LCD_SPI_HOST SPI2_HOST #define CROWPANEL_LCD_SPI_HOST SPI2_HOST
#define CROWPANEL_LCD_PIN_CS GPIO_NUM_40 #define CROWPANEL_LCD_PIN_CS GPIO_NUM_40
#define CROWPANEL_LCD_PIN_DC GPIO_NUM_41 // RS #define CROWPANEL_LCD_PIN_DC GPIO_NUM_41 // RS
#define CROWPANEL_LCD_HORIZONTAL_RESOLUTION 320 #define CROWPANEL_LCD_HORIZONTAL_RESOLUTION 320
#define CROWPANEL_LCD_VERTICAL_RESOLUTION 240 #define CROWPANEL_LCD_VERTICAL_RESOLUTION 240
#define CROWPANEL_LCD_SPI_TRANSFER_HEIGHT (CROWPANEL_LCD_VERTICAL_RESOLUTION / 10) #define CROWPANEL_LCD_SPI_TRANSFER_HEIGHT (CROWPANEL_LCD_VERTICAL_RESOLUTION / 10)
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -1,10 +1,8 @@
#include "CrowPanelSdCard.h" #include "SdCard.h"
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <esp_vfs_fat.h>
using tt::hal::sdcard::SpiSdCardDevice; using tt::hal::sdcard::SpiSdCardDevice;
constexpr auto CROWPANEL_SDCARD_PIN_CS = GPIO_NUM_7; constexpr auto CROWPANEL_SDCARD_PIN_CS = GPIO_NUM_7;

View File

@ -1,8 +1,7 @@
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include "Tactility/lvgl/LvglSync.h" #include "Tactility/lvgl/LvglSync.h"
#include "hal/CrowPanelDisplay.h" #include "devices/Display.h"
#include "hal/CrowPanelDisplayConstants.h" #include "devices/SdCard.h"
#include "hal/CrowPanelSdCard.h"
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
@ -10,14 +9,20 @@
using namespace tt::hal; using namespace tt::hal;
bool initBoot() { static bool initBoot() {
return driver::pwmbacklight::init(GPIO_NUM_38); return driver::pwmbacklight::init(GPIO_NUM_38);
} }
static DeviceVector createDevices() {
return {
createDisplay(),
createSdCard()
};
}
extern const Configuration crowpanel_advance_35 = { extern const Configuration crowpanel_advance_35 = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.i2c = { .i2c = {
// There is only 1 (internal for touch, and also serves as "I2C-OUT" port) // There is only 1 (internal for touch, and also serves as "I2C-OUT" port)
// Note: You could repurpose 1 or more UART interfaces as I2C interfaces // Note: You could repurpose 1 or more UART interfaces as I2C interfaces

View File

@ -1,12 +1,9 @@
#include "CrowPanelDisplay.h" #include "Display.h"
#include "CrowPanelDisplayConstants.h"
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <Ili9488Display.h> #include <Ili9488Display.h>
#define TAG "crowpanel_display"
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() { static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
// Note for future changes: Reset pin is 48 and interrupt pin is 47 // Note for future changes: Reset pin is 48 and interrupt pin is 47
auto configuration = std::make_unique<Gt911Touch::Configuration>( auto configuration = std::make_unique<Gt911Touch::Configuration>(

View File

@ -1,8 +1,12 @@
#pragma once #pragma once
#include <Tactility/hal/display/DisplayDevice.h>
#define CROWPANEL_LCD_SPI_HOST SPI2_HOST #define CROWPANEL_LCD_SPI_HOST SPI2_HOST
#define CROWPANEL_LCD_PIN_CS GPIO_NUM_40 #define CROWPANEL_LCD_PIN_CS GPIO_NUM_40
#define CROWPANEL_LCD_PIN_DC GPIO_NUM_41 // RS #define CROWPANEL_LCD_PIN_DC GPIO_NUM_41 // RS
#define CROWPANEL_LCD_HORIZONTAL_RESOLUTION 320 #define CROWPANEL_LCD_HORIZONTAL_RESOLUTION 320
#define CROWPANEL_LCD_VERTICAL_RESOLUTION 480 #define CROWPANEL_LCD_VERTICAL_RESOLUTION 480
#define CROWPANEL_LCD_SPI_TRANSFER_HEIGHT (CROWPANEL_LCD_VERTICAL_RESOLUTION / 10) #define CROWPANEL_LCD_SPI_TRANSFER_HEIGHT (CROWPANEL_LCD_VERTICAL_RESOLUTION / 10)
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -1,10 +1,8 @@
#include "CrowPanelSdCard.h" #include "SdCard.h"
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <esp_vfs_fat.h>
using tt::hal::sdcard::SpiSdCardDevice; using tt::hal::sdcard::SpiSdCardDevice;
constexpr auto CROWPANEL_SDCARD_PIN_CS = GPIO_NUM_7; constexpr auto CROWPANEL_SDCARD_PIN_CS = GPIO_NUM_7;

View File

@ -1,12 +1,12 @@
#include "hal/CrowPanelDisplay.h" #include "devices/Display.h"
#include "hal/CrowPanelSdCard.h" #include "devices/SdCard.h"
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
#include <TCA9534.h> #include <TCA9534.h>
using namespace tt::hal; using namespace tt::hal;
bool initBoot() { static bool initBoot() {
TCA9534_IO_EXP io_expander = { TCA9534_IO_EXP io_expander = {
.I2C_ADDR = 0x18, .I2C_ADDR = 0x18,
.i2c_master_port = I2C_NUM_0, .i2c_master_port = I2C_NUM_0,
@ -21,10 +21,16 @@ bool initBoot() {
return true; return true;
} }
static DeviceVector createDevices() {
return {
createDisplay(),
createSdCard()
};
}
extern const Configuration crowpanel_advance_50 = { extern const Configuration crowpanel_advance_50 = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.i2c = { .i2c = {
// There is only 1 (internal for touch, and also serves as "I2C-OUT" port) // There is only 1 (internal for touch, and also serves as "I2C-OUT" port)
// Note: You could repurpose 1 or more UART interfaces as I2C interfaces // Note: You could repurpose 1 or more UART interfaces as I2C interfaces

View File

@ -1,4 +1,4 @@
#include "CrowPanelDisplay.h" #include "Display.h"
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <RgbDisplay.h> #include <RgbDisplay.h>

View File

@ -1,10 +1,8 @@
#include "CrowPanelSdCard.h" #include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <esp_vfs_fat.h>
using tt::hal::sdcard::SpiSdCardDevice; using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() { std::shared_ptr<SdCardDevice> createSdCard() {

View File

@ -0,0 +1,7 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();

View File

@ -1,25 +1,30 @@
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include "Tactility/lvgl/LvglSync.h" #include "devices/Display.h"
#include "hal/CrowPanelDisplay.h" #include "devices/SdCard.h"
#include "hal/CrowPanelDisplayConstants.h"
#include "hal/CrowPanelSdCard.h"
#include <Xpt2046Power.h> #include <Xpt2046Power.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
#include <Tactility/lvgl/LvglSync.h>
#define CROWPANEL_SPI_TRANSFER_SIZE_LIMIT (CROWPANEL_LCD_HORIZONTAL_RESOLUTION * CROWPANEL_LCD_SPI_TRANSFER_HEIGHT * (LV_COLOR_DEPTH / 8)) #define CROWPANEL_SPI_TRANSFER_SIZE_LIMIT (CROWPANEL_LCD_HORIZONTAL_RESOLUTION * CROWPANEL_LCD_SPI_TRANSFER_HEIGHT * (LV_COLOR_DEPTH / 8))
using namespace tt::hal; using namespace tt::hal;
bool initBoot() { static bool initBoot() {
return driver::pwmbacklight::init(GPIO_NUM_27); return driver::pwmbacklight::init(GPIO_NUM_27);
} }
static DeviceVector createDevices() {
return {
std::make_shared<Xpt2046Power>(),
createDisplay(),
createSdCard(),
};
}
extern const Configuration crowpanel_basic_28 = { extern const Configuration crowpanel_basic_28 = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.power = getOrCreatePower,
.i2c = { .i2c = {
// There is only 1 (internal for touch, and also serves as "I2C-OUT" port) // There is only 1 (internal for touch, and also serves as "I2C-OUT" port)
// Note: You could repurpose 1 or more UART interfaces as I2C interfaces // Note: You could repurpose 1 or more UART interfaces as I2C interfaces

View File

@ -1,5 +1,4 @@
#include "CrowPanelDisplay.h" #include "Display.h"
#include "CrowPanelDisplayConstants.h"
#include <Ili934xDisplay.h> #include <Ili934xDisplay.h>
#include <Xpt2046Touch.h> #include <Xpt2046Touch.h>

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
#include <Tactility/hal/display/DisplayDevice.h>
#define CROWPANEL_LCD_SPI_HOST SPI2_HOST #define CROWPANEL_LCD_SPI_HOST SPI2_HOST
#define CROWPANEL_LCD_PIN_CS GPIO_NUM_15 #define CROWPANEL_LCD_PIN_CS GPIO_NUM_15
#define CROWPANEL_TOUCH_PIN_CS GPIO_NUM_33 #define CROWPANEL_TOUCH_PIN_CS GPIO_NUM_33
@ -7,3 +9,5 @@
#define CROWPANEL_LCD_HORIZONTAL_RESOLUTION 320 #define CROWPANEL_LCD_HORIZONTAL_RESOLUTION 320
#define CROWPANEL_LCD_VERTICAL_RESOLUTION 240 #define CROWPANEL_LCD_VERTICAL_RESOLUTION 240
#define CROWPANEL_LCD_SPI_TRANSFER_HEIGHT (CROWPANEL_LCD_VERTICAL_RESOLUTION / 10) #define CROWPANEL_LCD_SPI_TRANSFER_HEIGHT (CROWPANEL_LCD_VERTICAL_RESOLUTION / 10)
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -1,4 +1,4 @@
#include "CrowPanelSdCard.h" #include "SdCard.h"
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>

View File

@ -1,5 +0,0 @@
#pragma once
#include "Tactility/hal/display/DisplayDevice.h"
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -1,25 +1,30 @@
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include "Tactility/lvgl/LvglSync.h" #include "Tactility/lvgl/LvglSync.h"
#include "hal/CrowPanelDisplay.h" #include "devices/Display.h"
#include "hal/CrowPanelDisplayConstants.h" #include "devices/SdCard.h"
#include "hal/CrowPanelSdCard.h"
#include <Xpt2046Power.h> #include <Xpt2046Power.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
#define CROWPANEL_SPI_TRANSFER_SIZE_LIMIT (CROWPANEL_LCD_HORIZONTAL_RESOLUTION * CROWPANEL_LCD_SPI_TRANSFER_HEIGHT * (LV_COLOR_DEPTH / 8)) constexpr auto CROWPANEL_SPI_TRANSFER_SIZE_LIMIT = (CROWPANEL_LCD_HORIZONTAL_RESOLUTION * CROWPANEL_LCD_SPI_TRANSFER_HEIGHT * (LV_COLOR_DEPTH / 8));
using namespace tt::hal; using namespace tt::hal;
bool initBoot() { static bool initBoot() {
return driver::pwmbacklight::init(GPIO_NUM_27); return driver::pwmbacklight::init(GPIO_NUM_27);
} }
static DeviceVector createDevices() {
return {
std::make_shared<Xpt2046Power>(),
createDisplay(),
createSdCard(),
};
}
extern const Configuration crowpanel_basic_35 = { extern const Configuration crowpanel_basic_35 = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.power = getOrCreatePower,
.i2c = { .i2c = {
// There is only 1 (internal for touch, and also serves as "I2C-OUT" port) // There is only 1 (internal for touch, and also serves as "I2C-OUT" port)
// Note: You could repurpose 1 or more UART interfaces as I2C interfaces // Note: You could repurpose 1 or more UART interfaces as I2C interfaces

View File

@ -1,10 +1,8 @@
#include "CrowPanelDisplay.h" #include "Display.h"
#include "CrowPanelDisplayConstants.h"
#include <Ili9488Display.h> #include <Ili9488Display.h>
#include <Xpt2046Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <Xpt2046Touch.h>
std::shared_ptr<Xpt2046Touch> createTouch() { std::shared_ptr<Xpt2046Touch> createTouch() {
auto configuration = std::make_unique<Xpt2046Touch::Configuration>( auto configuration = std::make_unique<Xpt2046Touch::Configuration>(
@ -12,8 +10,8 @@ std::shared_ptr<Xpt2046Touch> createTouch() {
CROWPANEL_TOUCH_PIN_CS, CROWPANEL_TOUCH_PIN_CS,
320, 320,
480, 480,
true, false,
true, false,
true true
); );
@ -23,23 +21,18 @@ std::shared_ptr<Xpt2046Touch> createTouch() {
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() { std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
auto touch = createTouch(); auto touch = createTouch();
/**
* This display is mirrored on X, but that doesn't seem to work with the driver.
* Instead, we swap XY, which does work. That results in a landscape image.
*/
auto configuration = std::make_unique<Ili9488Display::Configuration>( auto configuration = std::make_unique<Ili9488Display::Configuration>(
CROWPANEL_LCD_SPI_HOST, CROWPANEL_LCD_SPI_HOST,
CROWPANEL_LCD_PIN_CS, CROWPANEL_LCD_PIN_CS,
CROWPANEL_LCD_PIN_DC, CROWPANEL_LCD_PIN_DC,
480,
320, 320,
480,
touch, touch,
true, false,
false, false,
false false
); );
configuration->mirrorX = true;
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty; configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
auto display = std::make_shared<Ili9488Display>(std::move(configuration)); auto display = std::make_shared<Ili9488Display>(std::move(configuration));

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
#include <Tactility/hal/display/DisplayDevice.h>
#define CROWPANEL_LCD_SPI_HOST SPI2_HOST #define CROWPANEL_LCD_SPI_HOST SPI2_HOST
#define CROWPANEL_LCD_PIN_CS GPIO_NUM_15 #define CROWPANEL_LCD_PIN_CS GPIO_NUM_15
#define CROWPANEL_TOUCH_PIN_CS GPIO_NUM_12 #define CROWPANEL_TOUCH_PIN_CS GPIO_NUM_12
@ -7,3 +9,5 @@
#define CROWPANEL_LCD_HORIZONTAL_RESOLUTION 320 #define CROWPANEL_LCD_HORIZONTAL_RESOLUTION 320
#define CROWPANEL_LCD_VERTICAL_RESOLUTION 240 #define CROWPANEL_LCD_VERTICAL_RESOLUTION 240
#define CROWPANEL_LCD_SPI_TRANSFER_HEIGHT (CROWPANEL_LCD_VERTICAL_RESOLUTION / 10) #define CROWPANEL_LCD_SPI_TRANSFER_HEIGHT (CROWPANEL_LCD_VERTICAL_RESOLUTION / 10)
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -1,10 +1,8 @@
#include "CrowPanelSdCard.h" #include "SdCard.h"
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <esp_vfs_fat.h>
using tt::hal::sdcard::SpiSdCardDevice; using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() { std::shared_ptr<SdCardDevice> createSdCard() {

View File

@ -1,19 +1,26 @@
#include "hal/CrowPanelDisplay.h" #include "devices/Display.h"
#include "hal/CrowPanelSdCard.h" #include "devices/SdCard.h"
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
using namespace tt::hal; using namespace tt::hal;
bool initBoot() { static bool initBoot() {
// Note: I tried 100 Hz to 100 kHz and couldn't get the flickering to stop
return driver::pwmbacklight::init(GPIO_NUM_2); return driver::pwmbacklight::init(GPIO_NUM_2);
} }
static DeviceVector createDevices() {
return {
createDisplay(),
createSdCard(),
};
}
extern const Configuration crowpanel_basic_50 = { extern const Configuration crowpanel_basic_50 = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.i2c = { .i2c = {
// There is only 1 (internal for touch, and also serves as "I2C-OUT" port) // There is only 1 (internal for touch, and also serves as "I2C-OUT" port)
// Note: You could repurpose 1 or more UART interfaces as I2C interfaces // Note: You could repurpose 1 or more UART interfaces as I2C interfaces

View File

@ -1,4 +1,4 @@
#include "CrowPanelDisplay.h" #include "Display.h"
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>

View File

@ -1,4 +1,4 @@
#include "WaveshareSdCard.h" #include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>

View File

@ -0,0 +1,7 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();

View File

@ -1,22 +1,21 @@
#include "Tactility/lvgl/LvglSync.h" #include "Tactility/lvgl/LvglSync.h"
#include "hal/TpagerDisplay.h" #include "devices/Display.h"
#include "hal/TpagerEncoder.h" #include "devices/SdCard.h"
#include "hal/TpagerDisplayConstants.h" #include "devices/TpagerEncoder.h"
#include "hal/TpagerKeyboard.h" #include "devices/TpagerKeyboard.h"
#include "hal/TpagerPower.h" #include "devices/TpagerPower.h"
#include "hal/TpagerSdCard.h"
#include <Bq25896.h> #include <Bq25896.h>
#include <Drv2605.h> #include <Drv2605.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
#define TPAGER_SPI_TRANSFER_SIZE_LIMIT (TPAGER_LCD_HORIZONTAL_RESOLUTION * TPAGER_LCD_SPI_TRANSFER_HEIGHT * (LV_COLOR_DEPTH / 8)) #define TPAGER_SPI_TRANSFER_SIZE_LIMIT (480 * 222 * (LV_COLOR_DEPTH / 8))
bool tpagerInit(); bool tpagerInit();
using namespace tt::hal; using namespace tt::hal;
DeviceVector createDevices() { static DeviceVector createDevices() {
auto bq27220 = std::make_shared<Bq27220>(I2C_NUM_0); auto bq27220 = std::make_shared<Bq27220>(I2C_NUM_0);
auto power = std::make_shared<TpagerPower>(bq27220); auto power = std::make_shared<TpagerPower>(bq27220);

View File

@ -1,10 +1,14 @@
#include "TpagerDisplay.h" #include "Display.h"
#include "TpagerDisplayConstants.h"
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <St7796Display.h> #include <St7796Display.h>
#include <driver/spi_master.h> #define TPAGER_LCD_SPI_HOST SPI2_HOST
#define TPAGER_LCD_PIN_CS GPIO_NUM_38
#define TPAGER_LCD_PIN_DC GPIO_NUM_37 // RS
#define TPAGER_LCD_HORIZONTAL_RESOLUTION 222
#define TPAGER_LCD_VERTICAL_RESOLUTION 480
#define TPAGER_LCD_SPI_TRANSFER_HEIGHT (TPAGER_LCD_VERTICAL_RESOLUTION / 10)
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() { std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
auto configuration = std::make_unique<St7796Display::Configuration>( auto configuration = std::make_unique<St7796Display::Configuration>(

View File

@ -1,4 +1,4 @@
#include "TpagerSdCard.h" #include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>

View File

@ -111,7 +111,7 @@ void TpagerEncoder::initEncoder() {
} }
} }
int TpagerEncoder::getEncoderPulses() { int TpagerEncoder::getEncoderPulses() const {
int pulses = 0; int pulses = 0;
pcnt_unit_get_count(encPcntUnit, &pulses); pcnt_unit_get_count(encPcntUnit, &pulses);
return pulses; return pulses;

View File

@ -15,7 +15,7 @@ class TpagerEncoder final : public tt::hal::encoder::EncoderDevice {
public: public:
TpagerEncoder() {} TpagerEncoder() {}
~TpagerEncoder() {} ~TpagerEncoder() override {}
std::string getName() const override { return "T-Lora Pager Encoder"; } std::string getName() const override { return "T-Lora Pager Encoder"; }
std::string getDescription() const override { return "The encoder wheel next to the display"; } std::string getDescription() const override { return "The encoder wheel next to the display"; }
@ -23,7 +23,7 @@ public:
bool startLvgl(lv_display_t* display) override; bool startLvgl(lv_display_t* display) override;
bool stopLvgl() override; bool stopLvgl() override;
int getEncoderPulses(); int getEncoderPulses() const;
lv_indev_t* _Nullable getLvglIndev() override { return encHandle; } lv_indev_t* _Nullable getLvglIndev() override { return encHandle; }
}; };

View File

@ -1,5 +0,0 @@
#pragma once
#include <Tactility/hal/display/DisplayDevice.h>
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -1,8 +0,0 @@
#pragma once
#define TPAGER_LCD_SPI_HOST SPI2_HOST
#define TPAGER_LCD_PIN_CS GPIO_NUM_38
#define TPAGER_LCD_PIN_DC GPIO_NUM_37 // RS
#define TPAGER_LCD_HORIZONTAL_RESOLUTION 222
#define TPAGER_LCD_VERTICAL_RESOLUTION 480
#define TPAGER_LCD_SPI_TRANSFER_HEIGHT (TPAGER_LCD_VERTICAL_RESOLUTION / 10)

View File

@ -7,7 +7,7 @@
#include <driver/i2c.h> #include <driver/i2c.h>
#include <driver/spi_master.h> #include <driver/spi_master.h>
#define TAG "core2" constexpr auto* TAG = "Core2";
axp192_t axpDevice; axp192_t axpDevice;

View File

@ -1,8 +1,8 @@
#include "M5stackCore2.h" #include "M5stackCore2.h"
#include "InitBoot.h" #include "InitBoot.h"
#include "hal/Core2Display.h" #include "devices/Display.h"
#include "hal/Core2Power.h" #include "devices/Core2Power.h"
#include "hal/Core2SdCard.h" #include "devices/SdCard.h"
#include <lvgl.h> #include <lvgl.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
@ -11,16 +11,22 @@
using namespace tt::hal; using namespace tt::hal;
extern const tt::hal::Configuration m5stack_core2 = { static DeviceVector createDevices() {
return {
createPower(),
createSdCard(),
createDisplay()
};
}
extern const Configuration m5stack_core2 = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.power = createPower,
.i2c = { .i2c = {
tt::hal::i2c::Configuration { i2c::Configuration {
.name = "Internal", .name = "Internal",
.port = I2C_NUM_0, .port = I2C_NUM_0,
.initMode = tt::hal::i2c::InitMode::ByTactility, .initMode = i2c::InitMode::ByTactility,
.isMutable = false, .isMutable = false,
.config = (i2c_config_t) { .config = (i2c_config_t) {
.mode = I2C_MODE_MASTER, .mode = I2C_MODE_MASTER,
@ -34,10 +40,10 @@ extern const tt::hal::Configuration m5stack_core2 = {
.clk_flags = 0 .clk_flags = 0
} }
}, },
tt::hal::i2c::Configuration { i2c::Configuration {
.name = "External", // (Grove) .name = "External", // (Grove)
.port = I2C_NUM_1, .port = I2C_NUM_1,
.initMode = tt::hal::i2c::InitMode::ByTactility, .initMode = i2c::InitMode::ByTactility,
.isMutable = true, .isMutable = true,
.config = (i2c_config_t) { .config = (i2c_config_t) {
.mode = I2C_MODE_MASTER, .mode = I2C_MODE_MASTER,
@ -53,7 +59,7 @@ extern const tt::hal::Configuration m5stack_core2 = {
} }
}, },
.spi { .spi {
tt::hal::spi::Configuration { spi::Configuration {
.device = SPI2_HOST, .device = SPI2_HOST,
.dma = SPI_DMA_CH_AUTO, .dma = SPI_DMA_CH_AUTO,
.config = { .config = {
@ -72,7 +78,7 @@ extern const tt::hal::Configuration m5stack_core2 = {
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0 .intr_flags = 0
}, },
.initMode = tt::hal::spi::InitMode::ByTactility, .initMode = spi::InitMode::ByTactility,
.isMutable = false, .isMutable = false,
.lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display .lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display
} }

View File

@ -16,8 +16,6 @@ bool Core2Power::supportsMetric(MetricType type) const {
default: default:
return false; return false;
} }
return false; // Safety guard for when new enum values are introduced
} }
bool Core2Power::getMetric(MetricType type, MetricData& data) { bool Core2Power::getMetric(MetricType type, MetricData& data) {

View File

@ -1,4 +1,4 @@
#include "Core2Display.h" #include "Display.h"
#include <Ft6x36Touch.h> #include <Ft6x36Touch.h>
#include <Ili934xDisplay.h> #include <Ili934xDisplay.h>

View File

@ -1,12 +1,10 @@
#include "Core2SdCard.h" #include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <esp_vfs_fat.h> constexpr auto CORE2_SDCARD_PIN_CS = GPIO_NUM_4;
constexpr auto CORE2_LCD_PIN_CS = GPIO_NUM_5;
#define CORE2_SDCARD_PIN_CS GPIO_NUM_4
#define CORE2_LCD_PIN_CS GPIO_NUM_5
using tt::hal::sdcard::SpiSdCardDevice; using tt::hal::sdcard::SpiSdCardDevice;

View File

@ -1,5 +1,7 @@
file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
idf_component_register( idf_component_register(
SRC_DIRS "Source" "Source/hal" SRCS ${SOURCE_FILES}
INCLUDE_DIRS "Source" INCLUDE_DIRS "Source"
REQUIRES Tactility esp_lvgl_port ILI934x FT5x06 AXP2101 AW9523 driver vfs fatfs REQUIRES Tactility esp_lvgl_port ILI934x FT5x06 AXP2101 AW9523 driver vfs fatfs
) )

View File

@ -1,4 +0,0 @@
#pragma once
#define AXP2101_ADDRESS 0x34
#define AW9523_ADDRESS 0x58

View File

@ -1,10 +1,9 @@
#include <Axp2101.h> #include "InitBoot.h"
#include <Aw9523.h>
#include <Tactility/Log.h> #include <Tactility/Log.h>
#include <Tactility/kernel/Kernel.h> #include <Tactility/kernel/Kernel.h>
#define TAG "cores3" constexpr auto* TAG = "CoreS3";
std::shared_ptr<Axp2101> axp2101; std::shared_ptr<Axp2101> axp2101;
std::shared_ptr<Aw9523> aw9523; std::shared_ptr<Aw9523> aw9523;
@ -148,9 +147,7 @@ bool initBoot() {
TT_LOG_I(TAG, "initBoot()"); TT_LOG_I(TAG, "initBoot()");
axp2101 = std::make_shared<Axp2101>(I2C_NUM_0); axp2101 = std::make_shared<Axp2101>(I2C_NUM_0);
tt::hal::registerDevice(axp2101);
aw9523 = std::make_shared<Aw9523>(I2C_NUM_0); aw9523 = std::make_shared<Aw9523>(I2C_NUM_0);
tt::hal::registerDevice(aw9523);
return initPowerControl() && initGpioExpander(); return initPowerControl() && initGpioExpander();
} }

View File

@ -1,3 +1,9 @@
#pragma once #pragma once
#include <Axp2101.h>
#include <Aw9523.h>
extern std::shared_ptr<Axp2101> axp2101;
extern std::shared_ptr<Aw9523> aw9523;
bool initBoot(); bool initBoot();

Some files were not shown because too many files have changed in this diff Show More