From a0405952b2ae099091f8c269a32d0ffc875138d4 Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 31 May 2025 00:57:54 +0200 Subject: [PATCH 1/2] initial changes to get display working gen4_ESP32_50CT --- src/drv/tft/tft_defines.h | 2 +- src/drv/tft/tft_driver_lovyangfx.cpp | 19 ++-- user_setups/esp32s3/elecrow-esp32-s3-tft.ini | 112 +++++++++++++++++++ 3 files changed, 123 insertions(+), 10 deletions(-) create mode 100644 user_setups/esp32s3/elecrow-esp32-s3-tft.ini diff --git a/src/drv/tft/tft_defines.h b/src/drv/tft/tft_defines.h index 66904dfd..e6729421 100644 --- a/src/drv/tft/tft_defines.h +++ b/src/drv/tft/tft_defines.h @@ -123,7 +123,7 @@ #define TFT_OFFSET_ROTATION 0 #endif #ifndef TOUCH_OFFSET_ROTATION -#define TOUCH_OFFSET_ROTATION 0 +#define TOUCH_OFFSET_ROTATION 1 #endif #ifndef I2C_TOUCH_PORT #define I2C_TOUCH_PORT 0 diff --git a/src/drv/tft/tft_driver_lovyangfx.cpp b/src/drv/tft/tft_driver_lovyangfx.cpp index 2959a436..0c5d70d5 100644 --- a/src/drv/tft/tft_driver_lovyangfx.cpp +++ b/src/drv/tft/tft_driver_lovyangfx.cpp @@ -412,9 +412,9 @@ lgfx::ITouch* _init_touch(Preferences* preferences) auto cfg = touch->config(); cfg.x_min = 0; - cfg.x_max = TFT_WIDTH - 1; + cfg.x_max = TOUCH_WIDTH - 1; cfg.y_min = 0; - cfg.y_max = TFT_HEIGHT - 1; + cfg.y_max = TOUCH_HEIGHT - 1; cfg.pin_int = TOUCH_IRQ; cfg.bus_shared = true; cfg.offset_rotation = TOUCH_OFFSET_ROTATION; @@ -1043,7 +1043,7 @@ void LovyanGfx::init(int w, int h) #elif defined(ESP32_8040S070C) || defined(RGB_DRIVER) auto _panel_instance = new lgfx::Panel_RGB(); auto _bus_instance = new lgfx::Bus_RGB(); - auto _touch_instance = new lgfx::Touch_GT911(); + auto _touch_instance = new lgfx::Touch_FT5x06(); { auto cfg = _panel_instance->config(); @@ -1105,17 +1105,18 @@ void LovyanGfx::init(int w, int h) { auto cfg = _touch_instance->config(); cfg.x_min = 0; - cfg.x_max = TFT_WIDTH; + cfg.x_max = TOUCH_WIDTH - 1; cfg.y_min = 0; - cfg.y_max = TFT_HEIGHT; + cfg.y_max = TOUCH_HEIGHT - 1; cfg.pin_int = TOUCH_IRQ; - cfg.bus_shared = false; - cfg.offset_rotation = TOUCH_OFFSET_ROTATION; + cfg.pin_rst = TOUCH_RST; + cfg.bus_shared = true; + cfg.offset_rotation = 1; cfg.i2c_port = I2C_TOUCH_PORT; cfg.pin_sda = TOUCH_SDA; cfg.pin_scl = TOUCH_SCL; - cfg.freq = 400000; - cfg.i2c_addr = 0x14; // 0x5D , 0x14 + cfg.freq = I2C_TOUCH_FREQUENCY; + cfg.i2c_addr = I2C_TOUCH_ADDRESS; // 0x5D , 0x14 _touch_instance->config(cfg); _panel_instance->setTouch(_touch_instance); } diff --git a/user_setups/esp32s3/elecrow-esp32-s3-tft.ini b/user_setups/esp32s3/elecrow-esp32-s3-tft.ini new file mode 100644 index 00000000..92d58e4b --- /dev/null +++ b/user_setups/esp32s3/elecrow-esp32-s3-tft.ini @@ -0,0 +1,112 @@ +;***************************************************; +; Elecrow ESP32-S3 TFT 5.0" ; +; - Wizee-ESP32 WZ8048C050 ; +; - Custom esp32-s3 board ; +; - ILI6122/ILI5960 display driver ; +; - gt911 touch controller ; +;***************************************************; +; +; https://www.elecrow.com/esp32-display-5-inch-hmi-display-rgb-tft-lcd-touch-screen-support-lvgl.html +; + +[elecrow-esp32-s3-tft-50] +extends = arduino_esp32s3_v2 +board = esp32-s3-devkitc-1 +board_build.arduino.memory_type = qio_opi + +build_flags = + ${arduino_esp32s3_v2.build_flags} + ${esp32s3.ps_ram} + +;region -- ArduinoGFX build options ------------------------ + -D HASP_LV_USE_SW_ROTATE=0 + -D TFT_BCKL=2 ;#define GFX_BL 2 +;endregion + +lib_deps = + ${arduino_esp32s3_v2.lib_deps} + ;;;;;;;${arduinogfx.lib_deps} + ${lovyangfx.lib_deps} + Arduino_RPi_DPI_RGBPanel_mod + ${goodix.lib_deps} + +board_build.partitions = huge_app.csv + +[elecrow-tft-common-pins] +build_flags = + + + +; Bus Settings - LovyanGFX Library // ; Bus Settings - Ardunio_GFX Library + -D LGFX_USE_V1=1 + -D TFT_B0=8 ;8 /* B0 */, + -D TFT_B1=3 ;3 /* B1 */, + -D TFT_B2=46 ;46 /* B2 */, + -D TFT_B3=9 ;9 /* B3 */, + -D TFT_B4=1 ;1 /* B4 */, + + -D TFT_G0=5 ;5 /* G0 */, + -D TFT_G1=6 ;6 /* G1 */, + -D TFT_G2=7 ;7 /* G2 */, + -D TFT_G3=15 ;15 /* G3 */, + -D TFT_G4=16 ;16 /* G4 */, + -D TFT_G5=4 ;4 /* G5 */, + + -D TFT_R0=45 ;45 /* R0 */, + -D TFT_R1=48 ;48 /* R1 */, + -D TFT_R2=47 ;47 /* R2 */, + -D TFT_R3=21 ;21 /* R3 */, + -D TFT_R4=14 ;14 /* R4 */, + -D RGB_DRIVER=1 ; + + -D TFT_DE=40 ;40 /* DE */, + -D TFT_VSYNC=41 ;41 /* VSYNC */, + -D TFT_HSYNC=39 ;39 /* HSYNC */, + -D TFT_PCLK=42 ;42s /* PCLK */, + +[env:elecrow-s3-8048C050_8MB] +extends = elecrow-esp32-s3-tft-50, flash_8mb + +build_flags = + -D HASP_MODEL="Elecrow WZ8048C050" + -D HASP_LOG_LEVEL=LOG_LEVEL_VERBOSE + -D HASP_USE_CAPTIVE_PORTAL=0 + ; -D HASP_USE_CUSTOM=1 + ; -D MQTT_TOPIC_CUSTOM="SmartPICoop" + + + ${elecrow-esp32-s3-tft-50.build_flags} + ${elecrow-tft-common-pins.build_flags} + + ; Panel Settings ILI6122/LI5960 + -D TFT_WIDTH=800 ;800 /* width */, + -D TFT_HEIGHT=480 ;480 /* height */, + + -D TFT_HSYNC_POLARITY=0 ;0 /* hsync_polarity */, + -D TFT_HSYNC_FRONT_PORCH=8 ;8 /* hsync_front_porch */, + -D TFT_HSYNC_PULSE_WIDTH=4 ;???Pio_4 /* hsync_pulse_width */ ???Ard_1 /* hsync_pulse_width */, -1 + -D TFT_HSYNC_BACK_PORCH=8 ;???Pio_43 /* hsync_back_porch */,???Ard_32 /* hsync_back_porch */, -32 + -D TFT_VSYNC_POLARITY=0 ;0 /* vsync_polarity */, + -D TFT_VSYNC_FRONT_PORCH=8 ;8 /* vsync_front_porch */, + -D TFT_VSYNC_PULSE_WIDTH=4 ;???Pio_4 /* vsync_pulse_width */ ???Ard_1 /* vsync_pulse_width */, -1 + -D TFT_VSYNC_BACK_PORCH=8 ;Pio_12 /* vsync_back_porch */ ???Ard_ 8 /* vsync_back_porch */, + -D TFT_PCLK_ACTIVE_NEG=1 ;1 /* pclk_active_neg */, + -D TFT_PREFER_SPEED=16000000 ;16000000 /* prefer_speed */ + -D TFT_AUTO_FLUSH=1 ;true /* auto_flush */ + + ; Touch Settings FT5446 + -D HASP_USE_LGFX_TOUCH=1 + -D TOUCH_OFFSET_ROTATION=1 + -D TOUCH_WIDTH=480 + -D TOUCH_HEIGHT=800 + -D TOUCH_DRIVER=0x6336 + -D I2C_TOUCH_PORT=0 + -D TOUCH_SCL=18 + -D TOUCH_SDA=17 + -D TOUCH_IRQ=-1 + -D TOUCH_RST=-1 + -D I2C_TOUCH_ADDRESS=0x38 + -D I2C_TOUCH_FREQUENCY=400000 + +lib_deps = + ${elecrow-esp32-s3-tft-50.lib_deps} From 368e41aab57c2e403d655e8fbedc5904bb804f29 Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 31 May 2025 04:12:41 +0200 Subject: [PATCH 2/2] change to correct names and fix some driver config issues --- src/drv/tft/tft_defines.h | 2 +- src/drv/tft/tft_driver_lovyangfx.cpp | 12 ++++--- ...-tft.ini => 4dsystems-gen4_esp32_50ct.ini} | 34 +++++++++---------- 3 files changed, 26 insertions(+), 22 deletions(-) rename user_setups/esp32s3/{elecrow-esp32-s3-tft.ini => 4dsystems-gen4_esp32_50ct.ini} (74%) diff --git a/src/drv/tft/tft_defines.h b/src/drv/tft/tft_defines.h index e6729421..66904dfd 100644 --- a/src/drv/tft/tft_defines.h +++ b/src/drv/tft/tft_defines.h @@ -123,7 +123,7 @@ #define TFT_OFFSET_ROTATION 0 #endif #ifndef TOUCH_OFFSET_ROTATION -#define TOUCH_OFFSET_ROTATION 1 +#define TOUCH_OFFSET_ROTATION 0 #endif #ifndef I2C_TOUCH_PORT #define I2C_TOUCH_PORT 0 diff --git a/src/drv/tft/tft_driver_lovyangfx.cpp b/src/drv/tft/tft_driver_lovyangfx.cpp index 0c5d70d5..dd1f4db4 100644 --- a/src/drv/tft/tft_driver_lovyangfx.cpp +++ b/src/drv/tft/tft_driver_lovyangfx.cpp @@ -1043,7 +1043,11 @@ void LovyanGfx::init(int w, int h) #elif defined(ESP32_8040S070C) || defined(RGB_DRIVER) auto _panel_instance = new lgfx::Panel_RGB(); auto _bus_instance = new lgfx::Bus_RGB(); - auto _touch_instance = new lgfx::Touch_FT5x06(); + #if TOUCH_DRIVER == 0x911 + auto _touch_instance = new lgfx::Touch_GT911(); + #elif TOUCH_DRIVER == 0x6336 + auto _touch_instance = new lgfx::Touch_FT5x06(); + #endif { auto cfg = _panel_instance->config(); @@ -1105,13 +1109,13 @@ void LovyanGfx::init(int w, int h) { auto cfg = _touch_instance->config(); cfg.x_min = 0; - cfg.x_max = TOUCH_WIDTH - 1; + cfg.x_max = TOUCH_WIDTH; cfg.y_min = 0; - cfg.y_max = TOUCH_HEIGHT - 1; + cfg.y_max = TOUCH_HEIGHT; cfg.pin_int = TOUCH_IRQ; cfg.pin_rst = TOUCH_RST; cfg.bus_shared = true; - cfg.offset_rotation = 1; + cfg.offset_rotation = TOUCH_OFFSET_ROTATION; cfg.i2c_port = I2C_TOUCH_PORT; cfg.pin_sda = TOUCH_SDA; cfg.pin_scl = TOUCH_SCL; diff --git a/user_setups/esp32s3/elecrow-esp32-s3-tft.ini b/user_setups/esp32s3/4dsystems-gen4_esp32_50ct.ini similarity index 74% rename from user_setups/esp32s3/elecrow-esp32-s3-tft.ini rename to user_setups/esp32s3/4dsystems-gen4_esp32_50ct.ini index 92d58e4b..35765655 100644 --- a/user_setups/esp32s3/elecrow-esp32-s3-tft.ini +++ b/user_setups/esp32s3/4dsystems-gen4_esp32_50ct.ini @@ -1,17 +1,17 @@ ;***************************************************; -; Elecrow ESP32-S3 TFT 5.0" ; -; - Wizee-ESP32 WZ8048C050 ; -; - Custom esp32-s3 board ; +; 4D Systems GEN4-ESP32-S3 TFT 5.0" ; +; - 4D Systems Screen 4DLCD-50800480 https://uk.rs-online.com/web/p/lcd-colour-displays/2058704?searchId=afcc888a-a7c2-4b51-8eb6-bc5aacf64fa9&gb=s ; +; - Custom esp32-s3r8 board ; ; - ILI6122/ILI5960 display driver ; -; - gt911 touch controller ; +; - FT5446 touch controller ; ;***************************************************; ; -; https://www.elecrow.com/esp32-display-5-inch-hmi-display-rgb-tft-lcd-touch-screen-support-lvgl.html +; https://4dsystems.com.au/products/gen4-esp32-series/ ; -[elecrow-esp32-s3-tft-50] +[4dsystems-gen4_esp32_50] extends = arduino_esp32s3_v2 -board = esp32-s3-devkitc-1 +board = esp32-s3-devkitc-1 ; Correct board would be 4d_systems_esp32s3_gen4_r8n16 but only included from 3.x.x framework board_build.arduino.memory_type = qio_opi build_flags = @@ -32,7 +32,7 @@ lib_deps = board_build.partitions = huge_app.csv -[elecrow-tft-common-pins] +[4dsystems-tft-common-pins] build_flags = @@ -64,19 +64,19 @@ build_flags = -D TFT_HSYNC=39 ;39 /* HSYNC */, -D TFT_PCLK=42 ;42s /* PCLK */, -[env:elecrow-s3-8048C050_8MB] -extends = elecrow-esp32-s3-tft-50, flash_8mb +[env:4dsystems-gen4_esp32_50ct_16MB] +extends = 4dsystems-gen4_esp32_50, flash_16mb build_flags = - -D HASP_MODEL="Elecrow WZ8048C050" + -D HASP_MODEL="4D Systems gen4-ESP32-43CT" -D HASP_LOG_LEVEL=LOG_LEVEL_VERBOSE -D HASP_USE_CAPTIVE_PORTAL=0 ; -D HASP_USE_CUSTOM=1 ; -D MQTT_TOPIC_CUSTOM="SmartPICoop" - ${elecrow-esp32-s3-tft-50.build_flags} - ${elecrow-tft-common-pins.build_flags} + ${4dsystems-gen4_esp32_50.build_flags} + ${4dsystems-tft-common-pins.build_flags} ; Panel Settings ILI6122/LI5960 -D TFT_WIDTH=800 ;800 /* width */, @@ -84,11 +84,11 @@ build_flags = -D TFT_HSYNC_POLARITY=0 ;0 /* hsync_polarity */, -D TFT_HSYNC_FRONT_PORCH=8 ;8 /* hsync_front_porch */, - -D TFT_HSYNC_PULSE_WIDTH=4 ;???Pio_4 /* hsync_pulse_width */ ???Ard_1 /* hsync_pulse_width */, -1 - -D TFT_HSYNC_BACK_PORCH=8 ;???Pio_43 /* hsync_back_porch */,???Ard_32 /* hsync_back_porch */, -32 + -D TFT_HSYNC_PULSE_WIDTH=4 ;???Pio_4 /* hsync_pulse_width */ ???Ard_1 /* hsync_pulse_width */, + -D TFT_HSYNC_BACK_PORCH=8 ;???Pio_43 /* hsync_back_porch */,???Ard_32 /* hsync_back_porch */, -D TFT_VSYNC_POLARITY=0 ;0 /* vsync_polarity */, -D TFT_VSYNC_FRONT_PORCH=8 ;8 /* vsync_front_porch */, - -D TFT_VSYNC_PULSE_WIDTH=4 ;???Pio_4 /* vsync_pulse_width */ ???Ard_1 /* vsync_pulse_width */, -1 + -D TFT_VSYNC_PULSE_WIDTH=4 ;???Pio_4 /* vsync_pulse_width */ ???Ard_1 /* vsync_pulse_width */, -D TFT_VSYNC_BACK_PORCH=8 ;Pio_12 /* vsync_back_porch */ ???Ard_ 8 /* vsync_back_porch */, -D TFT_PCLK_ACTIVE_NEG=1 ;1 /* pclk_active_neg */, -D TFT_PREFER_SPEED=16000000 ;16000000 /* prefer_speed */ @@ -109,4 +109,4 @@ build_flags = -D I2C_TOUCH_FREQUENCY=400000 lib_deps = - ${elecrow-esp32-s3-tft-50.lib_deps} + ${4dsystems-gen4_esp32_50.lib_deps}