diff --git a/.github/workflows/build-firmware.yml b/.github/workflows/build-firmware.yml index 1b823233..ab1b6484 100644 --- a/.github/workflows/build-firmware.yml +++ b/.github/workflows/build-firmware.yml @@ -15,6 +15,7 @@ jobs: strategy: matrix: board: [ + { id: btt-panda-touch, arch: esp32s3 }, { id: cyd-2432s024c, arch: esp32 }, { id: cyd-2432s028r, arch: esp32 }, { id: cyd-2432s028rv3, arch: esp32 }, @@ -44,11 +45,11 @@ jobs: { id: m5stack-stickc-plus, arch: esp32 }, { id: m5stack-stickc-plus2, arch: esp32 }, { id: unphone, arch: esp32s3 }, - { id: waveshare-s3-touch-lcd-43, arch: esp32s3 }, - { id: waveshare-s3-touch-lcd-147, arch: esp32s3 }, - { id: waveshare-s3-touch-lcd-128, arch: esp32s3 }, + { id: waveshare-esp32-s3-geek, arch: esp32s3 }, { id: waveshare-s3-lcd-13, arch: esp32s3 }, - { id: btt-panda-touch, arch: esp32s3 } + { id: waveshare-s3-touch-lcd-128, arch: esp32s3 }, + { id: waveshare-s3-touch-lcd-147, arch: esp32s3 }, + { id: waveshare-s3-touch-lcd-43, arch: esp32s3 } ] runs-on: ubuntu-latest steps: diff --git a/Boards/waveshare-esp32-s3-geek/CMakeLists.txt b/Boards/waveshare-esp32-s3-geek/CMakeLists.txt new file mode 100644 index 00000000..0ab2023a --- /dev/null +++ b/Boards/waveshare-esp32-s3-geek/CMakeLists.txt @@ -0,0 +1,7 @@ +file(GLOB_RECURSE SOURCE_FILES Source/*.c*) + +idf_component_register( + SRCS ${SOURCE_FILES} + INCLUDE_DIRS "Source" + REQUIRES Tactility ButtonControl ST7789 PwmBacklight driver +) \ No newline at end of file diff --git a/Boards/waveshare-esp32-s3-geek/Source/Configuration.cpp b/Boards/waveshare-esp32-s3-geek/Source/Configuration.cpp new file mode 100644 index 00000000..ce2934ac --- /dev/null +++ b/Boards/waveshare-esp32-s3-geek/Source/Configuration.cpp @@ -0,0 +1,99 @@ +#include "devices/Display.h" +#include "devices/SdCard.h" + +#include +#include +#include +#include + +using namespace tt::hal; + +static DeviceVector createDevices() { + return { + createDisplay(), + createSdCard(), + ButtonControl::createOneButtonControl(0) + }; +} + +static bool initBoot() { + return driver::pwmbacklight::init(LCD_PIN_BACKLIGHT); +} + +extern const Configuration hardwareConfiguration = { + .initBoot = initBoot, + .uiScale = UiScale::Smallest, + .createDevices = createDevices, + .i2c = { + //I2C Header + i2c::Configuration { + .name = "Main", + .port = I2C_NUM_0, + .initMode = i2c::InitMode::Disabled, + .isMutable = false, + .config = (i2c_config_t) { + .mode = I2C_MODE_MASTER, + .sda_io_num = GPIO_NUM_16, + .scl_io_num = GPIO_NUM_17, + .sda_pullup_en = true, + .scl_pullup_en = true, + .master = { + .clk_speed = 400000 + }, + .clk_flags = 0 + } + } + }, + .spi { + // Display + spi::Configuration { + .device = SPI2_HOST, + .dma = SPI_DMA_DISABLED, + .config = { + .mosi_io_num = GPIO_NUM_11, + .miso_io_num = GPIO_NUM_NC, + .sclk_io_num = GPIO_NUM_12, + .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 = LCD_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() // esp_lvgl_port owns the lock for the display + } + }, + .uart { + //UART Header + uart::Configuration { + .name = "UART0", + .port = UART_NUM_0, + .rxPin = GPIO_NUM_44, + .txPin = GPIO_NUM_43, + .rtsPin = GPIO_NUM_NC, + .ctsPin = GPIO_NUM_NC, + .rxBufferSize = 1024, + .txBufferSize = 1024, + .config = { + .baud_rate = 115200, + .data_bits = UART_DATA_8_BITS, + .parity = UART_PARITY_DISABLE, + .stop_bits = UART_STOP_BITS_1, + .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, + .rx_flow_ctrl_thresh = 0, + .source_clk = UART_SCLK_DEFAULT, + .flags = { + .allow_pd = 0, + .backup_before_sleep = 0, + } + } + } + } +}; \ No newline at end of file diff --git a/Boards/waveshare-esp32-s3-geek/Source/devices/Display.cpp b/Boards/waveshare-esp32-s3-geek/Source/devices/Display.cpp new file mode 100644 index 00000000..86329c4e --- /dev/null +++ b/Boards/waveshare-esp32-s3-geek/Source/devices/Display.cpp @@ -0,0 +1,32 @@ +#include "Display.h" + +#include +#include + +std::shared_ptr createDisplay() { + St7789Display::Configuration panel_configuration = { + .horizontalResolution = LCD_HORIZONTAL_RESOLUTION, + .verticalResolution = LCD_VERTICAL_RESOLUTION, + .gapX = 52, + .gapY = 40, + .swapXY = false, + .mirrorX = true, + .mirrorY = true, + .invertColor = true, + .bufferSize = LCD_BUFFER_SIZE, + .touch = nullptr, + .backlightDutyFunction = driver::pwmbacklight::setBacklightDuty, + .resetPin = LCD_PIN_RESET, + .lvglSwapBytes = false + }; + + auto spi_configuration = std::make_shared(St7789Display::SpiConfiguration { + .spiHostDevice = LCD_SPI_HOST, + .csPin = LCD_PIN_CS, + .dcPin = LCD_PIN_DC, + .pixelClockFrequency = 62'500'000, + .transactionQueueDepth = 10 + }); + + return std::make_shared(panel_configuration, spi_configuration); +} diff --git a/Boards/waveshare-esp32-s3-geek/Source/devices/Display.h b/Boards/waveshare-esp32-s3-geek/Source/devices/Display.h new file mode 100644 index 00000000..d7cd4f1d --- /dev/null +++ b/Boards/waveshare-esp32-s3-geek/Source/devices/Display.h @@ -0,0 +1,19 @@ +#pragma once + +#include +#include +#include +#include + +constexpr auto LCD_SPI_HOST = SPI2_HOST; +constexpr auto LCD_PIN_CS = GPIO_NUM_10; +constexpr auto LCD_PIN_DC = GPIO_NUM_8; +constexpr auto LCD_PIN_RESET = GPIO_NUM_9; +constexpr auto LCD_PIN_BACKLIGHT = GPIO_NUM_7; +constexpr auto LCD_HORIZONTAL_RESOLUTION = 135; +constexpr auto LCD_VERTICAL_RESOLUTION = 240; +constexpr auto LCD_BUFFER_HEIGHT = LCD_VERTICAL_RESOLUTION / 3; +constexpr auto LCD_BUFFER_SIZE = LCD_HORIZONTAL_RESOLUTION * LCD_BUFFER_HEIGHT; +constexpr auto LCD_SPI_TRANSFER_SIZE_LIMIT = LCD_BUFFER_SIZE * LV_COLOR_DEPTH / 8; + +std::shared_ptr createDisplay(); \ No newline at end of file diff --git a/Boards/waveshare-esp32-s3-geek/Source/devices/SdCard.cpp b/Boards/waveshare-esp32-s3-geek/Source/devices/SdCard.cpp new file mode 100644 index 00000000..542eec0b --- /dev/null +++ b/Boards/waveshare-esp32-s3-geek/Source/devices/SdCard.cpp @@ -0,0 +1,22 @@ +#include "SdCard.h" + +#include +#include + +using tt::hal::sdcard::SdmmcDevice; + +std::shared_ptr createSdCard() { + auto configuration = std::make_unique( + GPIO_NUM_36, //CLK + GPIO_NUM_35, //CMD + GPIO_NUM_37, //D0 + GPIO_NUM_33, //D1 + GPIO_NUM_38, //D2 + GPIO_NUM_34, //D3 + SdCardDevice::MountBehaviour::AtBoot + ); + + return std::make_shared( + std::move(configuration) + ); +} diff --git a/Boards/waveshare-esp32-s3-geek/Source/devices/SdCard.h b/Boards/waveshare-esp32-s3-geek/Source/devices/SdCard.h new file mode 100644 index 00000000..07d55649 --- /dev/null +++ b/Boards/waveshare-esp32-s3-geek/Source/devices/SdCard.h @@ -0,0 +1,7 @@ +#pragma once + +#include "Tactility/hal/sdcard/SdCardDevice.h" + +using tt::hal::sdcard::SdCardDevice; + +std::shared_ptr createSdCard(); \ No newline at end of file diff --git a/Boards/waveshare-esp32-s3-geek/device.properties b/Boards/waveshare-esp32-s3-geek/device.properties new file mode 100644 index 00000000..93204ece --- /dev/null +++ b/Boards/waveshare-esp32-s3-geek/device.properties @@ -0,0 +1,21 @@ +[general] +vendor=Waveshare +name=ESP32 S3 GEEK +incubating=true + +[hardware] +target=ESP32S3 +flashSize=16MB +spiRam=true +spiRamMode=QUAD +spiRamSpeed=120M +tinyUsb=true +esptoolFlashFreq=120M + +[display] +size=1.14" +shape=rectangle +dpi=143 + +[lvgl] +colorDepth=16 diff --git a/Firmware/Kconfig b/Firmware/Kconfig index 1e70324d..fa90ea66 100644 --- a/Firmware/Kconfig +++ b/Firmware/Kconfig @@ -11,6 +11,8 @@ menu "Tactility App" default TT_BOARD_CUSTOM config TT_BOARD_CUSTOM bool "Custom" + config TT_BOARD_BTT_PANDA_TOUCH + bool "BigTreeTech Panda Touch" config TT_BOARD_CYD_2432S024C bool "CYD 2432S024C" config TT_BOARD_CYD_2432S028R @@ -18,9 +20,9 @@ menu "Tactility App" config TT_BOARD_CYD_2432S028RV3 bool "CYD 2432S028RV3" config TT_BOARD_CYD_E32R28T - bool "CYD E32R28T" + bool "CYD E32R28T" config TT_BOARD_CYD_E32R32P - bool "CYD E32R32P" + bool "CYD E32R32P" config TT_BOARD_CYD_2432S032C bool "CYD 2432S032C" config TT_BOARD_CYD_8048S043C @@ -67,6 +69,8 @@ menu "Tactility App" bool "M5Stack StickC Plus2" config TT_BOARD_UNPHONE bool "unPhone" + config TT_BOARD_WAVESHARE_ESP32_S3_GEEK + bool "Waveshare ESP32 S3 GEEK" config TT_BOARD_WAVESHARE_S3_TOUCH_43 bool "Waveshare ESP32 S3 Touch LCD 4.3" config TT_BOARD_WAVESHARE_S3_TOUCH_LCD_147 @@ -75,8 +79,7 @@ menu "Tactility App" bool "Waveshare ESP32 S3 Touch LCD 1.28" config TT_BOARD_WAVESHARE_S3_LCD_13 bool "Waveshare ESP32 S3 LCD 1.3" - config TT_BOARD_BTT_PANDA_TOUCH - bool "BigTreeTech Panda Touch" + help Select a board/hardware configuration. Use TT_BOARD_CUSTOM if you will manually configure the board in your project.