Skip to content

Commit bc627f0

Browse files
authored
Merge pull request #613 from amanaplan/TSC2007
Add support for updated Adafruit 2.4 and 3.5 TFT FeatherWings and HUZZAH32 board
2 parents cca34e6 + 0218736 commit bc627f0

14 files changed

+348
-3
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
matrix:
2222
environment:
2323
- out: adafruit
24-
env: "huzzah32-featherwing-24 -e huzzah32-featherwing-35"
24+
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"
2525
- out: az-touch
2626
env: "az-touch-mod-esp32_ili9341_4MB -e az-touch-mod-esp32_ili9341_8MB"
2727
- env: d1-mini-esp32_ili9341

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
- name: Run PlatformIO
6464
run: pio run -e esp32-touchdown -e freetouchdeck_4MB -e freetouchdeck_8MB
6565
- name: Run PlatformIO
66-
run: pio run -e huzzah32-featherwing-24 -e huzzah32-featherwing-35
66+
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
6767
- name: Run PlatformIO
6868
run: pio run -e lanbon_l8
6969
- name: Run PlatformIO

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "lib/freetype"]
22
path = lib/freetype
33
url = https://github.com/fvanroie/freetype
4-
4+

platformio.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ lib_deps =
124124
lib_deps =
125125
git+https://github.com/aselectroworks/Arduino-FT6336U.git
126126

127+
[tsc2007]
128+
lib_deps =
129+
git+https://github.com/adafruit/Adafruit_TSC2007.git
130+
127131
[gsl1680]
128132
lib_deps =
129133
git+https://github.com/arovak/GSL2038.git

platformio_override-template.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ extra_default_envs =
2929
; d1-r32-unoshield_ili9341_adc
3030
; d1-r32-unoshield_ili9486_adc
3131
; d1-r32-waveshare_ili9486
32+
; esp32s2-featherwing-24-v2
33+
; esp32s2-featherwing-35-v2
3234
; esp32-2432s028r_4MB
3335
; esp32-3248s035c_4MB
3436
; esp32-3248s035c_4MB_lovyan
@@ -44,7 +46,11 @@ extra_default_envs =
4446
; freetouchdeck-s3_8MB
4547
; gs-t3e_16MB
4648
; huzzah32-featherwing-24
49+
; huzzah32-featherwing-24-v2
50+
; huzzah32-v2-featherwing-24-v2
4751
; huzzah32-featherwing-35
52+
; huzzah32-featherwing-35-v2
53+
; huzzah32-v2-featherwing-35-v2
4854
; lanbon_l8
4955
; lanbon_l8_eth
5056
; lilygo-lily-pi_ili9481

src/drv/touch/touch_driver.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ class BaseTouch {
8484
#elif TOUCH_DRIVER == 0x1680
8585
#warning Building for GSL1680
8686
#include "touch_driver_gslx680.h"
87+
#elif TOUCH_DRIVER == 0x2007
88+
#warning Building for TSC2007
89+
#include "touch_driver_tsc2007.h"
8790
#elif defined(LGFX_USE_V1)
8891
#warning Building for LovyanGfx Touch
8992
#include "touch_driver_lovyangfx.h"

src/drv/touch/touch_driver_tsc2007.h

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
2+
For full license information read the LICENSE file in the project folder */
3+
4+
#ifndef HASP_TSC2007_TOUCH_DRIVER_H
5+
#define HASP_TSC2007_TOUCH_DRIVER_H
6+
7+
#if defined(ARDUINO) && !defined(HASP_USE_LGFX_TOUCH)
8+
#include <Arduino.h>
9+
#include "ArduinoLog.h"
10+
#include "hasp_conf.h"
11+
12+
#include <Wire.h>
13+
#include "Adafruit_TSC2007.h"
14+
15+
#include "touch_driver.h" // base class
16+
#include "touch_helper.h" // i2c scanner
17+
18+
#include "hasp_debug.h"
19+
20+
#include "../../hasp/hasp.h" // for hasp_sleep_state
21+
extern uint8_t hasp_sleep_state;
22+
23+
// This is calibration data for the raw touch data to the screen coordinates
24+
#define TS_MINX 150
25+
#define TS_MINY 130
26+
#define TS_MAXX 3800
27+
#define TS_MAXY 4000
28+
#define TS_MIN_PRESSURE 100
29+
30+
namespace dev {
31+
32+
class TouchTsc2007 : public BaseTouch {
33+
public:
34+
Adafruit_TSC2007* ts;
35+
36+
IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
37+
{
38+
uint16_t x, y, z1, z2;
39+
if (ts->read_touch(&x, &y, &z1, &z2) && (z1 > TS_MIN_PRESSURE)) {
40+
if(hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_state(); // update Idle
41+
42+
data->state = LV_INDEV_STATE_PR;
43+
hasp_set_sleep_offset(0); // Reset the offset
44+
45+
// Scale from ~0->4000 to tft.width using the calibration #'s
46+
x = map(x, TS_MINX, TS_MAXX, 0, TFT_WIDTH);
47+
y = map(y, TS_MINY, TS_MAXY, 0, TFT_HEIGHT);
48+
49+
// LOG_INFO(TAG_DRVR, F("Touch point: %i, %i"), x, y);
50+
51+
#if defined(TOUCH_SWAP_XY) && (TOUCH_SWAP_XY)
52+
data->point.x = y;
53+
data->point.y = x;
54+
#else
55+
data->point.x = x;
56+
data->point.y = y;
57+
#endif
58+
59+
#if defined(TOUCH_INVERSE_X) && (TOUCH_INVERSE_X)
60+
data->point.x = _width_max - x;
61+
#endif
62+
#if defined(TOUCH_INVERSE_Y) && (TOUCH_INVERSE_Y)
63+
data->point.y = _height_max - y;
64+
#endif
65+
66+
} else {
67+
data->state = LV_INDEV_STATE_REL;
68+
}
69+
70+
/*Return `false` because we are not buffering and no more data to read*/
71+
return false;
72+
}
73+
74+
void init(int w, int h)
75+
{
76+
_height_max = h - 1;
77+
_width_max = w - 1;
78+
79+
// tsc2007_touch = new Adafruit_TSC2007();
80+
LOG_VERBOSE(TAG_DRVR, F("%s %d"), __FILE__, __LINE__);
81+
82+
ts = new Adafruit_TSC2007();
83+
84+
// Startup sequence CONTROLLER parT
85+
if (!ts->begin()) {
86+
LOG_INFO(TAG_DRVR, F("Failed to find Adafruit TSC2007 chip"));
87+
while (1) { delay(10); }
88+
}
89+
LOG_INFO(TAG_DRVR, F("Found Adafruit TSC2007 chip"));
90+
}
91+
92+
private:
93+
uint16_t _width_max;
94+
uint16_t _height_max;
95+
};
96+
97+
} // namespace dev
98+
99+
using dev::TouchTsc2007;
100+
dev::TouchTsc2007 haspTouch;
101+
102+
#endif // ARDUINO
103+
104+
#endif // HASP_TSC2007_TOUCH_DRIVER_H
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
;***************************************************;
2+
; HUZZAH32 ESP32 with Featherwing TFT 2.4" V2 ;
3+
; - HUZZAH32 esp32 board ;
4+
; - ili9341 TFT Featherwing 2.4" V2 ;
5+
; - TSC2007 touch controller ;
6+
;***************************************************;
7+
8+
[env:huzzah32-featherwing-24-v2]
9+
extends = arduino_esp32_v2, flash_4mb
10+
board = featheresp32
11+
12+
build_flags =
13+
-D HASP_MODEL="Adafruit HUZZAH32 ESP32 Featherwing 2.4 V2"
14+
${arduino_esp32_v2.build_flags}
15+
${esp32.no_ps_ram}
16+
17+
;region -- TFT_eSPI build options ------------------------
18+
${lcd.featherwing-24-v2}
19+
-D TFT_MISO=19
20+
-D TFT_MOSI=18
21+
-D TFT_SCLK=5
22+
-D TFT_DC=33
23+
-D TFT_CS=15
24+
-D TFT_RST=-1 ; RST
25+
-D TFT_BCKL=21 ; Solder the LITE pad to a PWM enabled pin of the ESP, like GPIO 21
26+
;endregion
27+
28+
lib_deps =
29+
${arduino_esp32_v2.lib_deps}
30+
${tft_espi.lib_deps}
31+
${tsc2007.lib_deps}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
;***************************************************;
2+
; HUZZAH32 ESP32 with Featherwing TFT 3.5" V2 ;
3+
; - HUZZAH32 esp32 board ;
4+
; - HX8357D TFT Featherwing 3.5" V2 ;
5+
; - TSC2007 touch controller ;
6+
;***************************************************;
7+
8+
[env:huzzah32-featherwing-35-v2]
9+
extends = arduino_esp32_v2, flash_4mb
10+
board = featheresp32
11+
12+
build_flags =
13+
-D HASP_MODEL="Adafruit HUZZAH32 ESP32 Featherwing 3.5 V2"
14+
${arduino_esp32_v2.build_flags}
15+
${esp32.no_ps_ram}
16+
17+
-D LV_INDEV_DEF_READ_PERIOD=30
18+
;region -- TFT_eSPI build options ------------------------
19+
${lcd.featherwing-35-v2}
20+
-D TFT_MISO=19
21+
-D TFT_MOSI=18
22+
-D TFT_SCLK=5
23+
-D TFT_DC=10
24+
-D TFT_CS=9
25+
-D TFT_RST=-1 ; RST
26+
-D TFT_BCKL=21 ; Solder the LITE pad to a PWM enabled pin of the ESP, like GPIO 21
27+
;endregion
28+
29+
lib_deps =
30+
${arduino_esp32_v2.lib_deps}
31+
${tft_espi.lib_deps}
32+
${tsc2007.lib_deps}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
;***************************************************;
2+
; HUZZAH32 V2 ESP32 with Featherwing TFT 2.4" V2 ;
3+
; - HUZZAH32 V2 w/ 2 MB PSRAM board ;
4+
; - ili9341 TFT Featherwing 2.4" V2 ;
5+
; - TSC2007 touch controller ;
6+
;***************************************************;
7+
8+
[env:huzzah32-featherwing-24-v2]
9+
extends = arduino_esp32_v2, flash_4mb
10+
board = featheresp32
11+
12+
build_flags =
13+
-D HASP_MODEL="Adafruit HUZZAH32 V2 ESP32 Featherwing 2.4 V2"
14+
${arduino_esp32_v2.build_flags}
15+
${esp32.ps_ram}
16+
17+
;region -- TFT_eSPI build options ------------------------
18+
${lcd.featherwing-24-v2}
19+
-D TFT_MISO=19
20+
-D TFT_MOSI=18
21+
-D TFT_SCLK=5
22+
-D TFT_DC=33
23+
-D TFT_CS=15
24+
-D TFT_RST=-1 ; RST
25+
-D TFT_BCKL=21 ; Solder the LITE pad to a PWM enabled pin of the ESP, like GPIO 21
26+
;endregion
27+
28+
lib_deps =
29+
${arduino_esp32_v2.lib_deps}
30+
${tft_espi.lib_deps}
31+
${tsc2007.lib_deps}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
;***************************************************;
2+
; HUZZAH32 V2 ESP32 with Featherwing TFT 3.5" V2 ;
3+
; - HUZZAH32 V2 w/ 2 MB PSRAM board ;
4+
; - HX8357D TFT Featherwing 3.5" V2 ;
5+
; - TSC2007 touch controller ;
6+
;***************************************************;
7+
8+
[env:huzzah32-v2-featherwing-35]
9+
extends = arduino_esp32_v2, flash_4mb
10+
board = featheresp32
11+
12+
build_flags =
13+
-D HASP_MODEL="Adafruit HUZZAH32 V2 ESP32 Featherwing 3.5 V2"
14+
${arduino_esp32_v2.build_flags}
15+
${esp32.ps_ram}
16+
-D LV_INDEV_DEF_READ_PERIOD=30
17+
;region -- TFT_eSPI build options ------------------------
18+
${lcd.featherwing-35-v2}
19+
-D TFT_MISO=19
20+
-D TFT_MOSI=18
21+
-D TFT_SCLK=5
22+
-D TFT_DC=10
23+
-D TFT_CS=9
24+
-D TFT_RST=-1 ; RST
25+
-D TFT_BCKL=21 ; Solder the LITE pad to a PWM enabled pin of the ESP, like GPIO 21
26+
;endregion
27+
28+
lib_deps =
29+
${arduino_esp32_v2.lib_deps}
30+
${tft_espi.lib_deps}
31+
${tsc2007.lib_deps}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
;***************************************************;
2+
; Adafruit ESP32-S2 with Featherwing TFT 2.4" V2 ;
3+
; - ESP32-S2 w/ 2 MB PSRAM board ;
4+
; - ili9341 TFT Featherwing 2.4" V2 ;
5+
; - TSC2007 touch controller ;
6+
;***************************************************;
7+
8+
[env:esp32s2-featherwing-24-v2]
9+
extends = esp32s2_4mb_v2
10+
board = esp32s2
11+
12+
build_flags =
13+
${env.build_flags}
14+
${esp32s2.build_flags}
15+
${esp32.ps_ram}
16+
-D HASP_MODEL="Adafruit ESP32-S2 Featherwing 2.4 V2"
17+
-D USE_HSPI_PORT
18+
19+
;region -- TFT_eSPI build options ------------------------
20+
${lcd.featherwing-24-v2}
21+
-D LGFX_USE_V1=1
22+
-D TFT_MISO=19
23+
-D TFT_MOSI=18
24+
-D TFT_SCLK=5
25+
-D TFT_DC=33
26+
-D TFT_CS=15
27+
-D TFT_RST=-1 ; RST
28+
-D TFT_BCKL=21 ; Solder the LITE pad to a PWM enabled pin of the ESP, like GPIO 21
29+
;endregion
30+
31+
lib_deps =
32+
${env.lib_deps}
33+
${esp32s2.lib_deps}
34+
${lovyangfx.lib_deps}
35+
${tsc2007.lib_deps}
36+
37+
lib_ignore =
38+
${env.lib_ignore}
39+
${esp32s2.lib_ignore}
40+
TFT_eSPI
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
;***************************************************;
2+
; Adafruit ESP32-S2 with Featherwing TFT 3.5" V2 ;
3+
; - ESP32-S2 w/ 2 MB PSRAM board ;
4+
; - HX8357D TFT Featherwing 3.5" V2 ;
5+
; - TSC2007 touch controller ;
6+
;***************************************************;
7+
8+
[env:esp32s2-featherwing-24-v2]
9+
extends = esp32s2_4mb_v2
10+
board = esp32s2
11+
12+
build_flags =
13+
${env.build_flags}
14+
${esp32s2.build_flags}
15+
${esp32.ps_ram}
16+
-D HASP_MODEL="Adafruit ESP32-S2 Featherwing 3.5 V2"
17+
-D USE_HSPI_PORT
18+
19+
;region -- TFT_eSPI build options ------------------------
20+
${lcd.featherwing-35-v2}
21+
-D LGFX_USE_V1=1
22+
-D TFT_MISO=19
23+
-D TFT_MOSI=18
24+
-D TFT_SCLK=5
25+
-D TFT_DC=10
26+
-D TFT_CS=9
27+
-D TFT_RST=-1 ; RST
28+
-D TFT_BCKL=21 ; Solder the LITE pad to a PWM enabled pin of the ESP, like GPIO 21
29+
;endregion
30+
31+
lib_deps =
32+
${env.lib_deps}
33+
${esp32s2.lib_deps}
34+
${tsc2007.lib_deps}
35+
${lovyangfx.lib_deps}
36+
37+
lib_ignore =
38+
${env.lib_ignore}
39+
${esp32s2.lib_ignore}
40+
TFT_eSPI

0 commit comments

Comments
 (0)