mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-04-18 09:25:06 +00:00
Implement device: CYD-2432S024R (#521)
This commit is contained in:
parent
10ba4f58e2
commit
be2cdc0b90
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
@ -34,6 +34,7 @@ jobs:
|
|||||||
board: [
|
board: [
|
||||||
{ id: btt-panda-touch, arch: esp32s3 },
|
{ id: btt-panda-touch, arch: esp32s3 },
|
||||||
{ id: cyd-2432s024c, arch: esp32 },
|
{ id: cyd-2432s024c, arch: esp32 },
|
||||||
|
{ id: cyd-2432s024r, arch: esp32 },
|
||||||
{ id: cyd-2432s028r, arch: esp32 },
|
{ id: cyd-2432s028r, arch: esp32 },
|
||||||
{ id: cyd-2432s028rv3, arch: esp32 },
|
{ id: cyd-2432s028rv3, arch: esp32 },
|
||||||
{ id: cyd-e32r28t, arch: esp32 },
|
{ id: cyd-e32r28t, arch: esp32 },
|
||||||
|
|||||||
7
Devices/cyd-2432s024r/CMakeLists.txt
Normal file
7
Devices/cyd-2432s024r/CMakeLists.txt
Normal 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 ILI934x XPT2046 PwmBacklight driver vfs fatfs
|
||||||
|
)
|
||||||
25
Devices/cyd-2432s024r/Source/Configuration.cpp
Normal file
25
Devices/cyd-2432s024r/Source/Configuration.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#include "devices/Display.h"
|
||||||
|
#include "devices/SdCard.h"
|
||||||
|
#include <driver/gpio.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(LCD_PIN_BACKLIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
static DeviceVector createDevices() {
|
||||||
|
return {
|
||||||
|
createDisplay(),
|
||||||
|
createSdCard()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
extern const Configuration hardwareConfiguration = {
|
||||||
|
.initBoot = initBoot,
|
||||||
|
.createDevices = createDevices
|
||||||
|
};
|
||||||
46
Devices/cyd-2432s024r/Source/devices/Display.cpp
Normal file
46
Devices/cyd-2432s024r/Source/devices/Display.cpp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#include "Display.h"
|
||||||
|
#include "Xpt2046Touch.h"
|
||||||
|
#include <Ili934xDisplay.h>
|
||||||
|
#include <PwmBacklight.h>
|
||||||
|
|
||||||
|
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch(esp_lcd_spi_bus_handle_t spiDevice) {
|
||||||
|
auto configuration = std::make_unique<Xpt2046Touch::Configuration>(
|
||||||
|
spiDevice,
|
||||||
|
TOUCH_CS_PIN,
|
||||||
|
LCD_HORIZONTAL_RESOLUTION,
|
||||||
|
LCD_VERTICAL_RESOLUTION,
|
||||||
|
true, // swapXY
|
||||||
|
false, // mirrorX
|
||||||
|
true // mirrorY
|
||||||
|
);
|
||||||
|
return std::make_shared<Xpt2046Touch>(std::move(configuration));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
|
||||||
|
auto spi_configuration = std::make_shared<Ili934xDisplay::SpiConfiguration>(Ili934xDisplay::SpiConfiguration {
|
||||||
|
.spiHostDevice = LCD_SPI_HOST,
|
||||||
|
.csPin = LCD_PIN_CS,
|
||||||
|
.dcPin = LCD_PIN_DC,
|
||||||
|
.pixelClockFrequency = 40'000'000,
|
||||||
|
.transactionQueueDepth = 10
|
||||||
|
});
|
||||||
|
|
||||||
|
Ili934xDisplay::Configuration panel_configuration = {
|
||||||
|
.horizontalResolution = LCD_HORIZONTAL_RESOLUTION,
|
||||||
|
.verticalResolution = LCD_VERTICAL_RESOLUTION,
|
||||||
|
.gapX = 0,
|
||||||
|
.gapY = 0,
|
||||||
|
.swapXY = true,
|
||||||
|
.mirrorX = true,
|
||||||
|
.mirrorY = true,
|
||||||
|
.invertColor = false,
|
||||||
|
.swapBytes = true,
|
||||||
|
.bufferSize = LCD_BUFFER_SIZE,
|
||||||
|
.touch = createTouch(spi_configuration->spiHostDevice),
|
||||||
|
.backlightDutyFunction = driver::pwmbacklight::setBacklightDuty,
|
||||||
|
.resetPin = LCD_PIN_RST,
|
||||||
|
.rgbElementOrder = LCD_RGB_ELEMENT_ORDER_RGB
|
||||||
|
};
|
||||||
|
|
||||||
|
return std::make_shared<Ili934xDisplay>(panel_configuration, spi_configuration, true);
|
||||||
|
}
|
||||||
28
Devices/cyd-2432s024r/Source/devices/Display.h
Normal file
28
Devices/cyd-2432s024r/Source/devices/Display.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Tactility/hal/display/DisplayDevice.h>
|
||||||
|
#include <driver/gpio.h>
|
||||||
|
#include <driver/spi_common.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
// Display
|
||||||
|
constexpr auto LCD_SPI_HOST = SPI2_HOST;
|
||||||
|
constexpr auto LCD_PIN_CS = GPIO_NUM_15;
|
||||||
|
constexpr auto LCD_PIN_DC = GPIO_NUM_2;
|
||||||
|
constexpr auto LCD_PIN_RST = GPIO_NUM_NC; // tied to ESP32 RST
|
||||||
|
constexpr auto LCD_PIN_CLK = GPIO_NUM_14;
|
||||||
|
constexpr auto LCD_PIN_MOSI = GPIO_NUM_13;
|
||||||
|
constexpr auto LCD_PIN_MISO = GPIO_NUM_12;
|
||||||
|
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;
|
||||||
|
|
||||||
|
// Backlight
|
||||||
|
constexpr auto LCD_PIN_BACKLIGHT = GPIO_NUM_27;
|
||||||
|
|
||||||
|
// Touch
|
||||||
|
constexpr auto TOUCH_CS_PIN = GPIO_NUM_33;
|
||||||
|
constexpr auto TOUCH_IRQ_PIN = GPIO_NUM_36;
|
||||||
|
|
||||||
|
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
|
||||||
23
Devices/cyd-2432s024r/Source/devices/SdCard.cpp
Normal file
23
Devices/cyd-2432s024r/Source/devices/SdCard.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include "SdCard.h"
|
||||||
|
#include <tactility/device.h>
|
||||||
|
#include <Tactility/hal/sdcard/SpiSdCardDevice.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,
|
||||||
|
nullptr,
|
||||||
|
std::vector<gpio_num_t>(),
|
||||||
|
SPI3_HOST
|
||||||
|
);
|
||||||
|
|
||||||
|
auto* spi_controller = device_find_by_name("spi1");
|
||||||
|
check(spi_controller, "spi1 not found");
|
||||||
|
|
||||||
|
return std::make_shared<SpiSdCardDevice>(std::move(config), spi_controller);
|
||||||
|
}
|
||||||
8
Devices/cyd-2432s024r/Source/devices/SdCard.h
Normal file
8
Devices/cyd-2432s024r/Source/devices/SdCard.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Tactility/hal/sdcard/SdCardDevice.h"
|
||||||
|
|
||||||
|
using tt::hal::sdcard::SdCardDevice;
|
||||||
|
|
||||||
|
std::shared_ptr<SdCardDevice> createSdCard();
|
||||||
|
|
||||||
23
Devices/cyd-2432s024r/Source/module.cpp
Normal file
23
Devices/cyd-2432s024r/Source/module.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include <tactility/module.h>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
static error_t start() {
|
||||||
|
// Empty for now
|
||||||
|
return ERROR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static error_t stop() {
|
||||||
|
// Empty for now
|
||||||
|
return ERROR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Module cyd_2432s024r_module = {
|
||||||
|
.name = "cyd-2432s024r",
|
||||||
|
.start = start,
|
||||||
|
.stop = stop,
|
||||||
|
.symbols = nullptr,
|
||||||
|
.internal = nullptr
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
39
Devices/cyd-2432s024r/cyd,2432s024r.dts
Normal file
39
Devices/cyd-2432s024r/cyd,2432s024r.dts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/dts-v1/;
|
||||||
|
|
||||||
|
#include <tactility/bindings/root.h>
|
||||||
|
#include <tactility/bindings/esp32_gpio.h>
|
||||||
|
#include <tactility/bindings/esp32_spi.h>
|
||||||
|
#include <tactility/bindings/esp32_uart.h>
|
||||||
|
|
||||||
|
/ {
|
||||||
|
compatible = "root";
|
||||||
|
model = "CYD 2432S024R";
|
||||||
|
|
||||||
|
gpio0 {
|
||||||
|
compatible = "espressif,esp32-gpio";
|
||||||
|
gpio-count = <40>;
|
||||||
|
};
|
||||||
|
|
||||||
|
display_spi: spi0 {
|
||||||
|
compatible = "espressif,esp32-spi";
|
||||||
|
host = <SPI2_HOST>;
|
||||||
|
pin-mosi = <&gpio0 13 GPIO_FLAG_NONE>;
|
||||||
|
pin-miso = <&gpio0 12 GPIO_FLAG_NONE>;
|
||||||
|
pin-sclk = <&gpio0 14 GPIO_FLAG_NONE>;
|
||||||
|
};
|
||||||
|
|
||||||
|
sdcard_spi: spi1 {
|
||||||
|
compatible = "espressif,esp32-spi";
|
||||||
|
host = <SPI3_HOST>;
|
||||||
|
pin-mosi = <&gpio0 23 GPIO_FLAG_NONE>;
|
||||||
|
pin-miso = <&gpio0 19 GPIO_FLAG_NONE>;
|
||||||
|
pin-sclk = <&gpio0 18 GPIO_FLAG_NONE>;
|
||||||
|
};
|
||||||
|
|
||||||
|
uart1 {
|
||||||
|
compatible = "espressif,esp32-uart";
|
||||||
|
port = <UART_NUM_1>;
|
||||||
|
pin-tx = <&gpio0 1 GPIO_FLAG_NONE>;
|
||||||
|
pin-rx = <&gpio0 3 GPIO_FLAG_NONE>;
|
||||||
|
};
|
||||||
|
};
|
||||||
19
Devices/cyd-2432s024r/device.properties
Normal file
19
Devices/cyd-2432s024r/device.properties
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[general]
|
||||||
|
vendor=CYD
|
||||||
|
name=2432S024R
|
||||||
|
|
||||||
|
[apps]
|
||||||
|
launcherAppId=Launcher
|
||||||
|
|
||||||
|
[hardware]
|
||||||
|
target=ESP32
|
||||||
|
flashSize=4MB
|
||||||
|
spiRam=false
|
||||||
|
|
||||||
|
[display]
|
||||||
|
size=2.4"
|
||||||
|
shape=rectangle
|
||||||
|
dpi=167
|
||||||
|
|
||||||
|
[lvgl]
|
||||||
|
colorDepth=16
|
||||||
3
Devices/cyd-2432s024r/devicetree.yaml
Normal file
3
Devices/cyd-2432s024r/devicetree.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
dependencies:
|
||||||
|
- Platforms/platform-esp32
|
||||||
|
dts: cyd,2432s024r.dts
|
||||||
Loading…
x
Reference in New Issue
Block a user