Skip to content
Merged
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
27 changes: 27 additions & 0 deletions .github/workflows/build-firmware.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,30 @@ jobs:
with:
board_id: unphone
arch: esp32s3
cyd-jc2432w328c:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Build"
uses: ./.github/actions/build-firmware
with:
board_id: cyd-jc2432w328c
arch: esp32
cyd-8048S043c:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Build"
uses: ./.github/actions/build-firmware
with:
board_id: cyd-8048S043c
arch: esp32s3
cyd-jc8048w550c:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Build"
uses: ./.github/actions/build-firmware
with:
board_id: cyd-jc8048w550c
arch: esp32s3
3 changes: 3 additions & 0 deletions App/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if (DEFINED ENV{ESP_IDF_VERSION})
ElecrowCrowpanelBasic28
ElecrowCrowpanelBasic35
M5stackCore2
CYD-JC2432W328C
)
endif()

Expand All @@ -19,6 +20,8 @@ if (DEFINED ENV{ESP_IDF_VERSION})
LilygoTdeck
M5stackCoreS3
UnPhone
CYD-8048S043C
CYD-JC8048W550C
)
endif()

Expand Down
6 changes: 6 additions & 0 deletions App/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ menu "Tactility App"
bool "M5Stack CoreS3"
config TT_BOARD_UNPHONE
bool "unPhone"
config TT_BOARD_CYD_JC2432W328C
bool "CYD JC2432W328C"
config TT_BOARD_CYD_8048S043C
bool "CYD 8048S043C"
config TT_BOARD_CYD_JC8048W550C
bool "CYD JC8048W550C"
help
Select a board/hardware configuration.
Use TT_BOARD_CUSTOM if you will manually configure the board in your project.
Expand Down
9 changes: 9 additions & 0 deletions App/Source/Boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@
#elif defined(CONFIG_TT_BOARD_UNPHONE)
#include "UnPhone.h"
#define TT_BOARD_HARDWARE &unPhone
#elif defined(CONFIG_TT_BOARD_CYD_JC2432W328C)
#include "JC2432W328C.h"
#define TT_BOARD_HARDWARE &cyd_jc2432w328c_config
#elif defined(CONFIG_TT_BOARD_CYD_8048S043C)
#include "CYD8048S043C.h"
#define TT_BOARD_HARDWARE &cyd_8048s043c_config
#elif defined(CONFIG_TT_BOARD_CYD_JC8048W550C)
#include "JC8048W550C.h"
#define TT_BOARD_HARDWARE &cyd_jc8048w550c_config
#else
#define TT_BOARD_HARDWARE NULL
#error Replace TT_BOARD_HARDWARE in main.c with your own. Or copy one of the ./sdkconfig.board.* files into ./sdkconfig.
Expand Down
7 changes: 7 additions & 0 deletions Boards/CYD-8048S043C/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 esp_lcd GT911 driver vfs fatfs
)
79 changes: 79 additions & 0 deletions Boards/CYD-8048S043C/Source/CYD8048S043C.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#include "CYD8048S043C.h"
#include "Tactility/lvgl/LvglSync.h"
#include "hal/YellowDisplay.h"
#include "hal/YellowDisplayConstants.h"
#include "hal/YellowSdCard.h"

#include <Tactility/hal/Configuration.h>

using namespace tt::hal;

const Configuration cyd_8048s043c_config = {
.createDisplay = createDisplay,
.sdcard = createYellowSdCard(),
.power = nullptr,
.i2c = {
//Touch
i2c::Configuration {
.name = "Internal",
.port = I2C_NUM_0,
.initMode = i2c::InitMode::ByTactility,
.isMutable = true,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_19,
.scl_io_num = GPIO_NUM_20,
.sda_pullup_en = true,
.scl_pullup_en = true,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
},
//P4 header, JST SH 1.0, GND / 3.3V / IO17 / IO18
i2c::Configuration {
.name = "External",
.port = I2C_NUM_1,
.initMode = i2c::InitMode::ByTactility,
.isMutable = true,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_17,
.scl_io_num = GPIO_NUM_18,
.sda_pullup_en = true,
.scl_pullup_en = true,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
}
},
.spi {
//SD Card
spi::Configuration {
.device = SPI2_HOST,
.dma = SPI_DMA_CH_AUTO,
.config = {
.mosi_io_num = GPIO_NUM_11,
.miso_io_num = GPIO_NUM_13,
.sclk_io_num = GPIO_NUM_12,
.quadwp_io_num = -1,
.quadhd_io_num = -1,
.data4_io_num = 0,
.data5_io_num = 0,
.data6_io_num = 0,
.data7_io_num = 0,
.data_io_default_level = false,
.max_transfer_sz = 8192,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
},
.initMode = spi::InitMode::ByTactility,
.isMutable = false,
.lock = nullptr
}
}
};
6 changes: 6 additions & 0 deletions Boards/CYD-8048S043C/Source/CYD8048S043C.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

#include <Tactility/hal/Configuration.h>

// Capacitive touch version of the 4.3" yellow board
extern const tt::hal::Configuration cyd_8048s043c_config;
220 changes: 220 additions & 0 deletions Boards/CYD-8048S043C/Source/hal/YellowDisplay.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
#include "YellowDisplay.h"
#include "YellowDisplayConstants.h"

#include <Gt911Touch.h>
#include <Tactility/Log.h>
#include <Tactility/TactilityCore.h>
#include <esp_lcd_panel_commands.h>

#include <driver/gpio.h>
#include <driver/ledc.h>
#include <esp_err.h>
#include <esp_lcd_panel_rgb.h>
#include <esp_lcd_panel_ops.h>
#include <esp_lvgl_port.h>

#define TAG "yellow_display"

static bool isBacklightInitialized = false;

static bool initBacklight() {
ledc_timer_config_t ledc_timer = {
.speed_mode = CYD8048S043_LCD_BACKLIGHT_LEDC_MODE,
.duty_resolution = CYD8048S043_LCD_BACKLIGHT_LEDC_DUTY_RES,
.timer_num = CYD8048S043_LCD_BACKLIGHT_LEDC_TIMER,
.freq_hz = CYD8048S043_LCD_BACKLIGHT_LEDC_FREQUENCY,
.clk_cfg = LEDC_AUTO_CLK,
.deconfigure = false
};

if (ledc_timer_config(&ledc_timer) != ESP_OK) {
TT_LOG_E(TAG, "Backlight led timer config failed");
return false;
}

return true;
}

static bool setBacklight(uint8_t duty) {
ledc_channel_config_t ledc_channel = {
.gpio_num = CYD8048S043_LCD_PIN_BACKLIGHT,
.speed_mode = CYD8048S043_LCD_BACKLIGHT_LEDC_MODE,
.channel = CYD8048S043_LCD_BACKLIGHT_LEDC_CHANNEL,
.intr_type = LEDC_INTR_DISABLE,
.timer_sel = CYD8048S043_LCD_BACKLIGHT_LEDC_TIMER,
.duty = duty,
.hpoint = 0,
.sleep_mode = LEDC_SLEEP_MODE_NO_ALIVE_NO_PD,
.flags = {
.output_invert = false
}
};

if (ledc_channel_config(&ledc_channel) != ESP_OK) {
TT_LOG_E(TAG, "Backlight init failed");
return false;
}

return true;
}

bool YellowDisplay::start() {
TT_LOG_I(TAG, "Starting");

const esp_lcd_rgb_panel_config_t panel_config = {
.clk_src = LCD_CLK_SRC_DEFAULT,
.timings = {
.pclk_hz = 16000000,
.h_res = CYD8048S043_LCD_HORIZONTAL_RESOLUTION,
.v_res = CYD8048S043_LCD_VERTICAL_RESOLUTION,

.hsync_pulse_width = 4,
.hsync_back_porch = 8,
.hsync_front_porch = 8,
.vsync_pulse_width = 4,
.vsync_back_porch = 8,
.vsync_front_porch = 8,
.flags = {
.hsync_idle_low = false,
.vsync_idle_low = false,
.de_idle_high = false,
.pclk_active_neg = true,
.pclk_idle_high = false
}
},
.data_width = 16,
.bits_per_pixel = 0,
.num_fbs = 2,
.bounce_buffer_size_px = CYD8048S043_LCD_HORIZONTAL_RESOLUTION * 10,
.sram_trans_align = 8,
.psram_trans_align = 64,

.hsync_gpio_num = CYD8048S043_LCD_PIN_HSYNC,
.vsync_gpio_num = CYD8048S043_LCD_PIN_VSYNC,
.de_gpio_num = CYD8048S043_LCD_PIN_DE,
.pclk_gpio_num = CYD8048S043_LCD_PIN_PCLK,
.disp_gpio_num = CYD8048S043_LCD_PIN_DISP_EN,
.data_gpio_nums = {
CYD8048S043_LCD_PIN_DATA0,
CYD8048S043_LCD_PIN_DATA1,
CYD8048S043_LCD_PIN_DATA2,
CYD8048S043_LCD_PIN_DATA3,
CYD8048S043_LCD_PIN_DATA4,
CYD8048S043_LCD_PIN_DATA5,
CYD8048S043_LCD_PIN_DATA6,
CYD8048S043_LCD_PIN_DATA7,
CYD8048S043_LCD_PIN_DATA8,
CYD8048S043_LCD_PIN_DATA9,
CYD8048S043_LCD_PIN_DATA10,
CYD8048S043_LCD_PIN_DATA11,
CYD8048S043_LCD_PIN_DATA12,
CYD8048S043_LCD_PIN_DATA13,
CYD8048S043_LCD_PIN_DATA14,
CYD8048S043_LCD_PIN_DATA15
},
.flags = {
.disp_active_low = false,
.refresh_on_demand = false,
.fb_in_psram = true,
.double_fb = true,
.no_fb = false,
.bb_invalidate_cache = false
}
};

if (esp_lcd_new_rgb_panel(&panel_config, &panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to create panel");
return false;
}

if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to reset panel");
return false;
}

if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to init panel");
return false;
}

const lvgl_port_display_cfg_t disp_cfg = {
.io_handle = ioHandle,
.panel_handle = panelHandle,
.control_handle = nullptr,
.buffer_size = CYD8048S043_LCD_DRAW_BUFFER_SIZE,
.double_buffer = true,
.trans_size = 0,
.hres = CYD8048S043_LCD_HORIZONTAL_RESOLUTION,
.vres = CYD8048S043_LCD_VERTICAL_RESOLUTION,
.monochrome = false,
.rotation = {
.swap_xy = false,
.mirror_x = false,
.mirror_y = false,
},
.color_format = LV_COLOR_FORMAT_RGB565,
.flags = {
.buff_dma = false,
.buff_spiram = true,
.sw_rotate = false,
.swap_bytes = false,
.full_refresh = false,
.direct_mode = false
}
};

const lvgl_port_display_rgb_cfg_t rgb_cfg = {
.flags = {
.bb_mode = true,
.avoid_tearing = false
}
};

displayHandle = lvgl_port_add_disp_rgb(&disp_cfg, &rgb_cfg);
TT_LOG_I(TAG, "Finished");
return displayHandle != nullptr;
}

bool YellowDisplay::stop() {
assert(displayHandle != nullptr);

lvgl_port_remove_disp(displayHandle);

if (esp_lcd_panel_del(panelHandle) != ESP_OK) {
return false;
}

if (esp_lcd_panel_io_del(ioHandle) != ESP_OK) {
return false;
}

displayHandle = nullptr;
return true;
}

std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable YellowDisplay::createTouch() {
// Note for future changes: Reset pin is 38 and interrupt pin is 18
// or INT = NC, schematic and other info floating around is kinda conflicting...
auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0,
800,
480
);

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

void YellowDisplay::setBacklightDuty(uint8_t backlightDuty) {
if (!isBacklightInitialized) {
tt_check(initBacklight());
isBacklightInitialized = true;
}

if (!setBacklight(backlightDuty)) {
TT_LOG_E(TAG, "Failed to configure display backlight");
}
}

std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
return std::make_shared<YellowDisplay>();
}
Loading
Loading