From 92bfd8a5cc4e8bb01cfcf5b761204895e75b5d60 Mon Sep 17 00:00:00 2001 From: yetanothercarbot <55005345+yetanothercarbot@users.noreply.github.com> Date: Thu, 25 Apr 2024 23:48:34 +1000 Subject: [PATCH] Initial support (bootloops) --- src/drv/tft/M5Stack.hpp | 2 +- src/drv/tft/tft_driver.h | 1 + src/drv/tft/tft_driver_lovyangfx.cpp | 40 ++++++++++++++++++++- user_setups/esp32/ttgo-t-watch.ini | 54 ++++++++++++++++++++++++++++ user_setups/esp32c3/2424S012.ini | 36 +++++++++++++++++++ 5 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 user_setups/esp32/ttgo-t-watch.ini create mode 100644 user_setups/esp32c3/2424S012.ini diff --git a/src/drv/tft/M5Stack.hpp b/src/drv/tft/M5Stack.hpp index 8822d724..0bdc9ec0 100644 --- a/src/drv/tft/M5Stack.hpp +++ b/src/drv/tft/M5Stack.hpp @@ -17,7 +17,7 @@ Contributors: /----------------------------------------------------------------------------*/ #pragma once -#if defined(ARDUINO) && defined(LGFX_USE_V1) +#if defined(ARDUINO) && defined(LGFX_USE_V1) && !defined(ESP32C3) #include "Arduino.h" #include "LovyanGFX.hpp" diff --git a/src/drv/tft/tft_driver.h b/src/drv/tft/tft_driver.h index c8bed996..b08cee35 100644 --- a/src/drv/tft/tft_driver.h +++ b/src/drv/tft/tft_driver.h @@ -32,6 +32,7 @@ enum lv_hasp_obj_type_t { TFT_PANEL_RM68140, TFT_PANEL_RGB, TFT_PANEL_EPD, + TFT_PANEL_GC9A01, TFT_PANEL_LAST, }; diff --git a/src/drv/tft/tft_driver_lovyangfx.cpp b/src/drv/tft/tft_driver_lovyangfx.cpp index 9d6d9a6a..62b5aac8 100644 --- a/src/drv/tft/tft_driver_lovyangfx.cpp +++ b/src/drv/tft/tft_driver_lovyangfx.cpp @@ -94,8 +94,12 @@ static lgfx::Bus_Parallel8* init_parallel_8_bus(Preferences* prefs, int8_t data_ cfg.pin_rd = prefs->getInt("rd", TFT_RD); cfg.pin_wr = prefs->getInt("wr", TFT_WR); cfg.pin_rs = prefs->getInt("rs", TFT_DC); +#ifndef ESP32C3 cfg.freq_write = prefs->getUInt("write_freq", SPI_FREQUENCY); -#if !defined(CONFIG_IDF_TARGET_ESP32S3) +#endif + + +#if !defined(CONFIG_IDF_TARGET_ESP32S3) && !defined(ESP32C3) uint8_t port = prefs->getUInt("i2s_port", 0); switch(port) { #if SOC_I2S_NUM > 1 @@ -328,6 +332,11 @@ lgfx::Panel_Device* LovyanGfx::_init_panel(lgfx::IBus* bus) LOG_VERBOSE(TAG_TFT, F("Panel_RGB")); break; } + case TFT_PANEL_GC9A01: { + panel = new lgfx::Panel_GC9A01(); + LOG_VERBOSE(TAG_TFT, F("Panel_GC9A01")); + break; + } default: { // Needs to be in curly braces LOG_FATAL(TAG_TFT, F(D_SERVICE_START_FAILED ": %s line %d"), __FILE__, __LINE__); } @@ -455,6 +464,31 @@ lgfx::ITouch* _init_touch(Preferences* preferences) } #endif +#if TOUCH_DRIVER == 0x816 + { + auto touch = new lgfx::Touch_CST816S(); + auto cfg = touch->config(); + + cfg.x_min = 0; + cfg.x_max = TFT_WIDTH - 1; + cfg.y_min = 0; + cfg.y_max = TFT_HEIGHT - 1; + cfg.pin_int = TOUCH_IRQ; + cfg.bus_shared = true; + cfg.offset_rotation = TOUCH_OFFSET_ROTATION; + + // I2C接続の場合 + cfg.i2c_port = I2C_TOUCH_PORT; + cfg.i2c_addr = I2C_TOUCH_ADDRESS; + cfg.pin_sda = TOUCH_SDA; + cfg.pin_scl = TOUCH_SCL; + cfg.freq = I2C_TOUCH_FREQUENCY; + + touch->config(cfg); + return touch; + } +#endif + #endif // HASP_USE_LGFX_TOUCH return nullptr; @@ -1261,6 +1295,8 @@ const char* LovyanGfx::get_tft_model() return "R61529"; #elif defined(RM68140_DRIVER) return "RM68140"; +#elif defined(GC9A01_DRIVER) + return "GC9A01"; #else return "Other"; #endif @@ -1302,6 +1338,8 @@ uint32_t LovyanGfx::get_tft_driver() return TFT_PANEL_EPD; #elif defined(RGB_DRIVER) return TFT_PANEL_RGB; +#elif defined(GC9A01_DRIVER) + return TFT_PANEL_GC9A01; #else return TFT_PANEL_UNKNOWN; #endif diff --git a/user_setups/esp32/ttgo-t-watch.ini b/user_setups/esp32/ttgo-t-watch.ini new file mode 100644 index 00000000..91b114ba --- /dev/null +++ b/user_setups/esp32/ttgo-t-watch.ini @@ -0,0 +1,54 @@ +[ttgo-t-watch] + +extends = arduino_esp32_v2 +board = esp32dev + +build_flags = + ${arduino_esp32_v2.build_flags} + ${esp32.ps_ram} + +;region -- TFT_eSPI build options ------------------------ + -D LGFX_USE_V1=1 + -D HASP_USE_LGFX_TOUCH=1 + -D ST7789_DRIVER=1 + -D TFT_HEIGHT=240 + -D TFT_WIDTH=240 + -D TFT_DC=27 + -D TFT_CS=5 + -D TFT_MOSI=19 + -D TFT_RST=-1 + -D TFT_SCLK=18 + -D TFT_BCKL=12 + -D SPI_FREQUENCY=40000000 + -D I2C_TOUCH_ADDRESS=0x38 + -D I2C_TOUCH_FREQUENCY=400000 + -D TOUCH_DRIVER=0x6336 + -D I2C_TOUCH_PORT=1 + -D TOUCH_IRQ=38 + -D TOUCH_RST=-1 + -D TOUCH_SDA=23 + -D TOUCH_SCL=32 +;endregion + +lib_deps = + ${arduino_esp32_v2.lib_deps} + ${lovyangfx.lib_deps} + ${ft6336.lib_deps} + +[env:ttgo-t-watch-2019] +extends = ttgo-t-watch, flash_16mb + +build_flags = + ${ttgo-t-watch.build_flags} + -D HASP_MODEL="TTgo T-Watch 2019" + -D INVERT_COLORS=1 + +[env:ttgo-t-watch-2020] +extends = ttgo-t-watch, flash_16mb + +build_flags = + ${ttgo-t-watch.build_flags} + -D HASP_MODEL="TTgo T-Watch 2020" + -D TFT_ROTATION=0 + ;-D TFT_ROTATION=2 + -D TOUCH_OFFSET_ROTATION=4 ; 1=swap xy, 2=invert x, 4=inverty \ No newline at end of file diff --git a/user_setups/esp32c3/2424S012.ini b/user_setups/esp32c3/2424S012.ini new file mode 100644 index 00000000..d05ac04c --- /dev/null +++ b/user_setups/esp32c3/2424S012.ini @@ -0,0 +1,36 @@ +[env:2424S012] +extends = arduino_esp32c3_v2, flash_4mb +; Close enough +board = seeed_xiao_esp32c3 + +build_flags = + -D HASP_MODEL="ESP32-2424S012" + ${arduino_esp32c3_v2.build_flags} + ${esp32c3.no_ps_ram} + +; Display configuration + -D ESP32C3=1 + -D LGFX_USE_V1=1 + -D HASP_USE_LGFX_TOUCH=1 + ;CST816S driver + -D TOUCH_DRIVER=0x816 + -D GC9A01_DRIVER=1 + -D TFT_WIDTH=240 + -D TFT_HEIGHT=240 + -D TOUCH_SDA=4 + -D TOUCH_SCL=5 + -D TOUCH_IRQ=0 + -D TOUCH_RST=1 + -D I2C_TOUCH_FREQUENCY=400000 + -D I2C_TOUCH_PORT=0 + -D I2C_TOUCH_ADDRESS=0x15 + -D TFT_SCLK=6 + -D TFT_MOSI=7 + -D TFT_DC=2 + -D TFT_CS=10 + -D TFT_BCKL=3 + +lib_deps = + ${arduino_esp32s3_v2.lib_deps} + ${lovyangfx.lib_deps} +; ${tft_espi.lib_deps} \ No newline at end of file