diff --git a/.github/workflows/build-firmware.yml b/.github/workflows/build-firmware.yml index 89416bc0..30996362 100644 --- a/.github/workflows/build-firmware.yml +++ b/.github/workflows/build-firmware.yml @@ -27,6 +27,15 @@ jobs: with: board_id: cyd-2432s028r arch: esp32 + cyd-e32r28t: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: "Build" + uses: ./.github/actions/build-firmware + with: + board_id: cyd-e32r28t + arch: esp32 cyd-2432s032c: runs-on: ubuntu-latest steps: @@ -179,4 +188,4 @@ jobs: uses: ./.github/actions/build-firmware with: board_id: waveshare-s3-touch-43 - arch: esp32s3 \ No newline at end of file + arch: esp32s3 diff --git a/.gitignore b/.gitignore index 496b3a09..b24fc7a4 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ build-sim/ cmake-build-*/ CMakeCache.txt *.cbp +CMakeFiles release/ @@ -17,4 +18,5 @@ managed_components/ dependencies.lock .vscode/ +.gitpod.yml diff --git a/App/CMakeLists.txt b/App/CMakeLists.txt index 61c9603e..e432c879 100644 --- a/App/CMakeLists.txt +++ b/App/CMakeLists.txt @@ -25,4 +25,4 @@ else () add_definitions(-D_Nullable=) add_definitions(-D_Nonnull=) -endif () +endif () \ No newline at end of file diff --git a/App/Kconfig b/App/Kconfig index 5ba57fd8..5cc4ce73 100644 --- a/App/Kconfig +++ b/App/Kconfig @@ -15,6 +15,8 @@ menu "Tactility App" bool "CYD 2432S024C" config TT_BOARD_CYD_2432S028R bool "CYD 2432S028R" + config TT_BOARD_CYD_E32R28T + bool "CYD E32R28T" config TT_BOARD_CYD_2432S032C bool "CYD 2432S032C" config TT_BOARD_CYD_8048S043C diff --git a/App/Source/Boards.h b/App/Source/Boards.h index 60f2c400..c91850f9 100644 --- a/App/Source/Boards.h +++ b/App/Source/Boards.h @@ -17,6 +17,9 @@ #elif defined(CONFIG_TT_BOARD_CYD_2432S028R) #include "CYD2432S028R.h" #define TT_BOARD_HARDWARE &cyd_2432s028r_config +#elif defined(CONFIG_TT_BOARD_CYD_E32R28T) +#include "E32R28T.h" +#define TT_BOARD_HARDWARE &cyd_e32r28t_config #elif defined(CONFIG_TT_BOARD_CYD_2432S032C) #include "CYD2432S032C.h" #define TT_BOARD_HARDWARE &cyd_2432S032c_config diff --git a/App/Source/Main.cpp b/App/Source/Main.cpp index 574d3f75..dd7e7203 100644 --- a/App/Source/Main.cpp +++ b/App/Source/Main.cpp @@ -28,4 +28,4 @@ void app_main() { tt::run(config); } -} // extern +} // extern \ No newline at end of file diff --git a/Boards/CYD-2432S028R/Source/CYD2432S028R.h b/Boards/CYD-2432S028R/Source/CYD2432S028R.h index 2171fe3d..cce4ae22 100644 --- a/Boards/CYD-2432S028R/Source/CYD2432S028R.h +++ b/Boards/CYD-2432S028R/Source/CYD2432S028R.h @@ -2,5 +2,5 @@ #include -// Resitive touch version of the 2.8" yellow board +// Resistive touch version of the 2.8" yellow board extern const tt::hal::Configuration cyd_2432s028r_config; diff --git a/Boards/CYD-E32R28T/CMakeLists.txt b/Boards/CYD-E32R28T/CMakeLists.txt new file mode 100644 index 00000000..d691e455 --- /dev/null +++ b/Boards/CYD-E32R28T/CMakeLists.txt @@ -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 XPT2046SoftSPI PwmBacklight driver vfs fatfs +) diff --git a/Boards/CYD-E32R28T/Source/E32R28T.cpp b/Boards/CYD-E32R28T/Source/E32R28T.cpp new file mode 100644 index 00000000..b89b771b --- /dev/null +++ b/Boards/CYD-E32R28T/Source/E32R28T.cpp @@ -0,0 +1,70 @@ +#include "E32R28T.h" +#include "hal/YellowSdCard.h" +#include "hal/YellowDisplay.h" +#include "hal/YellowDisplayConstants.h" +#include +#include +#include + +#define CYD_SPI_TRANSFER_SIZE_LIMIT (240 * 320 / 4 * 2) + +bool initBoot() { + return driver::pwmbacklight::init(CYD_BACKLIGHT_PIN); +} + +const tt::hal::Configuration cyd_e32r28t_config = { + .initBoot = initBoot, + .createDisplay = createDisplay, + .sdcard = createYellowSdCard(), + .power = nullptr, + .i2c = {}, + .spi = { + tt::hal::spi::Configuration { + .device = SPI2_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 = tt::hal::spi::InitMode::ByTactility, + .isMutable = false, + .lock = tt::lvgl::getSyncLock() + }, + tt::hal::spi::Configuration { + .device = SPI3_HOST, + .dma = SPI_DMA_CH_AUTO, + .config = { + .mosi_io_num = GPIO_NUM_23, + .miso_io_num = GPIO_NUM_19, + .sclk_io_num = GPIO_NUM_18, + .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 = tt::hal::spi::InitMode::ByTactility, + .isMutable = false, + .lock = tt::lvgl::getSyncLock() + }, + + } +}; diff --git a/Boards/CYD-E32R28T/Source/E32R28T.h b/Boards/CYD-E32R28T/Source/E32R28T.h new file mode 100644 index 00000000..f3545923 --- /dev/null +++ b/Boards/CYD-E32R28T/Source/E32R28T.h @@ -0,0 +1,6 @@ +#pragma once + +#include + +// Resistive touch version of the waveshare 2.8" yellow board +extern const tt::hal::Configuration cyd_e32r28t_config; diff --git a/Boards/CYD-E32R28T/Source/hal/YellowDisplay.cpp b/Boards/CYD-E32R28T/Source/hal/YellowDisplay.cpp new file mode 100644 index 00000000..5fa4c182 --- /dev/null +++ b/Boards/CYD-E32R28T/Source/hal/YellowDisplay.cpp @@ -0,0 +1,58 @@ +#include "YellowDisplay.h" +#include "YellowDisplayConstants.h" +#include "Xpt2046SoftSpi.h" +#include +#include +#include +#include +#include + +static const char* TAG = "YellowDisplay"; + +// Global to hold reference (only needed if calling stop() later) +static std::unique_ptr touch; + +static std::shared_ptr createTouch() { + ESP_LOGI(TAG, "Creating bitbang SPI touch"); + + // Create bitbang config object + auto config = std::make_unique( + CYD_TOUCH_MOSI_PIN, + CYD_TOUCH_MISO_PIN, + CYD_TOUCH_SCK_PIN, + CYD_TOUCH_CS_PIN, + CYD_DISPLAY_HORIZONTAL_RESOLUTION, // 240 + CYD_DISPLAY_VERTICAL_RESOLUTION, // 320 + false, // swapXY + true, // mirrorX + false // mirrorY + ); + + // Allocate the driver + touch = std::make_unique(std::move(config)); + + // Start the driver + if (!touch->start()) { + ESP_LOGE(TAG, "Touch driver start failed"); + } + + return std::shared_ptr(touch.get(), [](tt::hal::touch::TouchDevice*) { + // No delete needed; `touch` is managed above + }); +} + +std::shared_ptr createDisplay() { + auto touch_device = createTouch(); + auto configuration = std::make_unique( + CYD_DISPLAY_SPI_HOST, + CYD_DISPLAY_PIN_CS, + CYD_DISPLAY_PIN_DC, + CYD_DISPLAY_HORIZONTAL_RESOLUTION, + CYD_DISPLAY_VERTICAL_RESOLUTION, + touch_device + ); + configuration->mirrorX = true; + configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty; + configuration->rgbElementOrder = LCD_RGB_ELEMENT_ORDER_BGR; + return std::make_shared(std::move(configuration)); +} diff --git a/Boards/CYD-E32R28T/Source/hal/YellowDisplay.h b/Boards/CYD-E32R28T/Source/hal/YellowDisplay.h new file mode 100644 index 00000000..036603c9 --- /dev/null +++ b/Boards/CYD-E32R28T/Source/hal/YellowDisplay.h @@ -0,0 +1,6 @@ +#pragma once + +#include "Tactility/hal/display/DisplayDevice.h" +#include + +std::shared_ptr createDisplay(); diff --git a/Boards/CYD-E32R28T/Source/hal/YellowDisplayConstants.h b/Boards/CYD-E32R28T/Source/hal/YellowDisplayConstants.h new file mode 100644 index 00000000..17638c47 --- /dev/null +++ b/Boards/CYD-E32R28T/Source/hal/YellowDisplayConstants.h @@ -0,0 +1,25 @@ +#pragma once + +// Display +#define CYD_DISPLAY_SPI_HOST SPI2_HOST +#define CYD_DISPLAY_PIN_CS GPIO_NUM_15 +#define CYD_DISPLAY_PIN_DC GPIO_NUM_2 +#define CYD_DISPLAY_HORIZONTAL_RESOLUTION 240 +#define CYD_DISPLAY_VERTICAL_RESOLUTION 320 +#define CYD_DISPLAY_DRAW_BUFFER_HEIGHT (CYD_DISPLAY_VERTICAL_RESOLUTION / 10) +#define CYD_DISPLAY_DRAW_BUFFER_SIZE (CYD_DISPLAY_HORIZONTAL_RESOLUTION * CYD_DISPLAY_DRAW_BUFFER_HEIGHT) + +// Touch (Software SPI) +#define CYD_TOUCH_MISO_PIN GPIO_NUM_39 +#define CYD_TOUCH_MOSI_PIN GPIO_NUM_32 +#define CYD_TOUCH_SCK_PIN GPIO_NUM_25 +#define CYD_TOUCH_CS_PIN GPIO_NUM_33 +#define CYD_TOUCH_IRQ_PIN GPIO_NUM_36 + +// SD Card +#define CYD_SDCARD_SPI_HOST SPI3_HOST +#define CYD_SDCARD_PIN_CS GPIO_NUM_5 + + +// Backlight +#define CYD_BACKLIGHT_PIN GPIO_NUM_21 diff --git a/Boards/CYD-E32R28T/Source/hal/YellowSdCard.cpp b/Boards/CYD-E32R28T/Source/hal/YellowSdCard.cpp new file mode 100644 index 00000000..25d90617 --- /dev/null +++ b/Boards/CYD-E32R28T/Source/hal/YellowSdCard.cpp @@ -0,0 +1,22 @@ +#include "YellowSdCard.h" +#include "YellowDisplayConstants.h" +#include + +using tt::hal::sdcard::SpiSdCardDevice; + +std::shared_ptr createYellowSdCard() { + auto* configuration = new SpiSdCardDevice::Config( + CYD_SDCARD_PIN_CS, + GPIO_NUM_NC, // No card detect pin specified + GPIO_NUM_NC, + GPIO_NUM_NC, + SdCardDevice::MountBehaviour::AtBoot, + std::make_shared(), + std::vector(), + CYD_SDCARD_SPI_HOST + ); + + return std::shared_ptr( + new SpiSdCardDevice(std::unique_ptr(configuration)) + ); +} diff --git a/Boards/CYD-E32R28T/Source/hal/YellowSdCard.h b/Boards/CYD-E32R28T/Source/hal/YellowSdCard.h new file mode 100644 index 00000000..0c862512 --- /dev/null +++ b/Boards/CYD-E32R28T/Source/hal/YellowSdCard.h @@ -0,0 +1,7 @@ +#pragma once + +#include "Tactility/hal/sdcard/SdCardDevice.h" + +using tt::hal::sdcard::SdCardDevice; + +std::shared_ptr createYellowSdCard(); diff --git a/Buildscripts/Flashing/flash.ps1 b/Buildscripts/Flashing/flash.ps1 old mode 100644 new mode 100755 diff --git a/Buildscripts/board.cmake b/Buildscripts/board.cmake index 491f8e09..344a554b 100644 --- a/Buildscripts/board.cmake +++ b/Buildscripts/board.cmake @@ -24,7 +24,9 @@ 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) + set(TACTILITY_BOARD_PROJECT CYD-2432S028R) + elseif (board_id STREQUAL "cyd-e32r28t") + set(TACTILITY_BOARD_PROJECT CYD-E32R28T) elseif (board_id STREQUAL "cyd-2432s032c") set(TACTILITY_BOARD_PROJECT CYD-2432S032C) elseif (board_id STREQUAL "cyd-4848s040c") diff --git a/Buildscripts/build.ps1 b/Buildscripts/build.ps1 old mode 100644 new mode 100755 diff --git a/Buildscripts/release.ps1 b/Buildscripts/release.ps1 old mode 100644 new mode 100755 diff --git a/Drivers/EspLcdCompat/Source/EspLcdDisplay.h b/Drivers/EspLcdCompat/Source/EspLcdDisplay.h index 7fecff1b..099c2138 100644 --- a/Drivers/EspLcdCompat/Source/EspLcdDisplay.h +++ b/Drivers/EspLcdCompat/Source/EspLcdDisplay.h @@ -8,7 +8,7 @@ #include #include -class EspLcdDisplay : tt::hal::display::DisplayDevice { +class EspLcdDisplay : public tt::hal::display::DisplayDevice { esp_lcd_panel_io_handle_t _Nullable ioHandle = nullptr; esp_lcd_panel_handle_t _Nullable panelHandle = nullptr; diff --git a/sdkconfig.board.cyd-e32r28t b/sdkconfig.board.cyd-e32r28t new file mode 100644 index 00000000..89601356 --- /dev/null +++ b/sdkconfig.board.cyd-e32r28t @@ -0,0 +1,56 @@ +# Software defaults +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 + +# Hardware: Main +CONFIG_TT_BOARD_CYD_E32R28T=y +CONFIG_TT_BOARD_NAME="CYD E32R28T" +CONFIG_TT_BOARD_ID="cyd-e32r28t" +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=130 # Adjusted for 2.8" 240x320 (~130 DPI) +CONFIG_LVGL_BUFFER_WIDTH=240 +CONFIG_LVGL_BUFFER_HEIGHT=40 +CONFIG_LVGL_COLOR_DEPTH=16 + +# Drivers +CONFIG_DISPLAY_DRIVER_ILI9341=y +CONFIG_TOUCH_DRIVER_XPT2046=y +CONFIG_TOUCH_CALIBRATION=y +CONFIG_SD_CARD_ENABLE=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