Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- main
- cyd-2.4
tags:
- v*
pull_request:
Expand Down Expand Up @@ -34,6 +35,7 @@ jobs:
board: [
{ id: btt-panda-touch, arch: esp32s3 },
{ id: cyd-2432s024c, arch: esp32 },
{ id: cyd-2432s024r, arch: esp32 },
{ id: cyd-2432s028r, arch: esp32 },
{ id: cyd-2432s028rv3, arch: esp32 },
{ id: cyd-e32r28t, arch: esp32 },
Expand Down
7 changes: 7 additions & 0 deletions Devices/cyd-2432s024r/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
35 changes: 35 additions & 0 deletions Devices/cyd-2432s024r/Source/Configuration.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#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() {
// // Set the RGB LED Pins to output and turn them off
// ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_27, GPIO_MODE_OUTPUT)); // Red
// ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_12, GPIO_MODE_OUTPUT)); // Green
// ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_13, GPIO_MODE_OUTPUT)); // Blue

// // 0 on, 1 off
// ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_27, 1)); // Red
// ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_12, 1)); // Green
// ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_13, 1)); // Blue

return driver::pwmbacklight::init(LCD_PIN_BACKLIGHT);
}

static DeviceVector createDevices() {
return {
createDisplay(),
createSdCard()
};
}

extern const Configuration hardwareConfiguration = {
.initBoot = initBoot,
.createDevices = createDevices
};
46 changes: 46 additions & 0 deletions Devices/cyd-2432s024r/Source/devices/Display.cpp
Original file line number Diff line number Diff line change
@@ -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 changes: 28 additions & 0 deletions Devices/cyd-2432s024r/Source/devices/Display.h
Original file line number Diff line number Diff line change
@@ -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 changes: 23 additions & 0 deletions Devices/cyd-2432s024r/Source/devices/SdCard.cpp
Original file line number Diff line number Diff line change
@@ -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 changes: 8 additions & 0 deletions Devices/cyd-2432s024r/Source/devices/SdCard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#include "Tactility/hal/sdcard/SdCardDevice.h"

using tt::hal::sdcard::SdCardDevice;

std::shared_ptr<SdCardDevice> createSdCard();

23 changes: 23 additions & 0 deletions Devices/cyd-2432s024r/Source/module.cpp
Original file line number Diff line number Diff line change
@@ -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 changes: 39 additions & 0 deletions Devices/cyd-2432s024r/cyd,2432s024r.dts
Original file line number Diff line number Diff line change
@@ -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 changes: 19 additions & 0 deletions Devices/cyd-2432s024r/device.properties
Original file line number Diff line number Diff line change
@@ -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 changes: 3 additions & 0 deletions Devices/cyd-2432s024r/devicetree.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dependencies:
- Platforms/platform-esp32
dts: cyd,2432s024r.dts
Loading