From 4de8f4953eb0b75e17800a707da0ad76f06b783f Mon Sep 17 00:00:00 2001 From: Alvaro Lobato Date: Fri, 22 Dec 2023 00:02:05 +0100 Subject: [PATCH 01/18] Fix mac build: - Change compiler version so it works with newer MacOS - Fix library paths - Exclude freetype which creates a build error --- tools/osx_build_extra.py | 3 ++- user_setups/darwin_sdl/darwin_sdl_64bits.ini | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/osx_build_extra.py b/tools/osx_build_extra.py index 3f445946..ae726458 100644 --- a/tools/osx_build_extra.py +++ b/tools/osx_build_extra.py @@ -1,6 +1,7 @@ Import("env") -env.Replace(CC="gcc-10", CXX="g++-10") +#env.Replace(CC="gcc-10", CXX="g++-10") +env.Replace(CC="gcc-12", CXX="g++-12") env.Replace(BUILD_SCRIPT="tools/osx_build_script.py") diff --git a/user_setups/darwin_sdl/darwin_sdl_64bits.ini b/user_setups/darwin_sdl/darwin_sdl_64bits.ini index 30819a31..a1e64062 100644 --- a/user_setups/darwin_sdl/darwin_sdl_64bits.ini +++ b/user_setups/darwin_sdl/darwin_sdl_64bits.ini @@ -58,8 +58,10 @@ build_flags = -lm -lpthread ; MacOS with Homebrew - -I/usr/local/include - -L/usr/local/lib + ;-I/usr/local/include + ;-L/usr/local/lib + -I/opt/homebrew/include + -L/opt/homebrew/lib -DTARGET_OS_MAC=1 lib_deps = @@ -77,6 +79,7 @@ lib_ignore = ArduinoLog lv_lib_qrcode ETHSPI + freetype build_src_filter = +<*> From e756b4b4e2877a974dcf4900139415da8ccaa326 Mon Sep 17 00:00:00 2001 From: Alvaro Lobato Date: Fri, 22 Dec 2023 00:02:05 +0100 Subject: [PATCH 02/18] Fix mac build: - Change compiler version so it works with newer MacOS - Fix library paths - Exclude freetype which creates a build error --- tools/osx_build_extra.py | 3 ++- user_setups/darwin_sdl/darwin_sdl_64bits.ini | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/osx_build_extra.py b/tools/osx_build_extra.py index 3f445946..ae726458 100644 --- a/tools/osx_build_extra.py +++ b/tools/osx_build_extra.py @@ -1,6 +1,7 @@ Import("env") -env.Replace(CC="gcc-10", CXX="g++-10") +#env.Replace(CC="gcc-10", CXX="g++-10") +env.Replace(CC="gcc-12", CXX="g++-12") env.Replace(BUILD_SCRIPT="tools/osx_build_script.py") diff --git a/user_setups/darwin_sdl/darwin_sdl_64bits.ini b/user_setups/darwin_sdl/darwin_sdl_64bits.ini index 30819a31..a1e64062 100644 --- a/user_setups/darwin_sdl/darwin_sdl_64bits.ini +++ b/user_setups/darwin_sdl/darwin_sdl_64bits.ini @@ -58,8 +58,10 @@ build_flags = -lm -lpthread ; MacOS with Homebrew - -I/usr/local/include - -L/usr/local/lib + ;-I/usr/local/include + ;-L/usr/local/lib + -I/opt/homebrew/include + -L/opt/homebrew/lib -DTARGET_OS_MAC=1 lib_deps = @@ -77,6 +79,7 @@ lib_ignore = ArduinoLog lv_lib_qrcode ETHSPI + freetype build_src_filter = +<*> From 8b3451a1346ab4db2fe0d60b9a610785a1e704d6 Mon Sep 17 00:00:00 2001 From: tbxmb Date: Tue, 2 Jan 2024 19:17:09 +0100 Subject: [PATCH 03/18] Add: Pin configuration for esp32-s3-4848S040 #603 --- user_setups/esp32s3/esp32-s3-4848S040.ini | 85 +++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 user_setups/esp32s3/esp32-s3-4848S040.ini diff --git a/user_setups/esp32s3/esp32-s3-4848S040.ini b/user_setups/esp32s3/esp32-s3-4848S040.ini new file mode 100644 index 00000000..d620c21c --- /dev/null +++ b/user_setups/esp32s3/esp32-s3-4848S040.ini @@ -0,0 +1,85 @@ +;***************************************************; +; Generic T3E with TFT 3.95" ; +; - Custom esp32-s3 board ; +; - st7701s TFT ; +; - gt911 touch controller ; +;***************************************************; + +[esp32-s3-4848S040] +extends = arduino_esp32s3_v2 +board = esp32-s3-devkitc-1 +board_build.arduino.memory_type = qio_opi + +build_flags = + -D HASP_MODEL="ESP32-S3 4848S040" + ${arduino_esp32s3_v2.build_flags} + ${esp32s3.ps_ram} + ;-DARDUINO_USB_CDC_ON_BOOT + ;-DUSE_USB_CDC_CONSOLE + +;region -- ArduinoGFX build options ------------------------ + -D HASP_USE_ARDUINOGFX=1 + -D ST7701_DRIVER=1 + -D TFT_WIDTH=480 + -D TFT_HEIGHT=480 + ; Bus Settings + -D TFT_CS=39 + -D TFT_SCLK=48 + -D TFT_MOSI=47 + -D TFT_DE=18 + -D TFT_VSYNC=17 + -D TFT_HSYNC=16 + -D TFT_PCLK=21 + -D TFT_R0=11 + -D TFT_R1=12 + -D TFT_R2=13 + -D TFT_R3=14 + -D TFT_R4=0 + -D TFT_G0=8 + -D TFT_G1=20 + -D TFT_G2=3 + -D TFT_G3=46 + -D TFT_G4=9 + -D TFT_G5=10 + -D TFT_B0=4 + -D TFT_B1=5 + -D TFT_B2=6 + -D TFT_B3=7 + -D TFT_B4=15 + -D TFT_DC=-1 + -D TFT_MISO=-1 + -D TFT_RST=-1 + -D TFT_BUSY=-1 + -D TFT_BCKL=38 + ; Panel Settings + -D TFT_HSYNC_POLARITY=1 + -D TFT_HSYNC_FRONT_PORCH=10 + -D TFT_HSYNC_PULSE_WIDTH=8 + -D TFT_HSYNC_BACK_PORCH=50 + -D TFT_VSYNC_POLARITY=1 + -D TFT_VSYNC_FRONT_PORCH=10 + -D TFT_VSYNC_PULSE_WIDTH=8 + -D TFT_VSYNC_BACK_PORCH=20 + -D TFT_PCLK_ACTIVE_NEG=1 + -D TFT_PREFER_SPEED=12000000 + -D TFT_AUTO_FLUSH=1 + ; Touch Settings + -D TOUCH_DRIVER=0x911 + -D TOUCH_WIDTH=480 + -D TOUCH_HEIGHT=480 + -D TOUCH_SDA=19 + -D TOUCH_SCL=45 + -D TOUCH_RST=-1 + -D TOUCH_IRQ=-1 + -D I2C_TOUCH_FREQUENCY=400000 + -D I2C_TOUCH_ADDRESS=0x5D ; or 0x14 + -D I2C_TOUCH_PORT=1 +;endregion + +lib_deps = + ${arduino_esp32s3_v2.lib_deps} + ${arduinogfx.lib_deps} + ${goodix.lib_deps} + +[env:esp32-s3-4848S040] +extends = esp32-s3-4848S040, flash_16mb \ No newline at end of file From 7af48cff375fc0c73ffa10230f0dc45a7c1a2354 Mon Sep 17 00:00:00 2001 From: tbxmb Date: Wed, 3 Jan 2024 02:37:14 +0100 Subject: [PATCH 04/18] Add modified init operations for esp32-s3-4848S040 #603 --- .../Arduino_RGB_Display_mod.h | 119 ++++++++++++++++++ platformio_override-template.ini | 1 + src/drv/tft/tft_driver_arduinogfx.cpp | 10 ++ user_setups/esp32s3/esp32-s3-4848S040.ini | 1 + 4 files changed, 131 insertions(+) diff --git a/lib/Arduino_RPi_DPI_RGBPanel_mod/Arduino_RGB_Display_mod.h b/lib/Arduino_RPi_DPI_RGBPanel_mod/Arduino_RGB_Display_mod.h index 982da439..ae343534 100644 --- a/lib/Arduino_RPi_DPI_RGBPanel_mod/Arduino_RGB_Display_mod.h +++ b/lib/Arduino_RPi_DPI_RGBPanel_mod/Arduino_RGB_Display_mod.h @@ -11,6 +11,125 @@ #include "Arduino_GFX.h" #include "Arduino_RGBPanel_mod.h" +static const uint8_t st7701_4848S040_init_operations[] = { + BEGIN_WRITE, + WRITE_COMMAND_8, 0xFF, + WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x10, + + WRITE_C8_D16, 0xC0, 0x3B, 0x00, + WRITE_C8_D16, 0xC1, 0x0D, 0x02, + WRITE_C8_D16, 0xC2, 0x31, 0x05, + WRITE_C8_D8, 0xCD, 0x00,//0x08 + + WRITE_COMMAND_8, 0xB0, // Positive Voltage Gamma Control + WRITE_BYTES, 16, + 0x00, 0x11, 0x18, 0x0E, + 0x11, 0x06, 0x07, 0x08, + 0x07, 0x22, 0x04, 0x12, + 0x0F, 0xAA, 0x31, 0x18, + + WRITE_COMMAND_8, 0xB1, // Negative Voltage Gamma Control + WRITE_BYTES, 16, + 0x00, 0x11, 0x19, 0x0E, + 0x12, 0x07, 0x08, 0x08, + 0x08, 0x22, 0x04, 0x11, + 0x11, 0xA9, 0x32, 0x18, + + // PAGE1 + WRITE_COMMAND_8, 0xFF, + WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x11, + + WRITE_C8_D8, 0xB0, 0x60, // Vop=4.7375v + WRITE_C8_D8, 0xB1, 0x32, // VCOM=32 + WRITE_C8_D8, 0xB2, 0x07, // VGH=15v + WRITE_C8_D8, 0xB3, 0x80, + WRITE_C8_D8, 0xB5, 0x49, // VGL=-10.17v + WRITE_C8_D8, 0xB7, 0x85, + WRITE_C8_D8, 0xB8, 0x21, // AVDD=6.6 & AVCL=-4.6 + WRITE_C8_D8, 0xC1, 0x78, + WRITE_C8_D8, 0xC2, 0x78, + + WRITE_COMMAND_8, 0xE0, + WRITE_BYTES, 3, 0x00, 0x1B, 0x02, + + WRITE_COMMAND_8, 0xE1, + WRITE_BYTES, 11, + 0x08, 0xA0, 0x00, 0x00, + 0x07, 0xA0, 0x00, 0x00, + 0x00, 0x44, 0x44, + + WRITE_COMMAND_8, 0xE2, + WRITE_BYTES, 12, + 0x11, 0x11, 0x44, 0x44, + 0xED, 0xA0, 0x00, 0x00, + 0xEC, 0xA0, 0x00, 0x00, + + WRITE_COMMAND_8, 0xE3, + WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x11, + + WRITE_C8_D16, 0xE4, 0x44, 0x44, + + WRITE_COMMAND_8, 0xE5, + WRITE_BYTES, 16, + 0x0A, 0xE9, 0xD8, 0xA0, + 0x0C, 0xEB, 0xD8, 0xA0, + 0x0E, 0xED, 0xD8, 0xA0, + 0x10, 0xEF, 0xD8, 0xA0, + + WRITE_COMMAND_8, 0xE6, + WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x11, + + WRITE_C8_D16, 0xE7, 0x44, 0x44, + + WRITE_COMMAND_8, 0xE8, + WRITE_BYTES, 16, + 0x09, 0xE8, 0xD8, 0xA0, + 0x0B, 0xEA, 0xD8, 0xA0, + 0x0D, 0xEC, 0xD8, 0xA0, + 0x0F, 0xEE, 0xD8, 0xA0, + + WRITE_COMMAND_8, 0xEB, + WRITE_BYTES, 7, + 0x02, 0x00, 0xE4, 0xE4, + 0x88, 0x00, 0x40, + + WRITE_C8_D16, 0xEC, 0x3C, 0x00, + + WRITE_COMMAND_8, 0xED, + WRITE_BYTES, 16, + 0xAB, 0x89, 0x76, 0x54, + 0x02, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0x20, + 0x45, 0x67, 0x98, 0xBA, + + //-----------VAP & VAN--------------- + WRITE_COMMAND_8, 0xFF, + WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x13, + + WRITE_C8_D8, 0xE5, 0xE4, + + WRITE_COMMAND_8, 0xFF, + WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x00, + + WRITE_COMMAND_8, 0x21, // 0x20 normal, 0x21 IPS + WRITE_C8_D8, 0x3A, 0x60, // 0x70 RGB888, 0x60 RGB666, 0x50 RGB565 + + //WRITE_COMMAND_8, 0x21,0X00, + //END_WRITE, + + WRITE_COMMAND_8, 0x11, // Sleep Out + END_WRITE, + + DELAY, 120, + + BEGIN_WRITE, + WRITE_COMMAND_8, 0x29, // Display On + END_WRITE, + + BEGIN_WRITE, + WRITE_COMMAND_8, 0x20, // Invert display + END_WRITE +}; static const uint8_t st7701_sensecap_indicator_init_operations[] = { BEGIN_WRITE, diff --git a/platformio_override-template.ini b/platformio_override-template.ini index dcd3918e..8de29970 100644 --- a/platformio_override-template.ini +++ b/platformio_override-template.ini @@ -71,6 +71,7 @@ extra_default_envs = ; wt-86-32-3zw1 ; yeacreate-nscreen32 ; wz2432r028 + ; esp32-s3-4848S040 ;endregion ;region -- Define your local COM ports for each environment --- diff --git a/src/drv/tft/tft_driver_arduinogfx.cpp b/src/drv/tft/tft_driver_arduinogfx.cpp index 69084b6a..ff6f0835 100644 --- a/src/drv/tft/tft_driver_arduinogfx.cpp +++ b/src/drv/tft/tft_driver_arduinogfx.cpp @@ -63,6 +63,16 @@ void ArduinoGfx::init(int w, int h) tft = new Arduino_RGB_Display(w, h, rgbpanel, 0 /* rotation */, TFT_AUTO_FLUSH, bus, TFT_RST, gc9503v_type1_init_operations, sizeof(gc9503v_type1_init_operations)); +#elif(TFT_WIDTH == 480) && (TFT_HEIGHT == 480) && defined(ST7701_DRIVER) && defined(ST7701_4848S040) + Arduino_DataBus* bus = new Arduino_SWSPI(TFT_DC, TFT_CS, TFT_SCLK, TFT_MOSI, TFT_MISO); + Arduino_ESP32RGBPanel* rgbpanel = new Arduino_ESP32RGBPanel( + TFT_DE, TFT_VSYNC, TFT_HSYNC, TFT_PCLK, TFT_R0, TFT_R1, TFT_R2, TFT_R3, TFT_R4, TFT_G0, TFT_G1, TFT_G2, TFT_G3, + TFT_G4, TFT_G5, TFT_B0, TFT_B1, TFT_B2, TFT_B3, TFT_B4, TFT_HSYNC_POLARITY, TFT_HSYNC_FRONT_PORCH, + TFT_HSYNC_PULSE_WIDTH, TFT_HSYNC_BACK_PORCH, TFT_VSYNC_POLARITY, TFT_VSYNC_FRONT_PORCH, TFT_VSYNC_PULSE_WIDTH, + TFT_VSYNC_BACK_PORCH); + + tft = new Arduino_RGB_Display(w, h, rgbpanel, 0 /* rotation */, TFT_AUTO_FLUSH, bus, TFT_RST, + st7701_4848S040_init_operations, sizeof(st7701_4848S040_init_operations)); #elif(TFT_WIDTH == 480) && (TFT_HEIGHT == 480) && defined(ST7701_DRIVER) /* More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class */ Arduino_DataBus* bus = new Arduino_SWSPI(TFT_DC, TFT_CS, TFT_SCLK, TFT_MOSI, TFT_MISO); diff --git a/user_setups/esp32s3/esp32-s3-4848S040.ini b/user_setups/esp32s3/esp32-s3-4848S040.ini index d620c21c..db5a5b6e 100644 --- a/user_setups/esp32s3/esp32-s3-4848S040.ini +++ b/user_setups/esp32s3/esp32-s3-4848S040.ini @@ -20,6 +20,7 @@ build_flags = ;region -- ArduinoGFX build options ------------------------ -D HASP_USE_ARDUINOGFX=1 -D ST7701_DRIVER=1 + -D ST7701_4848S040=1 -D TFT_WIDTH=480 -D TFT_HEIGHT=480 ; Bus Settings From 9864ae7a87a7cbd1d09b0c4c685763c038336f98 Mon Sep 17 00:00:00 2001 From: fvanroie <15969459+fvanroie@users.noreply.github.com> Date: Thu, 4 Jan 2024 03:09:40 +0100 Subject: [PATCH 05/18] Revert "sleep state - run idle scripts and allow to control the backlight" --- src/hasp/hasp.cpp | 14 +++++++------- src/hasp/hasp.h | 2 +- src/hasp/hasp_dispatch.cpp | 9 ++++++--- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/hasp/hasp.cpp b/src/hasp/hasp.cpp index ad9cc5fd..9187f4ad 100644 --- a/src/hasp/hasp.cpp +++ b/src/hasp/hasp.cpp @@ -119,17 +119,20 @@ HASP_ATTRIBUTE_FAST_MEM void hasp_update_sleep_state() if(sleepTimeLong > 0 && idle >= (sleepTimeShort + sleepTimeLong)) { if(hasp_sleep_state != HASP_SLEEP_LONG) { gui_hide_pointer(true); - hasp_set_sleep_state(HASP_SLEEP_LONG, TAG_MAIN); + hasp_sleep_state = HASP_SLEEP_LONG; + dispatch_idle_state(HASP_SLEEP_LONG); } } else if(sleepTimeShort > 0 && idle >= sleepTimeShort) { if(hasp_sleep_state != HASP_SLEEP_SHORT) { gui_hide_pointer(true); - hasp_set_sleep_state(HASP_SLEEP_SHORT, TAG_MAIN); + hasp_sleep_state = HASP_SLEEP_SHORT; + dispatch_idle_state(HASP_SLEEP_SHORT); } } else { if(hasp_sleep_state != HASP_SLEEP_OFF) { gui_hide_pointer(false); - hasp_set_sleep_state(HASP_SLEEP_OFF, TAG_MAIN); + hasp_sleep_state = HASP_SLEEP_OFF; + dispatch_idle_state(HASP_SLEEP_OFF); } } } @@ -144,21 +147,18 @@ uint8_t hasp_get_sleep_state() return hasp_sleep_state; } -void hasp_set_sleep_state(uint8_t state, uint8_t source) +void hasp_set_sleep_state(uint8_t state) { switch(state) { case HASP_SLEEP_LONG: hasp_set_sleep_offset(sleepTimeShort + sleepTimeLong); - dispatch_run_script(NULL, "L:/idle_long.cmd", source); break; case HASP_SLEEP_SHORT: hasp_set_sleep_offset(sleepTimeShort); - dispatch_run_script(NULL, "L:/idle_short.cmd", source); break; case HASP_SLEEP_OFF: hasp_set_sleep_offset(0); // hasp_set_wakeup_touch(false); - dispatch_run_script(NULL, "L:/idle_off.cmd", source); break; default: return; diff --git a/src/hasp/hasp.h b/src/hasp/hasp.h index cf30abed..4b9b5217 100644 --- a/src/hasp/hasp.h +++ b/src/hasp/hasp.h @@ -79,7 +79,7 @@ lv_font_t* hasp_get_font(uint8_t fontid); HASP_ATTRIBUTE_FAST_MEM void hasp_update_sleep_state(); void hasp_get_sleep_payload(uint8_t state, char* payload); uint8_t hasp_get_sleep_state(); -void hasp_set_sleep_state(uint8_t state, uint8_t source); +void hasp_set_sleep_state(uint8_t state); void hasp_get_sleep_time(uint16_t& short_time, uint16_t& long_time); void hasp_set_sleep_time(uint16_t short_time, uint16_t long_time); void hasp_set_sleep_offset(uint32_t offset); diff --git a/src/hasp/hasp_dispatch.cpp b/src/hasp/hasp_dispatch.cpp index 38548264..3ffe667f 100644 --- a/src/hasp/hasp_dispatch.cpp +++ b/src/hasp/hasp_dispatch.cpp @@ -1364,11 +1364,14 @@ void dispatch_idle(const char*, const char* payload, uint8_t source) if(payload && strlen(payload)) { uint8_t state = HASP_SLEEP_LAST; if(!strcmp_P(payload, "off")) { - hasp_set_sleep_state(HASP_SLEEP_OFF, source); + hasp_set_sleep_state(HASP_SLEEP_OFF); + dispatch_run_script(NULL, "L:/idle_off.cmd", source); } else if(!strcmp_P(payload, "short")) { - hasp_set_sleep_state(HASP_SLEEP_SHORT, source); + hasp_set_sleep_state(HASP_SLEEP_SHORT); + dispatch_run_script(NULL, "L:/idle_short.cmd", source); } else if(!strcmp_P(payload, "long")) { - hasp_set_sleep_state(HASP_SLEEP_LONG, source); + hasp_set_sleep_state(HASP_SLEEP_LONG); + dispatch_run_script(NULL, "L:/idle_long.cmd", source); } else { LOG_WARNING(TAG_MSGR, F("Invalid idle value %s"), payload); return; From a5e348e499dcfe58ee6f772865e3dbcba08a9f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20St=C3=BCck?= Date: Mon, 15 Jan 2024 15:52:11 -0500 Subject: [PATCH 06/18] Add Adafruit TSC2007 library from https://github.com/adafruit/Adafruit_TSC2007 --- .gitmodules | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 90d1c1d0..7706a667 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,7 @@ [submodule "lib/freetype"] path = lib/freetype url = https://github.com/fvanroie/freetype - \ No newline at end of file + +[submodule "lib/Adafruit_TSC2007"] + path = lib/Adafruit_TSC2007 + url = https://github.com/adafruit/Adafruit_TSC2007.git From ab4664b4b8e6b01c0c9b5ae4d939f492f26ab2de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20St=C3=BCck?= Date: Mon, 15 Jan 2024 15:53:04 -0500 Subject: [PATCH 07/18] Add support for TSC2007 touch controller --- platformio.ini | 4 ++ src/drv/touch/touch_driver.h | 3 + src/drv/touch/touch_driver_tsc2007.h | 104 +++++++++++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 src/drv/touch/touch_driver_tsc2007.h diff --git a/platformio.ini b/platformio.ini index c28cea8c..dc0edda8 100644 --- a/platformio.ini +++ b/platformio.ini @@ -124,6 +124,10 @@ lib_deps = lib_deps = git+https://github.com/aselectroworks/Arduino-FT6336U.git +[tsc2007] +lib_deps = + git+https://github.com/adafruit/Adafruit_TSC2007.git + [gsl1680] lib_deps = git+https://github.com/arovak/GSL2038.git diff --git a/src/drv/touch/touch_driver.h b/src/drv/touch/touch_driver.h index 674558f7..7e729180 100644 --- a/src/drv/touch/touch_driver.h +++ b/src/drv/touch/touch_driver.h @@ -84,6 +84,9 @@ class BaseTouch { #elif TOUCH_DRIVER == 0x1680 #warning Building for GSL1680 #include "touch_driver_gslx680.h" +#elif TOUCH_DRIVER == 0x2007 +#warning Building for TSC2007 +#include "touch_driver_tsc2007.h" #elif defined(LGFX_USE_V1) #warning Building for LovyanGfx Touch #include "touch_driver_lovyangfx.h" diff --git a/src/drv/touch/touch_driver_tsc2007.h b/src/drv/touch/touch_driver_tsc2007.h new file mode 100644 index 00000000..7688842c --- /dev/null +++ b/src/drv/touch/touch_driver_tsc2007.h @@ -0,0 +1,104 @@ +/* MIT License - Copyright (c) 2019-2022 Francis Van Roie + For full license information read the LICENSE file in the project folder */ + +#ifndef HASP_TSC2007_TOUCH_DRIVER_H +#define HASP_TSC2007_TOUCH_DRIVER_H + +#if defined(ARDUINO) && !defined(HASP_USE_LGFX_TOUCH) +#include +#include "ArduinoLog.h" +#include "hasp_conf.h" + +#include +#include "Adafruit_TSC2007.h" + +#include "touch_driver.h" // base class +#include "touch_helper.h" // i2c scanner + +#include "hasp_debug.h" + +#include "../../hasp/hasp.h" // for hasp_sleep_state +extern uint8_t hasp_sleep_state; + +// This is calibration data for the raw touch data to the screen coordinates +#define TS_MINX 150 +#define TS_MINY 130 +#define TS_MAXX 3800 +#define TS_MAXY 4000 +#define TS_MIN_PRESSURE 100 + +namespace dev { + +class TouchTsc2007 : public BaseTouch { + public: + Adafruit_TSC2007* ts; + + IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) + { + uint16_t x, y, z1, z2; + if (ts->read_touch(&x, &y, &z1, &z2) && (z1 > TS_MIN_PRESSURE)) { + if(hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_state(); // update Idle + + data->state = LV_INDEV_STATE_PR; + hasp_set_sleep_offset(0); // Reset the offset + + // Scale from ~0->4000 to tft.width using the calibration #'s + x = map(x, TS_MINX, TS_MAXX, 0, TFT_WIDTH); + y = map(y, TS_MINY, TS_MAXY, 0, TFT_HEIGHT); + + // LOG_INFO(TAG_DRVR, F("Touch point: %i, %i"), x, y); + +#if defined(TOUCH_SWAP_XY) && (TOUCH_SWAP_XY) + data->point.x = y; + data->point.y = x; +#else + data->point.x = x; + data->point.y = y; +#endif + +#if defined(TOUCH_INVERSE_X) && (TOUCH_INVERSE_X) + data->point.x = _width_max - x; +#endif +#if defined(TOUCH_INVERSE_Y) && (TOUCH_INVERSE_Y) + data->point.y = _height_max - y; +#endif + + } else { + data->state = LV_INDEV_STATE_REL; + } + + /*Return `false` because we are not buffering and no more data to read*/ + return false; + } + + void init(int w, int h) + { + _height_max = h - 1; + _width_max = w - 1; + + // tsc2007_touch = new Adafruit_TSC2007(); + LOG_VERBOSE(TAG_DRVR, F("%s %d"), __FILE__, __LINE__); + + ts = new Adafruit_TSC2007(); + + // Startup sequence CONTROLLER parT + if (!ts->begin()) { + LOG_INFO(TAG_DRVR, F("Failed to find Adafruit TSC2007 chip")); + while (1) { delay(10); } + } + LOG_INFO(TAG_DRVR, F("Found Adafruit TSC2007 chip")); + } + + private: + uint16_t _width_max; + uint16_t _height_max; +}; + +} // namespace dev + +using dev::TouchTsc2007; +dev::TouchTsc2007 haspTouch; + +#endif // ARDUINO + +#endif // HASP_TSC2007_TOUCH_DRIVER_H \ No newline at end of file From a0ed65c4ce8493c85849552ac77a2d0c397bfcbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20St=C3=BCck?= Date: Mon, 15 Jan 2024 16:15:54 -0500 Subject: [PATCH 08/18] Add support for updated Adafruit 2.4 and 3.5 TFT FeatherWings and HUZZAH32 boards Support added for the following displays: - [Adafruit TFT FeatherWing - 2.4" 320x240 Touchscreen For All Feathers - V2](https://www.adafruit.com/product/3315) - [Adafruit TFT FeatherWing - 3.5" 480x320 Touchscreen for Feathers - V2 with TSC2007](https://www.adafruit.com/product/3651) Support added for the following board: - [Adafruit HUZZAH32 ESP32 Feather V2 - 8MB Flash + 2 MB PSRAM - STEMMA QT](https://www.adafruit.com/product/5400) --- .github/workflows/build.yaml | 2 +- .github/workflows/release.yml | 2 +- platformio_override-template.ini | 6 +++ .../esp32/huzzah32-featherwing-24-v2.ini | 31 ++++++++++++++ .../esp32/huzzah32-featherwing-35-v2.ini | 32 +++++++++++++++ .../esp32/huzzah32-v2-featherwing-24-v2.ini | 31 ++++++++++++++ .../esp32/huzzah32-v2-featherwing-35-v2.ini | 31 ++++++++++++++ .../esp32s2/esp32s2-featherwing-24-v2.ini | 40 +++++++++++++++++++ .../esp32s2/esp32s2-featherwing-35-v2.ini | 40 +++++++++++++++++++ user_setups/lcd_config.ini | 23 +++++++++++ 10 files changed, 236 insertions(+), 2 deletions(-) create mode 100644 user_setups/esp32/huzzah32-featherwing-24-v2.ini create mode 100644 user_setups/esp32/huzzah32-featherwing-35-v2.ini create mode 100644 user_setups/esp32/huzzah32-v2-featherwing-24-v2.ini create mode 100644 user_setups/esp32/huzzah32-v2-featherwing-35-v2.ini create mode 100644 user_setups/esp32s2/esp32s2-featherwing-24-v2.ini create mode 100644 user_setups/esp32s2/esp32s2-featherwing-35-v2.ini diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index abcec923..d57b3061 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -21,7 +21,7 @@ jobs: matrix: environment: - out: adafruit - env: "huzzah32-featherwing-24 -e huzzah32-featherwing-35" + env: "huzzah32-featherwing-24 -e huzzah32-featherwing-35 -e huzzah32-featherwing-24-v2 -e huzzah32-featherwing-35-v2 -e huzzah32-v2-featherwing-24-v2 -e huzzah32-v2-featherwing-35-v2" - out: az-touch env: "az-touch-mod-esp32_ili9341_4MB -e az-touch-mod-esp32_ili9341_8MB" - env: d1-mini-esp32_ili9341 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b47c2d78..62ef57b4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,7 +63,7 @@ jobs: - name: Run PlatformIO run: pio run -e esp32-touchdown -e freetouchdeck_4MB -e freetouchdeck_8MB - name: Run PlatformIO - run: pio run -e huzzah32-featherwing-24 -e huzzah32-featherwing-35 + run: pio run -e huzzah32-featherwing-24 -e huzzah32-featherwing-35 -e huzzah32-featherwing-24-v2 -e huzzah32-featherwing-35-v2 -e huzzah32-v2-featherwing-24-v2 -e huzzah32-v2-featherwing-35-v2 - name: Run PlatformIO run: pio run -e lanbon_l8 - name: Run PlatformIO diff --git a/platformio_override-template.ini b/platformio_override-template.ini index 8de29970..941fe815 100644 --- a/platformio_override-template.ini +++ b/platformio_override-template.ini @@ -29,6 +29,8 @@ extra_default_envs = ; d1-r32-unoshield_ili9341_adc ; d1-r32-unoshield_ili9486_adc ; d1-r32-waveshare_ili9486 + ; esp32s2-featherwing-24-v2 + ; esp32s2-featherwing-35-v2 ; esp32-2432s028r_4MB ; esp32-3248s035c_4MB ; esp32-3248s035c_4MB_lovyan @@ -44,7 +46,11 @@ extra_default_envs = ; freetouchdeck-s3_8MB ; gs-t3e_16MB ; huzzah32-featherwing-24 + ; huzzah32-featherwing-24-v2 + ; huzzah32-v2-featherwing-24-v2 ; huzzah32-featherwing-35 + ; huzzah32-featherwing-35-v2 + ; huzzah32-v2-featherwing-35-v2 ; lanbon_l8 ; lanbon_l8_eth ; lilygo-lily-pi_ili9481 diff --git a/user_setups/esp32/huzzah32-featherwing-24-v2.ini b/user_setups/esp32/huzzah32-featherwing-24-v2.ini new file mode 100644 index 00000000..8c97b591 --- /dev/null +++ b/user_setups/esp32/huzzah32-featherwing-24-v2.ini @@ -0,0 +1,31 @@ +;***************************************************; +; HUZZAH32 ESP32 with Featherwing TFT 2.4" V2 ; +; - HUZZAH32 esp32 board ; +; - ili9341 TFT Featherwing 2.4" V2 ; +; - TSC2007 touch controller ; +;***************************************************; + +[env:huzzah32-featherwing-24-v2] +extends = arduino_esp32_v2, flash_4mb +board = featheresp32 + +build_flags = + -D HASP_MODEL="Adafruit HUZZAH32 ESP32 Featherwing 2.4 V2" + ${arduino_esp32_v2.build_flags} + ${esp32.no_ps_ram} + +;region -- TFT_eSPI build options ------------------------ + ${lcd.featherwing-24-v2} + -D TFT_MISO=19 + -D TFT_MOSI=18 + -D TFT_SCLK=5 + -D TFT_DC=33 + -D TFT_CS=15 + -D TFT_RST=-1 ; RST + -D TFT_BCKL=21 ; Solder the LITE pad to a PWM enabled pin of the ESP, like GPIO 21 +;endregion + +lib_deps = + ${arduino_esp32_v2.lib_deps} + ${tft_espi.lib_deps} + ${tsc2007.lib_deps} \ No newline at end of file diff --git a/user_setups/esp32/huzzah32-featherwing-35-v2.ini b/user_setups/esp32/huzzah32-featherwing-35-v2.ini new file mode 100644 index 00000000..8b17d1bf --- /dev/null +++ b/user_setups/esp32/huzzah32-featherwing-35-v2.ini @@ -0,0 +1,32 @@ +;***************************************************; +; HUZZAH32 ESP32 with Featherwing TFT 3.5" V2 ; +; - HUZZAH32 esp32 board ; +; - HX8357D TFT Featherwing 3.5" V2 ; +; - TSC2007 touch controller ; +;***************************************************; + +[env:huzzah32-featherwing-35-v2] +extends = arduino_esp32_v2, flash_4mb +board = featheresp32 + +build_flags = + -D HASP_MODEL="Adafruit HUZZAH32 ESP32 Featherwing 3.5 V2" + ${arduino_esp32_v2.build_flags} + ${esp32.no_ps_ram} + + -D LV_INDEV_DEF_READ_PERIOD=30 +;region -- TFT_eSPI build options ------------------------ + ${lcd.featherwing-35-v2} + -D TFT_MISO=19 + -D TFT_MOSI=18 + -D TFT_SCLK=5 + -D TFT_DC=10 + -D TFT_CS=9 + -D TFT_RST=-1 ; RST + -D TFT_BCKL=21 ; Solder the LITE pad to a PWM enabled pin of the ESP, like GPIO 21 +;endregion + +lib_deps = + ${arduino_esp32_v2.lib_deps} + ${tft_espi.lib_deps} + ${tsc2007.lib_deps} diff --git a/user_setups/esp32/huzzah32-v2-featherwing-24-v2.ini b/user_setups/esp32/huzzah32-v2-featherwing-24-v2.ini new file mode 100644 index 00000000..29261680 --- /dev/null +++ b/user_setups/esp32/huzzah32-v2-featherwing-24-v2.ini @@ -0,0 +1,31 @@ +;***************************************************; +; HUZZAH32 V2 ESP32 with Featherwing TFT 2.4" V2 ; +; - HUZZAH32 V2 w/ 2 MB PSRAM board ; +; - ili9341 TFT Featherwing 2.4" V2 ; +; - TSC2007 touch controller ; +;***************************************************; + +[env:huzzah32-featherwing-24-v2] +extends = arduino_esp32_v2, flash_4mb +board = featheresp32 + +build_flags = + -D HASP_MODEL="Adafruit HUZZAH32 V2 ESP32 Featherwing 2.4 V2" + ${arduino_esp32_v2.build_flags} + ${esp32.ps_ram} + +;region -- TFT_eSPI build options ------------------------ + ${lcd.featherwing-24-v2} + -D TFT_MISO=19 + -D TFT_MOSI=18 + -D TFT_SCLK=5 + -D TFT_DC=33 + -D TFT_CS=15 + -D TFT_RST=-1 ; RST + -D TFT_BCKL=21 ; Solder the LITE pad to a PWM enabled pin of the ESP, like GPIO 21 +;endregion + +lib_deps = + ${arduino_esp32_v2.lib_deps} + ${tft_espi.lib_deps} + ${tsc2007.lib_deps} \ No newline at end of file diff --git a/user_setups/esp32/huzzah32-v2-featherwing-35-v2.ini b/user_setups/esp32/huzzah32-v2-featherwing-35-v2.ini new file mode 100644 index 00000000..c2a6b4c2 --- /dev/null +++ b/user_setups/esp32/huzzah32-v2-featherwing-35-v2.ini @@ -0,0 +1,31 @@ +;***************************************************; +; HUZZAH32 V2 ESP32 with Featherwing TFT 3.5" V2 ; +; - HUZZAH32 V2 w/ 2 MB PSRAM board ; +; - HX8357D TFT Featherwing 3.5" V2 ; +; - TSC2007 touch controller ; +;***************************************************; + +[env:huzzah32-v2-featherwing-35] +extends = arduino_esp32_v2, flash_4mb +board = featheresp32 + +build_flags = + -D HASP_MODEL="Adafruit HUZZAH32 V2 ESP32 Featherwing 3.5 V2" + ${arduino_esp32_v2.build_flags} + ${esp32.ps_ram} + -D LV_INDEV_DEF_READ_PERIOD=30 +;region -- TFT_eSPI build options ------------------------ + ${lcd.featherwing-35-v2} + -D TFT_MISO=19 + -D TFT_MOSI=18 + -D TFT_SCLK=5 + -D TFT_DC=10 + -D TFT_CS=9 + -D TFT_RST=-1 ; RST + -D TFT_BCKL=21 ; Solder the LITE pad to a PWM enabled pin of the ESP, like GPIO 21 +;endregion + +lib_deps = + ${arduino_esp32_v2.lib_deps} + ${tft_espi.lib_deps} + ${tsc2007.lib_deps} diff --git a/user_setups/esp32s2/esp32s2-featherwing-24-v2.ini b/user_setups/esp32s2/esp32s2-featherwing-24-v2.ini new file mode 100644 index 00000000..cb102e00 --- /dev/null +++ b/user_setups/esp32s2/esp32s2-featherwing-24-v2.ini @@ -0,0 +1,40 @@ +;***************************************************; +; Adafruit ESP32-S2 with Featherwing TFT 2.4" V2 ; +; - ESP32-S2 w/ 2 MB PSRAM board ; +; - ili9341 TFT Featherwing 2.4" V2 ; +; - TSC2007 touch controller ; +;***************************************************; + +[env:esp32s2-featherwing-24-v2] +extends = esp32s2_4mb_v2 +board = esp32s2 + +build_flags = + ${env.build_flags} + ${esp32s2.build_flags} + ${esp32.ps_ram} + -D HASP_MODEL="Adafruit ESP32-S2 Featherwing 2.4 V2" + -D USE_HSPI_PORT + +;region -- TFT_eSPI build options ------------------------ + ${lcd.featherwing-24-v2} + -D LGFX_USE_V1=1 + -D TFT_MISO=19 + -D TFT_MOSI=18 + -D TFT_SCLK=5 + -D TFT_DC=33 + -D TFT_CS=15 + -D TFT_RST=-1 ; RST + -D TFT_BCKL=21 ; Solder the LITE pad to a PWM enabled pin of the ESP, like GPIO 21 +;endregion + +lib_deps = + ${env.lib_deps} + ${esp32s2.lib_deps} + ${lovyangfx.lib_deps} + ${tsc2007.lib_deps} + +lib_ignore = + ${env.lib_ignore} + ${esp32s2.lib_ignore} + TFT_eSPI diff --git a/user_setups/esp32s2/esp32s2-featherwing-35-v2.ini b/user_setups/esp32s2/esp32s2-featherwing-35-v2.ini new file mode 100644 index 00000000..b781f449 --- /dev/null +++ b/user_setups/esp32s2/esp32s2-featherwing-35-v2.ini @@ -0,0 +1,40 @@ +;***************************************************; +; Adafruit ESP32-S2 with Featherwing TFT 3.5" V2 ; +; - ESP32-S2 w/ 2 MB PSRAM board ; +; - HX8357D TFT Featherwing 3.5" V2 ; +; - TSC2007 touch controller ; +;***************************************************; + +[env:esp32s2-featherwing-24-v2] +extends = esp32s2_4mb_v2 +board = esp32s2 + +build_flags = + ${env.build_flags} + ${esp32s2.build_flags} + ${esp32.ps_ram} + -D HASP_MODEL="Adafruit ESP32-S2 Featherwing 3.5 V2" + -D USE_HSPI_PORT + +;region -- TFT_eSPI build options ------------------------ + ${lcd.featherwing-35-v2} + -D LGFX_USE_V1=1 + -D TFT_MISO=19 + -D TFT_MOSI=18 + -D TFT_SCLK=5 + -D TFT_DC=10 + -D TFT_CS=9 + -D TFT_RST=-1 ; RST + -D TFT_BCKL=21 ; Solder the LITE pad to a PWM enabled pin of the ESP, like GPIO 21 +;endregion + +lib_deps = + ${env.lib_deps} + ${esp32s2.lib_deps} + ${tsc2007.lib_deps} + ${lovyangfx.lib_deps} + +lib_ignore = + ${env.lib_ignore} + ${esp32s2.lib_ignore} + TFT_eSPI diff --git a/user_setups/lcd_config.ini b/user_setups/lcd_config.ini index ce4e272b..8b5df106 100644 --- a/user_setups/lcd_config.ini +++ b/user_setups/lcd_config.ini @@ -122,6 +122,18 @@ featherwing-35 = -D TOUCH_DRIVER=0x0610 ;STMPE610 ;-D SUPPORT_TRANSACTIONS ; Default on ESP32 +featherwing-35-v2 = + -D HX8357D_DRIVER=1 + -D TFT_WIDTH=320 + -D TFT_HEIGHT=480 + -D TFT_ROTATION=0 ; Use default, see TFT_ROTATION values + -D SPI_FREQUENCY=27000000 + -D SPI_TOUCH_FREQUENCY=2500000 + -D SPI_READ_FREQUENCY=20000000 + -D USER_SETUP_LOADED=1 + -D TOUCH_DRIVER=0x2007 ;TSC2007 + ;-D SUPPORT_TRANSACTIONS ; Default on ESP32 + featherwing-24 = -D ILI9341_DRIVER=1 -D TFT_WIDTH=240 @@ -132,4 +144,15 @@ featherwing-24 = -D SPI_READ_FREQUENCY=20000000 -D USER_SETUP_LOADED=1 -D TOUCH_DRIVER=0x0610 ;STMPE610 + ;-D SUPPORT_TRANSACTIONS ; Default on ESP32 + +featherwing-24-v2 = + -D ILI9341_DRIVER=1 + -D TFT_WIDTH=240 + -D TFT_HEIGHT=320 + -D TFT_ROTATION=0 ; Use default, see TFT_ROTATION values + -D SPI_FREQUENCY=27000000 + -D SPI_READ_FREQUENCY=20000000 + -D USER_SETUP_LOADED=1 + -D TOUCH_DRIVER=0x2007 ;TSC2007 ;-D SUPPORT_TRANSACTIONS ; Default on ESP32 \ No newline at end of file From c411f2c3b0f8822d6df0e66e3aa6dc8fb9388342 Mon Sep 17 00:00:00 2001 From: tbxMb Date: Wed, 17 Jan 2024 14:21:18 +0100 Subject: [PATCH 09/18] Add esp32-s3-4848s040 to build.yaml --- .github/workflows/build.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index abcec923..4c9a3ccf 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -60,6 +60,8 @@ jobs: env: "wt32-sc01_4MB -e wt32-sc01_16MB -e wt-86-32-3zw1 -e wt32-sc01-plus_8MB -e wt32-sc01-plus_16MB" - out: yeacreate env: yeacreate-nscreen32 + - out: guition + env: esp32-s3-4848S040 steps: - uses: actions/checkout@v3 From 0218736d1d67f4ded98a7762a7f732518cd7cb9f Mon Sep 17 00:00:00 2001 From: fvanroie <15969459+fvanroie@users.noreply.github.com> Date: Wed, 17 Jan 2024 14:29:19 +0100 Subject: [PATCH 10/18] Update .gitmodules --- .gitmodules | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 7706a667..c1197372 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,6 +2,3 @@ path = lib/freetype url = https://github.com/fvanroie/freetype -[submodule "lib/Adafruit_TSC2007"] - path = lib/Adafruit_TSC2007 - url = https://github.com/adafruit/Adafruit_TSC2007.git From 79f8ed0c3355f7e3a32ad22ed200d1540683328a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20St=C3=BCck?= Date: Wed, 17 Jan 2024 10:11:52 -0500 Subject: [PATCH 11/18] Corrected environment names for huzzah32-v2-* boards --- user_setups/esp32/huzzah32-v2-featherwing-24-v2.ini | 2 +- user_setups/esp32/huzzah32-v2-featherwing-35-v2.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/user_setups/esp32/huzzah32-v2-featherwing-24-v2.ini b/user_setups/esp32/huzzah32-v2-featherwing-24-v2.ini index 29261680..457dc5aa 100644 --- a/user_setups/esp32/huzzah32-v2-featherwing-24-v2.ini +++ b/user_setups/esp32/huzzah32-v2-featherwing-24-v2.ini @@ -5,7 +5,7 @@ ; - TSC2007 touch controller ; ;***************************************************; -[env:huzzah32-featherwing-24-v2] +[env:huzzah32-v2-featherwing-24-v2] extends = arduino_esp32_v2, flash_4mb board = featheresp32 diff --git a/user_setups/esp32/huzzah32-v2-featherwing-35-v2.ini b/user_setups/esp32/huzzah32-v2-featherwing-35-v2.ini index c2a6b4c2..1cb762f8 100644 --- a/user_setups/esp32/huzzah32-v2-featherwing-35-v2.ini +++ b/user_setups/esp32/huzzah32-v2-featherwing-35-v2.ini @@ -5,7 +5,7 @@ ; - TSC2007 touch controller ; ;***************************************************; -[env:huzzah32-v2-featherwing-35] +[env:huzzah32-v2-featherwing-35-v2] extends = arduino_esp32_v2, flash_4mb board = featheresp32 From db7c9ddf7bac85b3106010323c69b63e4774f14d Mon Sep 17 00:00:00 2001 From: TheHexaMaster <129121144+TheHexaMaster@users.noreply.github.com> Date: Wed, 24 Jan 2024 12:12:59 +0100 Subject: [PATCH 12/18] Update sunton-esp32-s3-tft.ini Fixed display flickering settings while using wifi for sunton-8048s070c_16MB display --- user_setups/esp32s3/sunton-esp32-s3-tft.ini | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/user_setups/esp32s3/sunton-esp32-s3-tft.ini b/user_setups/esp32s3/sunton-esp32-s3-tft.ini index 7cbb14d8..f9bbe24c 100644 --- a/user_setups/esp32s3/sunton-esp32-s3-tft.ini +++ b/user_setups/esp32s3/sunton-esp32-s3-tft.ini @@ -228,15 +228,15 @@ build_flags = -D TFT_B4=4 ; Panel Settings -D TFT_HSYNC_POLARITY=0 - -D TFT_HSYNC_FRONT_PORCH=240 ; Maximum HSYNC Front Porch - -D TFT_HSYNC_PULSE_WIDTH=30 ; Typical HSYNC Pulse Width - -D TFT_HSYNC_BACK_PORCH=16 ; Typical HSYNC Back Porch + -D TFT_HSYNC_FRONT_PORCH=8 ; Maximum HSYNC Front Porch / 8 GOOD + -D TFT_HSYNC_PULSE_WIDTH=10 ; Typical HSYNC Pulse Width / 10 GOOD + -D TFT_HSYNC_BACK_PORCH=43 ; Typical HSYNC Back Porch / 43 GOOD -D TFT_VSYNC_POLARITY=0 - -D TFT_VSYNC_FRONT_PORCH=32 ; Maximum VSYNC Front Porch - -D TFT_VSYNC_PULSE_WIDTH=13 ; Typical VSYNC Pulse Width - -D TFT_VSYNC_BACK_PORCH=10 ; Typical VSYNC Back Porch + -D TFT_VSYNC_FRONT_PORCH=8 ; Maximum VSYNC Front Porch / 8 GOOD + -D TFT_VSYNC_PULSE_WIDTH=8 ; Typical VSYNC Pulse Width / 8 GOOD + -D TFT_VSYNC_BACK_PORCH=12 ; Typical VSYNC Back Porch / 12 GOOD -D TFT_PCLK_ACTIVE_NEG=1 - -D TFT_PREFER_SPEED=16000000 ; 1/2 of Typical DCLK Frequency + -D TFT_PREFER_SPEED=14500000 ; 1/2 of Typical DCLK Frequency / 12000000 GOOD -D TFT_AUTO_FLUSH=1 ; Touch Settings -D TOUCH_WIDTH=800 @@ -250,4 +250,4 @@ build_flags = -D I2C_TOUCH_FREQUENCY=400000 lib_deps = ${sunton-esp32-s3-tft.lib_deps} - ${goodix.lib_deps} \ No newline at end of file + ${goodix.lib_deps} From 6bfdcd47a11c3cf43da7b32c1172f22daa415f24 Mon Sep 17 00:00:00 2001 From: hans boot Date: Sat, 27 Jan 2024 14:03:59 +0100 Subject: [PATCH 13/18] Allow more time for http get --- src/hasp/hasp_attribute.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hasp/hasp_attribute.cpp b/src/hasp/hasp_attribute.cpp index f0934fb7..105cefce 100644 --- a/src/hasp/hasp_attribute.cpp +++ b/src/hasp/hasp_attribute.cpp @@ -1346,7 +1346,7 @@ static hasp_attribute_type_t special_attribute_src(lv_obj_t* obj, const char* pa #if HASP_USE_WIFI > 0 || HASP_USE_ETHERNET > 0 HTTPClient http; http.begin(payload); - http.setTimeout(1000); + http.setTimeout(5000); http.setConnectTimeout(5000); // const char* hdrs[] = {"Content-Type"}; From 03cd25edd27ed483666a858d4b606e4deb06078f Mon Sep 17 00:00:00 2001 From: hans boot Date: Sat, 27 Jan 2024 14:40:48 +0100 Subject: [PATCH 14/18] re-enable idle_* scripts --- src/hasp/hasp.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hasp/hasp.cpp b/src/hasp/hasp.cpp index 9187f4ad..34ba04f8 100644 --- a/src/hasp/hasp.cpp +++ b/src/hasp/hasp.cpp @@ -121,18 +121,21 @@ HASP_ATTRIBUTE_FAST_MEM void hasp_update_sleep_state() gui_hide_pointer(true); hasp_sleep_state = HASP_SLEEP_LONG; dispatch_idle_state(HASP_SLEEP_LONG); + dispatch_run_script(NULL, "L:/idle_long.cmd", TAG_MAIN); } } else if(sleepTimeShort > 0 && idle >= sleepTimeShort) { if(hasp_sleep_state != HASP_SLEEP_SHORT) { gui_hide_pointer(true); hasp_sleep_state = HASP_SLEEP_SHORT; dispatch_idle_state(HASP_SLEEP_SHORT); + dispatch_run_script(NULL, "L:/idle_short.cmd", TAG_MAIN); } } else { if(hasp_sleep_state != HASP_SLEEP_OFF) { gui_hide_pointer(false); hasp_sleep_state = HASP_SLEEP_OFF; dispatch_idle_state(HASP_SLEEP_OFF); + dispatch_run_script(NULL, "L:/idle_off.cmd", TAG_MAIN); } } } From 8436bb6493066ce433c92cb35fc5dfabd1dfd22b Mon Sep 17 00:00:00 2001 From: hans boot Date: Sat, 27 Jan 2024 14:45:49 +0100 Subject: [PATCH 15/18] revert re-enable idle_* scripts --- src/hasp/hasp.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/hasp/hasp.cpp b/src/hasp/hasp.cpp index 34ba04f8..9187f4ad 100644 --- a/src/hasp/hasp.cpp +++ b/src/hasp/hasp.cpp @@ -121,21 +121,18 @@ HASP_ATTRIBUTE_FAST_MEM void hasp_update_sleep_state() gui_hide_pointer(true); hasp_sleep_state = HASP_SLEEP_LONG; dispatch_idle_state(HASP_SLEEP_LONG); - dispatch_run_script(NULL, "L:/idle_long.cmd", TAG_MAIN); } } else if(sleepTimeShort > 0 && idle >= sleepTimeShort) { if(hasp_sleep_state != HASP_SLEEP_SHORT) { gui_hide_pointer(true); hasp_sleep_state = HASP_SLEEP_SHORT; dispatch_idle_state(HASP_SLEEP_SHORT); - dispatch_run_script(NULL, "L:/idle_short.cmd", TAG_MAIN); } } else { if(hasp_sleep_state != HASP_SLEEP_OFF) { gui_hide_pointer(false); hasp_sleep_state = HASP_SLEEP_OFF; dispatch_idle_state(HASP_SLEEP_OFF); - dispatch_run_script(NULL, "L:/idle_off.cmd", TAG_MAIN); } } } From 889682d49b30c7e3f9611aa164ce199a79953ec2 Mon Sep 17 00:00:00 2001 From: hans boot Date: Sat, 27 Jan 2024 15:05:34 +0100 Subject: [PATCH 16/18] re-enable idle scripts --- src/hasp/hasp.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hasp/hasp.cpp b/src/hasp/hasp.cpp index 9187f4ad..34ba04f8 100644 --- a/src/hasp/hasp.cpp +++ b/src/hasp/hasp.cpp @@ -121,18 +121,21 @@ HASP_ATTRIBUTE_FAST_MEM void hasp_update_sleep_state() gui_hide_pointer(true); hasp_sleep_state = HASP_SLEEP_LONG; dispatch_idle_state(HASP_SLEEP_LONG); + dispatch_run_script(NULL, "L:/idle_long.cmd", TAG_MAIN); } } else if(sleepTimeShort > 0 && idle >= sleepTimeShort) { if(hasp_sleep_state != HASP_SLEEP_SHORT) { gui_hide_pointer(true); hasp_sleep_state = HASP_SLEEP_SHORT; dispatch_idle_state(HASP_SLEEP_SHORT); + dispatch_run_script(NULL, "L:/idle_short.cmd", TAG_MAIN); } } else { if(hasp_sleep_state != HASP_SLEEP_OFF) { gui_hide_pointer(false); hasp_sleep_state = HASP_SLEEP_OFF; dispatch_idle_state(HASP_SLEEP_OFF); + dispatch_run_script(NULL, "L:/idle_off.cmd", TAG_MAIN); } } } From c190cf94b54e551eb3adc38d70ceb7fd63de007e Mon Sep 17 00:00:00 2001 From: hans boot Date: Sat, 27 Jan 2024 15:51:33 +0100 Subject: [PATCH 17/18] update to TAG_HASP, as requested --- src/hasp/hasp.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hasp/hasp.cpp b/src/hasp/hasp.cpp index 34ba04f8..1a3336ee 100644 --- a/src/hasp/hasp.cpp +++ b/src/hasp/hasp.cpp @@ -121,21 +121,21 @@ HASP_ATTRIBUTE_FAST_MEM void hasp_update_sleep_state() gui_hide_pointer(true); hasp_sleep_state = HASP_SLEEP_LONG; dispatch_idle_state(HASP_SLEEP_LONG); - dispatch_run_script(NULL, "L:/idle_long.cmd", TAG_MAIN); + dispatch_run_script(NULL, "L:/idle_long.cmd", TAG_HASP); } } else if(sleepTimeShort > 0 && idle >= sleepTimeShort) { if(hasp_sleep_state != HASP_SLEEP_SHORT) { gui_hide_pointer(true); hasp_sleep_state = HASP_SLEEP_SHORT; dispatch_idle_state(HASP_SLEEP_SHORT); - dispatch_run_script(NULL, "L:/idle_short.cmd", TAG_MAIN); + dispatch_run_script(NULL, "L:/idle_short.cmd", TAG_HASP); } } else { if(hasp_sleep_state != HASP_SLEEP_OFF) { gui_hide_pointer(false); hasp_sleep_state = HASP_SLEEP_OFF; dispatch_idle_state(HASP_SLEEP_OFF); - dispatch_run_script(NULL, "L:/idle_off.cmd", TAG_MAIN); + dispatch_run_script(NULL, "L:/idle_off.cmd", TAG_HASP); } } } From 91faf614749757a7c122386afe5022e0c21bf727 Mon Sep 17 00:00:00 2001 From: Ryan Press Date: Mon, 29 Jan 2024 03:15:29 -0800 Subject: [PATCH 18/18] On ESP32 fade the backlight --- src/dev/esp32/esp32.cpp | 28 +++++++++++++++++++++------- src/dev/esp32/esp32.h | 4 +++- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/dev/esp32/esp32.cpp b/src/dev/esp32/esp32.cpp index 88d34460..049f3c1b 100644 --- a/src/dev/esp32/esp32.cpp +++ b/src/dev/esp32/esp32.cpp @@ -9,6 +9,7 @@ #include "esp_system.h" #include // needed to get the ResetInfo #include "driver/adc.h" +#include "driver/ledc.h" #include "esp_adc_cal.h" #include "esp_efuse.h" @@ -253,7 +254,8 @@ void Esp32Device::set_backlight_pin(uint8_t pin) ledcSetup(BACKLIGHT_CHANNEL, BACKLIGHT_FREQUENCY, 10); #endif ledcAttachPin(pin, BACKLIGHT_CHANNEL); - update_backlight(); + ledc_fade_func_install(0); + update_backlight(false); } else { LOG_VERBOSE(TAG_GUI, F("Backlight : Pin not set")); } @@ -262,7 +264,7 @@ void Esp32Device::set_backlight_pin(uint8_t pin) void Esp32Device::set_backlight_invert(bool invert) { _backlight_invert = invert; - update_backlight(); + update_backlight(false); } bool Esp32Device::get_backlight_invert() @@ -273,7 +275,7 @@ bool Esp32Device::get_backlight_invert() void Esp32Device::set_backlight_level(uint8_t level) { _backlight_level = level; - update_backlight(); + update_backlight(true); } uint8_t Esp32Device::get_backlight_level() @@ -284,7 +286,7 @@ uint8_t Esp32Device::get_backlight_level() void Esp32Device::set_backlight_power(bool power) { _backlight_power = power; - update_backlight(); + update_backlight(true); } bool Esp32Device::get_backlight_power() @@ -292,18 +294,30 @@ bool Esp32Device::get_backlight_power() return _backlight_power != 0; } -void Esp32Device::update_backlight() +void Esp32Device::update_backlight(bool fade) { + static uint32_t last_duty = 0; if(_backlight_pin < GPIO_NUM_MAX) { #if !defined(CONFIG_IDF_TARGET_ESP32S2) uint32_t duty = _backlight_power ? map(_backlight_level, 0, 255, 0, 1023) : 0; if(_backlight_invert) duty = 1023 - duty; - ledcWrite(BACKLIGHT_CHANNEL, duty); // ledChannel and value + if(fade) { + ledcWrite(BACKLIGHT_CHANNEL, last_duty); // this will stop an in-progress fade + ledc_set_fade_time_and_start(LEDC_LOW_SPEED_MODE, (ledc_channel_t) BACKLIGHT_CHANNEL, duty, BACKLIGHT_FADEMS, LEDC_FADE_NO_WAIT); + } else { + ledcWrite(BACKLIGHT_CHANNEL, duty); // ledChannel and value + } #else uint32_t duty = _backlight_power ? map(_backlight_level, 0, 255, 0, 1023) : 0; if(_backlight_invert) duty = 1023 - duty; - ledcWrite(BACKLIGHT_CHANNEL, duty); // ledChannel and value + if(fade) { + ledcWrite(BACKLIGHT_CHANNEL, last_duty); // this will stop an in-progress fade + ledc_set_fade_time_and_start(LEDC_LOW_SPEED_MODE, (ledc_channel_t) BACKLIGHT_CHANNEL, duty, BACKLIGHT_FADEMS, LEDC_FADE_NO_WAIT); + } else { + ledcWrite(BACKLIGHT_CHANNEL, duty); // ledChannel and value + } #endif + last_duty = duty; } // haspTft.tft.writecommand(0x53); // Write CTRL Display diff --git a/src/dev/esp32/esp32.h b/src/dev/esp32/esp32.h index 7dec242d..660d0df8 100644 --- a/src/dev/esp32/esp32.h +++ b/src/dev/esp32/esp32.h @@ -13,6 +13,8 @@ #define BACKLIGHT_FREQUENCY 20000 #endif +#define BACKLIGHT_FADEMS 200 + #ifdef __cplusplus extern "C" { #endif @@ -67,7 +69,7 @@ class Esp32Device : public BaseDevice { uint8_t _backlight_power; uint8_t _backlight_invert; - void update_backlight(); + void update_backlight(bool fade); }; } // namespace dev