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 1/4] 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 90d1c1d08..7706a667d 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 2/4] 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 c28cea8c2..dc0edda88 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 674558f75..7e7291805 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 000000000..7688842c7 --- /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 3/4] 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 abcec9234..d57b30619 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 b47c2d78b..62ef57b4f 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 8de29970b..941fe8150 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 000000000..8c97b591a --- /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 000000000..8b17d1bfc --- /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 000000000..29261680c --- /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 000000000..c2a6b4c26 --- /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 000000000..cb102e004 --- /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 000000000..b781f4495 --- /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 ce4e272bf..8b5df1069 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 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 4/4] Update .gitmodules --- .gitmodules | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 7706a667d..c1197372d 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