Implemented CYD-2432S028R board and update XPT2046 driver (#308)
- Added CONFIG_TT_BOARD_CYD_2432S028R in Kconfig. - Included support for CYD2432S028R in Boards.h and board.cmake. - Updated Xpt2046Touch driver to use configuration->spiDevice instead of SPI2_HOST when creating the SPI handle. - Note: SD card is not working on this board yet. This commit introduces full support for the CYD-2432S028R board and improves the touchscreen driver flexibility by allowing dynamic SPI device configuration. SD card functionality still needs to be implemented.
This commit is contained in:
parent
50007ea9ed
commit
5dfc6d70da
9
.github/workflows/build-firmware.yml
vendored
9
.github/workflows/build-firmware.yml
vendored
@ -18,6 +18,15 @@ jobs:
|
||||
with:
|
||||
board_id: cyd-2432s024c
|
||||
arch: esp32
|
||||
cyd-2432s028r:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: "Build"
|
||||
uses: ./.github/actions/build-firmware
|
||||
with:
|
||||
board_id: cyd-2432s028r
|
||||
arch: esp32
|
||||
cyd-2432s032c:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
@ -13,6 +13,8 @@ menu "Tactility App"
|
||||
bool "Custom"
|
||||
config TT_BOARD_CYD_2432S024C
|
||||
bool "CYD 2432S024C"
|
||||
config TT_BOARD_CYD_2432S028R
|
||||
bool "CYD 2432S028R"
|
||||
config TT_BOARD_CYD_2432S032C
|
||||
bool "CYD 2432S032C"
|
||||
config TT_BOARD_CYD_8048S043C
|
||||
|
||||
@ -14,6 +14,9 @@
|
||||
#elif defined(CONFIG_TT_BOARD_CYD_2432S024C)
|
||||
#include "CYD2432S024C.h"
|
||||
#define TT_BOARD_HARDWARE &cyd_2432s024c_config
|
||||
#elif defined(CONFIG_TT_BOARD_CYD_2432S028R)
|
||||
#include "CYD2432S028R.h"
|
||||
#define TT_BOARD_HARDWARE &cyd_2432s028r_config
|
||||
#elif defined(CONFIG_TT_BOARD_CYD_2432S032C)
|
||||
#include "CYD2432S032C.h"
|
||||
#define TT_BOARD_HARDWARE &cyd_2432S032c_config
|
||||
|
||||
7
Boards/CYD-2432S028R/CMakeLists.txt
Normal file
7
Boards/CYD-2432S028R/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
|
||||
)
|
||||
81
Boards/CYD-2432S028R/Source/CYD2432S028R.cpp
Normal file
81
Boards/CYD-2432S028R/Source/CYD2432S028R.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
#include "CYD2432S028R.h"
|
||||
#include "hal/YellowDisplay.h"
|
||||
#include "hal/YellowConstants.h"
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <PwmBacklight.h>
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
|
||||
using namespace tt::hal;
|
||||
|
||||
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(CYD2432S028R_LCD_PIN_BACKLIGHT);
|
||||
}
|
||||
|
||||
const Configuration cyd_2432s028r_config = {
|
||||
.initBoot = initBoot,
|
||||
.createDisplay = createDisplay,
|
||||
.sdcard = nullptr,
|
||||
.power = nullptr,
|
||||
.i2c = {},
|
||||
.spi {
|
||||
//Display
|
||||
spi::Configuration {
|
||||
.device = CYD2432S028R_LCD_SPI_HOST,
|
||||
.dma = SPI_DMA_CH_AUTO,
|
||||
.config = {
|
||||
.mosi_io_num = GPIO_NUM_13,
|
||||
.miso_io_num = GPIO_NUM_12,
|
||||
.sclk_io_num = GPIO_NUM_14,
|
||||
.quadwp_io_num = GPIO_NUM_NC,
|
||||
.quadhd_io_num = GPIO_NUM_NC,
|
||||
.data4_io_num = GPIO_NUM_NC,
|
||||
.data5_io_num = GPIO_NUM_NC,
|
||||
.data6_io_num = GPIO_NUM_NC,
|
||||
.data7_io_num = GPIO_NUM_NC,
|
||||
.data_io_default_level = false,
|
||||
.max_transfer_sz = CYD_SPI_TRANSFER_SIZE_LIMIT,
|
||||
.flags = 0,
|
||||
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
|
||||
.intr_flags = 0
|
||||
},
|
||||
.initMode = spi::InitMode::ByTactility,
|
||||
.isMutable = false,
|
||||
.lock = tt::lvgl::getSyncLock()
|
||||
},
|
||||
|
||||
// Touch
|
||||
spi::Configuration {
|
||||
.device = CYD2432S028R_TOUCH_SPI_HOST,
|
||||
.dma = SPI_DMA_CH_AUTO,
|
||||
.config = {
|
||||
.mosi_io_num = GPIO_NUM_32,
|
||||
.miso_io_num = GPIO_NUM_39,
|
||||
.sclk_io_num = GPIO_NUM_25,
|
||||
.quadwp_io_num = GPIO_NUM_NC,
|
||||
.quadhd_io_num = GPIO_NUM_NC,
|
||||
.data4_io_num = GPIO_NUM_NC,
|
||||
.data5_io_num = GPIO_NUM_NC,
|
||||
.data6_io_num = GPIO_NUM_NC,
|
||||
.data7_io_num = GPIO_NUM_NC,
|
||||
.data_io_default_level = false,
|
||||
.max_transfer_sz = 0,
|
||||
.flags = 0,
|
||||
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
|
||||
.intr_flags = 0
|
||||
},
|
||||
.initMode = tt::hal::spi::InitMode::ByTactility,
|
||||
.isMutable = false,
|
||||
.lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display
|
||||
},
|
||||
}
|
||||
};
|
||||
6
Boards/CYD-2432S028R/Source/CYD2432S028R.h
Normal file
6
Boards/CYD-2432S028R/Source/CYD2432S028R.h
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
|
||||
// Resitive touch version of the 2.8" yellow board
|
||||
extern const tt::hal::Configuration cyd_2432s028r_config;
|
||||
24
Boards/CYD-2432S028R/Source/hal/YellowConstants.h
Normal file
24
Boards/CYD-2432S028R/Source/hal/YellowConstants.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
// Display backlight (PWM)
|
||||
#define CYD2432S028R_LCD_PIN_BACKLIGHT GPIO_NUM_21
|
||||
|
||||
// Display
|
||||
#define CYD2432S028R_LCD_SPI_HOST SPI2_HOST
|
||||
#define CYD2432S028R_LCD_HORIZONTAL_RESOLUTION 240
|
||||
#define CYD2432S028R_LCD_VERTICAL_RESOLUTION 320
|
||||
#define CYD2432S028R_LCD_DRAW_BUFFER_HEIGHT (CYD2432S028R_LCD_VERTICAL_RESOLUTION / 10)
|
||||
#define CYD2432S028R_LCD_DRAW_BUFFER_SIZE (CYD2432S028R_LCD_HORIZONTAL_RESOLUTION * CYD2432S028R_LCD_DRAW_BUFFER_HEIGHT)
|
||||
#define CYD2432S028R_LCD_PIN_CS GPIO_NUM_15
|
||||
#define CYD2432S028R_LCD_PIN_DC GPIO_NUM_2
|
||||
|
||||
// Touch
|
||||
#define CYD2432S028R_TOUCH_SPI_HOST SPI3_HOST
|
||||
#define CYD2432S028R_TOUCH_PIN_CS GPIO_NUM_33
|
||||
|
||||
// SDCard
|
||||
#define SDCARD_SPI_HOST SPI3_HOST
|
||||
#define SDCARD_PIN_CS GPIO_NUM_5
|
||||
|
||||
// SPI Transfer
|
||||
#define CYD_SPI_TRANSFER_SIZE_LIMIT (CYD2432S028R_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8)
|
||||
42
Boards/CYD-2432S028R/Source/hal/YellowDisplay.cpp
Normal file
42
Boards/CYD-2432S028R/Source/hal/YellowDisplay.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
#include "YellowDisplay.h"
|
||||
#include "Xpt2046Touch.h"
|
||||
#include "YellowConstants.h"
|
||||
#include <Ili934xDisplay.h>
|
||||
#include <PwmBacklight.h>
|
||||
|
||||
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
|
||||
auto configuration = std::make_unique<Xpt2046Touch::Configuration>(
|
||||
CYD2432S028R_TOUCH_SPI_HOST,
|
||||
CYD2432S028R_TOUCH_PIN_CS,
|
||||
240,
|
||||
320,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
||||
return std::make_shared<Xpt2046Touch>(std::move(configuration));
|
||||
}
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
|
||||
auto touch = createTouch();
|
||||
|
||||
auto configuration = std::make_unique<Ili934xDisplay::Configuration>(
|
||||
CYD2432S028R_LCD_SPI_HOST,
|
||||
CYD2432S028R_LCD_PIN_CS,
|
||||
CYD2432S028R_LCD_PIN_DC,
|
||||
CYD2432S028R_LCD_HORIZONTAL_RESOLUTION,
|
||||
CYD2432S028R_LCD_VERTICAL_RESOLUTION,
|
||||
touch,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
CYD2432S028R_LCD_DRAW_BUFFER_SIZE
|
||||
);
|
||||
|
||||
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
|
||||
|
||||
auto display = std::make_shared<Ili934xDisplay>(std::move(configuration));
|
||||
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
|
||||
}
|
||||
6
Boards/CYD-2432S028R/Source/hal/YellowDisplay.h
Normal file
6
Boards/CYD-2432S028R/Source/hal/YellowDisplay.h
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/hal/display/DisplayDevice.h"
|
||||
#include <memory>
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
|
||||
26
Boards/CYD-2432S028R/Source/hal/YellowSdCard.cpp
Normal file
26
Boards/CYD-2432S028R/Source/hal/YellowSdCard.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "YellowSdCard.h"
|
||||
#include "YellowConstants.h"
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
|
||||
using tt::hal::sdcard::SpiSdCardDevice;
|
||||
|
||||
std::shared_ptr<SdCardDevice> createYellowSdCard() {
|
||||
auto* configuration = new SpiSdCardDevice::Config(
|
||||
SDCARD_PIN_CS,
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
GPIO_NUM_NC,
|
||||
SdCardDevice::MountBehaviour::AtBoot,
|
||||
std::make_shared<tt::Mutex>(),
|
||||
std::vector<gpio_num_t>(),
|
||||
SDCARD_SPI_HOST
|
||||
);
|
||||
|
||||
auto* sdcard = (SdCardDevice*) new SpiSdCardDevice(
|
||||
std::unique_ptr<SpiSdCardDevice::Config>(configuration)
|
||||
);
|
||||
|
||||
return std::shared_ptr<SdCardDevice>(sdcard);
|
||||
}
|
||||
|
||||
8
Boards/CYD-2432S028R/Source/hal/YellowSdCard.h
Normal file
8
Boards/CYD-2432S028R/Source/hal/YellowSdCard.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/hal/sdcard/SdCardDevice.h"
|
||||
|
||||
using tt::hal::sdcard::SdCardDevice;
|
||||
|
||||
std::shared_ptr<SdCardDevice> createYellowSdCard();
|
||||
|
||||
@ -23,6 +23,8 @@ function(INIT_TACTILITY_GLOBALS SDKCONFIG_FILE)
|
||||
|
||||
if (board_id STREQUAL "cyd-2432s024c")
|
||||
set(TACTILITY_BOARD_PROJECT CYD-2432S024C)
|
||||
elseif (board_id STREQUAL "cyd-2432s028r")
|
||||
set(TACTILITY_BOARD_PROJECT CYD-2432S028R)
|
||||
elseif (board_id STREQUAL "cyd-2432s032c")
|
||||
set(TACTILITY_BOARD_PROJECT CYD-2432S032C)
|
||||
elseif (board_id STREQUAL "cyd-4848s040c")
|
||||
|
||||
@ -11,7 +11,7 @@ Xpt2046Touch* Xpt2046Touch::instance = nullptr;
|
||||
|
||||
bool Xpt2046Touch::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
|
||||
const esp_lcd_panel_io_spi_config_t io_config = ESP_LCD_TOUCH_IO_SPI_XPT2046_CONFIG(configuration->spiPinCs);
|
||||
return esp_lcd_new_panel_io_spi(SPI2_HOST, &io_config, &outHandle) == ESP_OK;
|
||||
return esp_lcd_new_panel_io_spi(configuration->spiDevice, &io_config, &outHandle) == ESP_OK;
|
||||
}
|
||||
|
||||
bool Xpt2046Touch::createTouchHandle(esp_lcd_panel_io_handle_t ioHandle, const esp_lcd_touch_config_t& config, esp_lcd_touch_handle_t& panelHandle) {
|
||||
|
||||
52
sdkconfig.board.cyd-2432s028r
Normal file
52
sdkconfig.board.cyd-2432s028r
Normal file
@ -0,0 +1,52 @@
|
||||
# Software defaults
|
||||
# Increase stack size for WiFi (fixes crash after scan)
|
||||
CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=3072
|
||||
CONFIG_LV_FONT_MONTSERRAT_14=y
|
||||
CONFIG_LV_FONT_MONTSERRAT_18=y
|
||||
CONFIG_LV_USE_USER_DATA=y
|
||||
CONFIG_LV_USE_FS_STDIO=y
|
||||
CONFIG_LV_FS_STDIO_LETTER=65
|
||||
CONFIG_LV_FS_STDIO_PATH=""
|
||||
CONFIG_LV_FS_STDIO_CACHE_SIZE=4096
|
||||
CONFIG_LV_USE_LODEPNG=y
|
||||
CONFIG_LV_USE_BUILTIN_MALLOC=n
|
||||
CONFIG_LV_USE_CLIB_MALLOC=y
|
||||
CONFIG_LV_USE_MSGBOX=n
|
||||
CONFIG_LV_USE_SPINNER=n
|
||||
CONFIG_LV_USE_WIN=n
|
||||
CONFIG_LV_USE_SNAPSHOT=y
|
||||
CONFIG_FREERTOS_HZ=1000
|
||||
CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=2
|
||||
CONFIG_FREERTOS_SMP=n
|
||||
CONFIG_FREERTOS_UNICORE=n
|
||||
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=4096
|
||||
CONFIG_FREERTOS_USE_TRACE_FACILITY=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
|
||||
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
|
||||
CONFIG_FATFS_LFN_HEAP=y
|
||||
CONFIG_FATFS_VOLUME_COUNT=3
|
||||
CONFIG_FATFS_SECTOR_512=y
|
||||
CONFIG_WL_SECTOR_SIZE_512=y
|
||||
CONFIG_WL_SECTOR_SIZE=512
|
||||
CONFIG_WL_SECTOR_MODE_SAFE=y
|
||||
CONFIG_WL_SECTOR_MODE=1
|
||||
|
||||
# Hardware: Main
|
||||
CONFIG_TT_BOARD_NAME="CYD 2432S028R"
|
||||
CONFIG_TT_BOARD_ID="cyd-2432s028r"
|
||||
CONFIG_TT_BOARD_CYD_2432S028R=y
|
||||
CONFIG_IDF_TARGET="esp32"
|
||||
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
|
||||
CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||
CONFIG_FLASHMODE_QIO=y
|
||||
# LVGL
|
||||
CONFIG_LV_DISP_DEF_REFR_PERIOD=10
|
||||
CONFIG_LV_DPI_DEF=160
|
||||
CONFIG_LV_THEME_DEFAULT_DARK=y
|
||||
# Fix for IRAM
|
||||
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y
|
||||
CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y
|
||||
CONFIG_HEAP_PLACE_FUNCTION_INTO_FLASH=y
|
||||
CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y
|
||||
Loading…
x
Reference in New Issue
Block a user