New board: CYD-E32R32P (#393)

This commit is contained in:
NellowTCS 2025-10-27 12:59:53 -06:00 committed by GitHub
parent 8115ca4fd9
commit 647678ff82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 297 additions and 2 deletions

View File

@ -17,6 +17,7 @@ jobs:
{ id: cyd-2432s028r, arch: esp32 },
{ id: cyd-2432s028rv3, arch: esp32 },
{ id: cyd-e32r28t, arch: esp32 },
{ id: cyd-e32r32p, arch: esp32 },
{ id: cyd-2432s032c, arch: esp32 },
{ id: cyd-jc2432w328c, arch: esp32 },
{ id: cyd-8048s043c, arch: esp32s3 },

View File

@ -0,0 +1,7 @@
file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
idf_component_register(
SRCS ${SOURCE_FILES}
INCLUDE_DIRS "Source"
REQUIRES Tactility esp_lvgl_port ST7789 XPT2046 PwmBacklight EstimatedPower driver vfs fatfs
)

View File

@ -0,0 +1,96 @@
#include "devices/SdCard.h"
#include "devices/Display.h"
#include "devices/Power.h"
#include <Tactility/hal/Configuration.h>
#include <Tactility/lvgl/LvglSync.h>
#include <PwmBacklight.h>
using namespace tt::hal;
static bool initBoot() {
return driver::pwmbacklight::init(DISPLAY_BACKLIGHT_PIN);
}
static tt::hal::DeviceVector createDevices() {
return {
createPower(),
createDisplay(),
createSdCard()
};
}
extern const Configuration hardwareConfiguration = {
.initBoot = initBoot,
.createDevices = createDevices,
.i2c = {
tt::hal::i2c::Configuration {
.name = "External",
.port = I2C_NUM_0,
.initMode = tt::hal::i2c::InitMode::ByTactility,
.isMutable = true,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_32,
.scl_io_num = GPIO_NUM_25,
.sda_pullup_en = false,
.scl_pullup_en = false,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
},
},
// Display
.spi = {
tt::hal::spi::Configuration {
.device = SPI2_HOST,
.dma = SPI_DMA_CH_AUTO,
.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 = DISPLAY_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
},
.initMode = tt::hal::spi::InitMode::ByTactility,
.isMutable = false,
.lock = tt::lvgl::getSyncLock()
},
// SD Card
tt::hal::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 = tt::hal::spi::InitMode::ByTactility,
.isMutable = false,
.lock = nullptr
},
}
};

View File

@ -0,0 +1,51 @@
#include "Display.h"
#include <Xpt2046Touch.h>
#include <St7789Display.h>
#include <PwmBacklight.h>
#include <Tactility/hal/touch/TouchDevice.h>
// Create the XPT2046 touch device (hardware/esp_lcd driver)
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto config = std::make_unique<Xpt2046Touch::Configuration>(
DISPLAY_SPI_HOST, // spi device / bus (SPI2_HOST)
TOUCH_CS_PIN, // touch CS (IO33)
(uint16_t)DISPLAY_HORIZONTAL_RESOLUTION, // x max
(uint16_t)DISPLAY_VERTICAL_RESOLUTION, // y max
false, // swapXy
true, // mirrorX
true // mirrorY
);
return std::make_shared<Xpt2046Touch>(std::move(config));
}
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
// Create the ST7789 panel configuration
St7789Display::Configuration panel_configuration = {
.horizontalResolution = DISPLAY_HORIZONTAL_RESOLUTION,
.verticalResolution = DISPLAY_VERTICAL_RESOLUTION,
.gapX = 0,
.gapY = 0,
.swapXY = false,
.mirrorX = false,
.mirrorY = false,
.invertColor = false,
.bufferSize = DISPLAY_DRAW_BUFFER_SIZE, // 0 -> default 1/10 screen
.touch = createTouch(),
.backlightDutyFunction = driver::pwmbacklight::setBacklightDuty,
.resetPin = GPIO_NUM_NC,
.rgbElementOrder = LCD_RGB_ELEMENT_ORDER_BGR // BGR for this display
};
// Create the SPI configuration (from EspLcdSpiDisplay base class)
auto spi_configuration = std::make_shared<EspLcdSpiDisplay::SpiConfiguration>(EspLcdSpiDisplay::SpiConfiguration {
.spiHostDevice = DISPLAY_SPI_HOST,
.csPin = DISPLAY_PIN_CS,
.dcPin = DISPLAY_PIN_DC,
.pixelClockFrequency = 40'000'000,
.transactionQueueDepth = 10
});
return std::make_shared<St7789Display>(panel_configuration, spi_configuration);
}

View File

@ -0,0 +1,27 @@
#pragma once
#include <Tactility/hal/display/DisplayDevice.h>
#include "driver/gpio.h"
#include "driver/spi_common.h"
#include <memory>
// Display (ST7789P3 on this board)
constexpr auto DISPLAY_SPI_HOST = SPI2_HOST;
constexpr auto DISPLAY_PIN_CS = GPIO_NUM_15;
constexpr auto DISPLAY_PIN_DC = GPIO_NUM_2;
constexpr auto DISPLAY_HORIZONTAL_RESOLUTION = 240;
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;
constexpr auto TOUCH_MOSI_PIN = GPIO_NUM_13;
constexpr auto TOUCH_SCK_PIN = GPIO_NUM_14;
constexpr auto TOUCH_CS_PIN = GPIO_NUM_33;
constexpr auto TOUCH_IRQ_PIN = GPIO_NUM_36;
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();

View File

@ -0,0 +1,12 @@
#include "Power.h"
#include <ChargeFromAdcVoltage.h>
#include <EstimatedPower.h>
std::shared_ptr<tt::hal::power::PowerDevice> createPower() {
ChargeFromAdcVoltage::Configuration configuration;
// 2.0 ratio, but +.11 added as display voltage sag compensation.
configuration.adcMultiplier = 2.11;
return std::make_shared<EstimatedPower>(configuration);
}

View File

@ -0,0 +1,6 @@
#pragma once
#include <memory>
#include <Tactility/hal/power/PowerDevice.h>
std::shared_ptr<tt::hal::power::PowerDevice> createPower();

View File

@ -0,0 +1,22 @@
#include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
using tt::hal::sdcard::SpiSdCardDevice;
using SdCardDevice = tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
SD_CS_PIN, // CS pin (IO5 on the module)
GPIO_NUM_NC, // MOSI override: leave NC to use SPI host pins
GPIO_NUM_NC, // MISO override: leave NC
GPIO_NUM_NC, // SCLK override: leave NC
SdCardDevice::MountBehaviour::AtBoot,
std::make_shared<tt::Mutex>(tt::Mutex::Type::Recursive),
std::vector<gpio_num_t>(),
SD_SPI_HOST // SPI host for SD card (SPI3_HOST)
);
return std::make_shared<SpiSdCardDevice>(
std::move(configuration)
);
}

View File

@ -0,0 +1,13 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
#include "driver/gpio.h"
#include "driver/spi_common.h"
using tt::hal::sdcard::SdCardDevice;
// SD card (microSD)
constexpr auto SD_CS_PIN = GPIO_NUM_5;
constexpr auto SD_SPI_HOST = SPI3_HOST;
std::shared_ptr<SdCardDevice> createSdCard();

View File

@ -29,6 +29,8 @@ function(INIT_TACTILITY_GLOBALS SDKCONFIG_FILE)
set(TACTILITY_BOARD_PROJECT CYD-2432S028RV3)
elseif (board_id STREQUAL "cyd-e32r28t")
set(TACTILITY_BOARD_PROJECT CYD-E32R28T)
elseif (board_id STREQUAL "cyd-e32r32p")
set(TACTILITY_BOARD_PROJECT CYD-E32R32P)
elseif (board_id STREQUAL "cyd-2432s032c")
set(TACTILITY_BOARD_PROJECT CYD-2432S032C)
elseif (board_id STREQUAL "cyd-4848s040c")

View File

@ -19,7 +19,7 @@ std::shared_ptr<EspLcdConfiguration> St7789Display::createEspLcdConfiguration(co
.resetPin = configuration.resetPin,
.lvglColorFormat = LV_COLOR_FORMAT_RGB565,
.lvglSwapBytes = false,
.rgbElementOrder = LCD_RGB_ELEMENT_ORDER_RGB,
.rgbElementOrder = configuration.rgbElementOrder,
.bitsPerPixel = 16,
});
}

View File

@ -26,6 +26,7 @@ public:
std::shared_ptr<tt::hal::touch::TouchDevice> touch;
std::function<void(uint8_t)> _Nullable backlightDutyFunction;
gpio_num_t resetPin;
lcd_rgb_element_order_t rgbElementOrder = LCD_RGB_ELEMENT_ORDER_RGB;
};
private:

View File

@ -18,7 +18,9 @@ menu "Tactility App"
config TT_BOARD_CYD_2432S028RV3
bool "CYD 2432S028RV3"
config TT_BOARD_CYD_E32R28T
bool "CYD E32R28T"
bool "CYD E32R28T"
config TT_BOARD_CYD_E32R32P
bool "CYD E32R32P"
config TT_BOARD_CYD_2432S032C
bool "CYD 2432S032C"
config TT_BOARD_CYD_8048S043C

View File

@ -0,0 +1,55 @@
# Software defaults
CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=3072
CONFIG_LV_FONT_MONTSERRAT_14=y
CONFIG_LV_FONT_MONTSERRAT_18=y
CONFIG_LV_USE_USER_DATA=y
CONFIG_LV_USE_FS_STDIO=y
CONFIG_LV_FS_STDIO_LETTER=65
CONFIG_LV_FS_STDIO_PATH=""
CONFIG_LV_FS_STDIO_CACHE_SIZE=4096
CONFIG_LV_USE_LODEPNG=y
CONFIG_LV_USE_BUILTIN_MALLOC=n
CONFIG_LV_USE_CLIB_MALLOC=y
CONFIG_LV_USE_MSGBOX=n
CONFIG_LV_USE_SPINNER=n
CONFIG_LV_USE_WIN=n
CONFIG_LV_USE_SNAPSHOT=y
CONFIG_FREERTOS_HZ=1000
CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=2
CONFIG_FREERTOS_SMP=n
CONFIG_FREERTOS_UNICORE=n
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=4096
CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FATFS_LFN_HEAP=y
CONFIG_FATFS_VOLUME_COUNT=3
# Hardware: Main
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-4mb.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions-4mb.csv"
CONFIG_TT_BOARD_CYD_E32R32P=y
CONFIG_TT_BOARD_NAME="CYD E32R32P"
CONFIG_TT_BOARD_ID="cyd-e32r32p"
CONFIG_IDF_TARGET="esp32"
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_FLASHMODE_QIO=y
# LVGL
CONFIG_LV_DISP_DEF_REFR_PERIOD=10
CONFIG_LV_DPI_DEF=130 # Adjusted for 2.8" 240x320 (~130 DPI)
CONFIG_LVGL_BUFFER_WIDTH=240
CONFIG_LVGL_BUFFER_HEIGHT=40
CONFIG_LVGL_COLOR_DEPTH=16
# Drivers
CONFIG_TOUCH_DRIVER_XPT2046=y
CONFIG_TOUCH_CALIBRATION=y
CONFIG_SD_CARD_ENABLE=y
# Fix for IRAM
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y
CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y
CONFIG_HEAP_PLACE_FUNCTION_INTO_FLASH=y
CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y