Skip to content
Open
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
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
{ id: cyd-e32r28t, arch: esp32 },
{ id: cyd-e32r32p, arch: esp32 },
{ id: cyd-2432s032c, arch: esp32 },
{ id: cyd-3248s035c, arch: esp32 },
{ id: cyd-8048s043c, arch: esp32s3 },
{ id: cyd-4848s040c, arch: esp32s3 },
{ id: elecrow-crowpanel-advance-28, arch: esp32s3 },
Expand Down
7 changes: 7 additions & 0 deletions Devices/cyd-3248s035c/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 ST7796 GT911 PwmBacklight driver vfs fatfs
)
34 changes: 34 additions & 0 deletions Devices/cyd-3248s035c/Source/Configuration.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "devices/Display.h"
#include "devices/SdCard.h"
#include <driver/gpio.h>

#include <PwmBacklight.h>
#include <Tactility/hal/Configuration.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_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_17, GPIO_MODE_OUTPUT)); //Blue

//0 on, 1 off... yep it's backwards.
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_4, 1)); //Red
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_16, 1)); //Green
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_17, 1)); //Blue

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

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

extern const Configuration hardwareConfiguration = {
.initBoot = initBoot,
.createDevices = createDevices
};
36 changes: 36 additions & 0 deletions Devices/cyd-3248s035c/Source/devices/Display.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "Display.h"

#include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <St7796Display.h>

static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
LCD_HORIZONTAL_RESOLUTION,
LCD_VERTICAL_RESOLUTION
);

return std::make_shared<Gt911Touch>(std::move(configuration));
}

std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
auto touch = createTouch();
auto configuration = std::make_unique<St7796Display::Configuration>(
LCD_SPI_HOST,
LCD_PIN_CS,
LCD_PIN_DC,
LCD_HORIZONTAL_RESOLUTION,
LCD_VERTICAL_RESOLUTION,
touch,
false,
true,
false,
false
);

configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;

auto display = std::make_shared<St7796Display>(std::move(configuration));
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
Comment on lines +34 to +35
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify inheritance and cast sites for this display type.
rg -nP --type=cpp --type=h 'class\s+St7796Display\s*:\s*public\s+tt::hal::display::DisplayDevice'
rg -nP --type=cpp --type=h 'reinterpret_pointer_cast<tt::hal::display::DisplayDevice>|static_pointer_cast<tt::hal::display::DisplayDevice>'

Repository: TactilityProject/Tactility

Length of output: 1887


🏁 Script executed:

# Find St7796Display class definition
rg -nP --type=cpp --type=h 'class\s+St7796Display'

Repository: TactilityProject/Tactility

Length of output: 160


🏁 Script executed:

# Find DisplayDevice class definition to understand the hierarchy
rg -nP --type=cpp --type=h 'class\s+DisplayDevice' | head -20

Repository: TactilityProject/Tactility

Length of output: 166


🏁 Script executed:

# Look for the actual file containing St7796Display and examine its definition
fd -type f -name '*.h' -o -name '*.cpp' | xargs grep -l 'St7796Display' | head -10

Repository: TactilityProject/Tactility

Length of output: 240


🏁 Script executed:

# Find EspLcdDisplay class definition and its base class
rg -nP --type=cpp --type=h 'class\s+EspLcdDisplay'

Repository: TactilityProject/Tactility

Length of output: 414


🏁 Script executed:

# Check the Display.cpp file for the complete context around line 35
cat -n Devices/cyd-3248s035c/Source/devices/Display.cpp | sed -n '1,45p'

Repository: TactilityProject/Tactility

Length of output: 1389


Use static_pointer_cast instead of reinterpret_pointer_cast for upcasting.

Line 35 performs an unsafe cast for what should be a normal polymorphic upcast. St7796Display inherits from EspLcdDisplay, which inherits from tt::hal::display::DisplayDevice. The reinterpret_pointer_cast treats the pointer bits directly without adjustment, which is unsafe and can cause undefined behavior. Use static_pointer_cast for compile-time known polymorphic upcasts.

🛠️ Safe cast fix
-    return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
+    return std::static_pointer_cast<tt::hal::display::DisplayDevice>(display);

}
22 changes: 22 additions & 0 deletions Devices/cyd-3248s035c/Source/devices/Display.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include "Display.h"

#include <Tactility/hal/display/DisplayDevice.h>
#include <memory>
Comment on lines +3 to +6
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify where DisplayDevice is declared and whether this include path exists.
fd -i 'DisplayDevice.h'
rg -n -C2 --iglob '*.{h,cpp}' 'Tactility/hal/display/DisplayDevice.h|class DisplayDevice|namespace tt::hal::display' Devices TactilityKernel Firmware Drivers

Repository: TactilityProject/Tactility

Length of output: 22049


Remove the self-include of Display.h.

Line 3 includes itself (#include "Display.h"), which is redundant and can mask include hygiene issues. The include path <Tactility/hal/display/DisplayDevice.h> is valid and widely used across the codebase (50+ device files use it successfully). No forward declaration is necessary; keep the existing include as-is and simply remove the self-include.

🧰 Tools
🪛 Clang (14.0.6)

[error] 5-5: 'Tactility/hal/display/DisplayDevice.h' file not found

(clang-diagnostic-error)

#include <driver/gpio.h>
#include <driver/spi_common.h>

// Display backlight (PWM)
constexpr auto LCD_PIN_BACKLIGHT = GPIO_NUM_27;

// 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_HORIZONTAL_RESOLUTION = 320;
constexpr auto LCD_VERTICAL_RESOLUTION = 480;
constexpr auto LCD_BUFFER_HEIGHT = LCD_VERTICAL_RESOLUTION / 10;
constexpr auto LCD_BUFFER_SIZE = LCD_HORIZONTAL_RESOLUTION * LCD_BUFFER_HEIGHT;

std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
31 changes: 31 additions & 0 deletions Devices/cyd-3248s035c/Source/devices/SdCard.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "SdCard.h"

#include <tactility/device.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>

constexpr auto SDCARD_SPI_HOST = SPI3_HOST;
constexpr auto SDCARD_PIN_CS = GPIO_NUM_5;

using tt::hal::sdcard::SpiSdCardDevice;

std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
SDCARD_PIN_CS,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
nullptr,
std::vector<gpio_num_t>(),
SDCARD_SPI_HOST
);

auto* spi_controller = device_find_by_name("spi1");
check(spi_controller, "spi1 not found");

return std::make_shared<SpiSdCardDevice>(
std::move(configuration),
spi_controller
);
}

8 changes: 8 additions & 0 deletions Devices/cyd-3248s035c/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-3248s035c/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_3248s035c_module = {
.name = "cyd-3248s035c",
.start = start,
.stop = stop,
.symbols = nullptr,
.internal = nullptr
};

}
58 changes: 58 additions & 0 deletions Devices/cyd-3248s035c/cyd,3248s035c.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/dts-v1/;

#include <tactility/bindings/root.h>
#include <tactility/bindings/esp32_gpio.h>
#include <tactility/bindings/esp32_i2c.h>
#include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_uart.h>

/ {
compatible = "root";
model = "CYD 3248S035C";

gpio0 {
compatible = "espressif,esp32-gpio";
gpio-count = <40>;
};

i2c_internal: i2c0 {
compatible = "espressif,esp32-i2c";
port = <I2C_NUM_0>;
clock-frequency = <400000>;
pin-sda = <&gpio0 33 GPIO_FLAG_NONE>;
pin-scl = <&gpio0 32 GPIO_FLAG_NONE>;
};

// CN1 header
i2c_external: i2c1 {
compatible = "espressif,esp32-i2c";
port = <I2C_NUM_1>;
clock-frequency = <400000>;
pin-sda = <&gpio0 21 GPIO_FLAG_NONE>;
pin-scl = <&gpio0 22 GPIO_FLAG_NONE>;
};

display_spi: spi0 {
compatible = "espressif,esp32-spi";
host = <SPI2_HOST>;
pin-mosi = <&gpio0 13 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>;
};

// CN1 header, JST SH 1.25, GND / IO22 / IO21 / 3.3V
uart1 {
compatible = "espressif,esp32-uart";
status = "disabled";
port = <UART_NUM_1>;
pin-tx = <&gpio0 22 GPIO_FLAG_NONE>;
pin-rx = <&gpio0 21 GPIO_FLAG_NONE>;
};
};
19 changes: 19 additions & 0 deletions Devices/cyd-3248s035c/device.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[general]
vendor=CYD
name=3248S035C

[apps]
launcherAppId=Launcher

[hardware]
target=ESP32
flashSize=4MB
spiRam=false

[display]
size=3.5"
shape=rectangle
dpi=165
[lvgl]
colorDepth=16
3 changes: 3 additions & 0 deletions Devices/cyd-3248s035c/devicetree.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dependencies:
- Platforms/platform-esp32
dts: cyd,3248s035c.dts
Comment on lines +1 to +3
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Normalize this YAML file to LF line endings.

yamllint reports invalid newline characters on this file. Please resave with \n (LF) to avoid CI lint failures.

🧰 Tools
🪛 YAMLlint (1.38.0)

[error] 1-1: wrong new line character: expected \n

(new-lines)

Loading