Add CYD-2432S028RV3 board support (#385)

This commit is contained in:
Giasone
2025-10-25 18:16:55 +02:00
committed by GitHub
parent c139300a58
commit 1450ca319d
12 changed files with 322 additions and 0 deletions
@@ -0,0 +1,54 @@
#include "Display.h"
#include "Xpt2046SoftSpi.h"
#include <St7789Display.h>
#include <PwmBacklight.h>
constexpr auto* TAG = "CYD";
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto configuration = std::make_unique<Xpt2046SoftSpi::Configuration>(
CYD_TOUCH_MOSI_PIN,
CYD_TOUCH_MISO_PIN,
CYD_TOUCH_SCK_PIN,
CYD_TOUCH_CS_PIN,
CYD2432S028RV3_LCD_HORIZONTAL_RESOLUTION, // 240
CYD2432S028RV3_LCD_VERTICAL_RESOLUTION, // 320
false, // swapXY
true, // mirrorX
false // mirrorY
);
// Allocate the driver
auto touch = std::make_shared<Xpt2046SoftSpi>(std::move(configuration));
// Start the driver
if (!touch->start()) {
ESP_LOGE(TAG, "Touch driver start failed");
return nullptr;
}
return touch;
}
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
auto touch = createTouch();
auto configuration = std::make_unique<St7789Display::Configuration>(
CYD2432S028RV3_LCD_SPI_HOST,
CYD2432S028RV3_LCD_PIN_CS,
CYD2432S028RV3_LCD_PIN_DC,
CYD2432S028RV3_LCD_HORIZONTAL_RESOLUTION,
CYD2432S028RV3_LCD_VERTICAL_RESOLUTION,
touch,
false, // swapXY
false, // mirrorX
false, // mirrorY
false, // invertColor
CYD2432S028RV3_LCD_DRAW_BUFFER_SIZE
);
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
auto display = std::make_shared<St7789Display>(std::move(configuration));
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
}
@@ -0,0 +1,22 @@
#pragma once
#include "Tactility/hal/display/DisplayDevice.h"
#include <memory>
// Display
#define CYD2432S028RV3_LCD_SPI_HOST SPI2_HOST
#define CYD2432S028RV3_LCD_HORIZONTAL_RESOLUTION 240
#define CYD2432S028RV3_LCD_VERTICAL_RESOLUTION 320
#define CYD2432S028RV3_LCD_DRAW_BUFFER_HEIGHT (CYD2432S028RV3_LCD_VERTICAL_RESOLUTION / 10)
#define CYD2432S028RV3_LCD_DRAW_BUFFER_SIZE (CYD2432S028RV3_LCD_HORIZONTAL_RESOLUTION * CYD2432S028RV3_LCD_DRAW_BUFFER_HEIGHT)
#define CYD2432S028RV3_LCD_PIN_CS GPIO_NUM_15
#define CYD2432S028RV3_LCD_PIN_DC GPIO_NUM_2
// Touch (Software SPI)
#define CYD_TOUCH_MISO_PIN GPIO_NUM_39
#define CYD_TOUCH_MOSI_PIN GPIO_NUM_32
#define CYD_TOUCH_SCK_PIN GPIO_NUM_25
#define CYD_TOUCH_CS_PIN GPIO_NUM_33
#define CYD_TOUCH_IRQ_PIN GPIO_NUM_36
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
@@ -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>(tt::Mutex::Type::Recursive),
std::vector<gpio_num_t>(),
SPI3_HOST
);
return std::make_shared<SpiSdCardDevice>(std::move(config));
}
@@ -0,0 +1,8 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();