Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7cfe470

Browse files
P-R-O-C-H-Ypre-commit-ci-lite[bot]
andauthoredOct 21, 2024··
feat(touch): Support NG touch driver for P4 (#10448)
* feat(touch): Support NG touch driver for P4 * fix(ci): Touch test + IDF compilation fixes * fix(ci): remove debug prints from touch test * fix(ci): Fix touch test for esp32 * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 59ca4e2 commit 7cfe470

File tree

14 files changed

+643
-46
lines changed

14 files changed

+643
-46
lines changed
 

‎CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ set(CORE_SRCS
4545
cores/esp32/esp32-hal-timer.c
4646
cores/esp32/esp32-hal-tinyusb.c
4747
cores/esp32/esp32-hal-touch.c
48+
cores/esp32/esp32-hal-touch-ng.c
4849
cores/esp32/esp32-hal-uart.c
4950
cores/esp32/esp32-hal-rmt.c
5051
cores/esp32/Esp.cpp
@@ -317,6 +318,10 @@ if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_OpenThre
317318
endif()
318319
endif()
319320

321+
if(IDF_TARGET STREQUAL "esp32p4")
322+
list(APPEND requires esp_driver_touch_sens)
323+
endif()
324+
320325
idf_component_register(INCLUDE_DIRS ${includedirs} PRIV_INCLUDE_DIRS ${priv_includes} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires})
321326

322327
if(NOT CONFIG_FREERTOS_HZ EQUAL 1000 AND NOT "$ENV{ARDUINO_SKIP_TICK_CHECK}")

‎cores/esp32/esp32-hal-touch-ng.c

Lines changed: 453 additions & 0 deletions
Large diffs are not rendered by default.

‎cores/esp32/esp32-hal-touch-ng.h

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
Arduino.h - Main include file for the Arduino SDK
3+
Copyright (c) 2005-2013 Arduino Team. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#ifndef MAIN_ESP32_HAL_TOUCH_NEW_H_
21+
#define MAIN_ESP32_HAL_TOUCH_NEW_H_
22+
23+
#include "soc/soc_caps.h"
24+
#if SOC_TOUCH_SENSOR_SUPPORTED
25+
#if SOC_TOUCH_SENSOR_VERSION == 3 // ESP32P4
26+
27+
#ifdef __cplusplus
28+
extern "C" {
29+
#endif
30+
31+
#include "esp32-hal.h"
32+
33+
typedef uint32_t touch_value_t;
34+
35+
/*
36+
* Set time in us that measurement operation takes
37+
* The result from touchRead, threshold and detection
38+
* accuracy depend on these values.
39+
* Note: must be called before setting up touch pads
40+
**/
41+
void touchSetTiming(float measure, uint32_t sleep);
42+
43+
/*
44+
* Tune the touch pad frequency.
45+
* Note: Must be called before setting up touch pads
46+
*/
47+
void touchSetConfig(uint32_t _div_num, uint8_t coarse_freq_tune, uint8_t fine_freq_tune);
48+
49+
/*
50+
* Read touch pad value.
51+
* You can use this method to chose a good threshold value
52+
* to use as value for touchAttachInterrupt.
53+
* */
54+
touch_value_t touchRead(uint8_t pin);
55+
56+
/*
57+
* Set function to be called if touch pad value rises by given increment (threshold).
58+
* Use touchRead to determine a proper threshold between touched and untouched state.
59+
* */
60+
void touchAttachInterrupt(uint8_t pin, void (*userFunc)(void), touch_value_t threshold);
61+
void touchAttachInterruptArg(uint8_t pin, void (*userFunc)(void *), void *arg, touch_value_t threshold);
62+
void touchDetachInterrupt(uint8_t pin);
63+
64+
/*
65+
* Returns true when the latest ISR status for the Touchpad is that it is touched (Active)
66+
* and false when the Touchpad is untoouched (Inactive).
67+
* This function can be used in conjunction with ISR User callback in order to take action
68+
* as soon as the touchpad is touched and/or released.
69+
**/
70+
bool touchInterruptGetLastStatus(uint8_t pin);
71+
72+
/*
73+
* Set the default threshold for touch pads.
74+
* The threshold is a percentage of the benchmark value.
75+
* The default value is 1.5%.
76+
**/
77+
void touchSetDefaultThreshold(float percentage);
78+
79+
/*
80+
* Setup touch pad wake up from deep sleep /light sleep with given threshold.
81+
* When light sleep is used, all used touch pads will be able to wake up the chip.
82+
**/
83+
void touchSleepWakeUpEnable(uint8_t pin, touch_value_t threshold);
84+
85+
#ifdef __cplusplus
86+
}
87+
#endif
88+
89+
#endif /* SOC_TOUCH_SENSOR_VERSION == 3 */
90+
#endif /* SOC_TOUCH_SENSOR_SUPPORTED */
91+
#endif /* MAIN_ESP32_HAL_TOUCH_H_ */

‎cores/esp32/esp32-hal-touch.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
#include "soc/soc_caps.h"
1515

1616
#if SOC_TOUCH_SENSOR_SUPPORTED
17-
#if SOC_TOUCH_SENSOR_VERSION == 3 // ESP32P4
18-
// ToDo: Implement touch sensor for ESP32P4
19-
#warning "Touch sensor not implemented for ESP32P4 yet"
20-
#else
17+
#if SOC_TOUCH_SENSOR_VERSION <= 2 // ESP32, ESP32S2, ESP32S3
18+
2119
#include "driver/touch_sensor.h"
2220
#include "esp32-hal-touch.h"
2321
#include "esp32-hal-periman.h"
@@ -26,10 +24,10 @@
2624
Internal Private Touch Data Structure and Functions
2725
*/
2826

29-
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
27+
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
3028
static uint16_t __touchSleepCycles = 0x1000;
3129
static uint16_t __touchMeasureCycles = 0x1000;
32-
#elif SOC_TOUCH_SENSOR_VERSION >= 2 // ESP32S2, ESP32S3, ESP32P4
30+
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
3331
static uint16_t __touchSleepCycles = TOUCH_PAD_SLEEP_CYCLE_DEFAULT;
3432
static uint16_t __touchMeasureCycles = TOUCH_PAD_MEASURE_CYCLE_DEFAULT;
3533
#endif
@@ -55,7 +53,7 @@ static bool initialized = false;
5553
static bool channels_initialized[SOC_TOUCH_SENSOR_NUM] = {false};
5654

5755
static void ARDUINO_ISR_ATTR __touchISR(void *arg) {
58-
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
56+
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
5957
uint32_t pad_intr = touch_pad_get_status();
6058
//clear interrupt
6159
touch_pad_clear_status();
@@ -97,7 +95,7 @@ static void ARDUINO_ISR_ATTR __touchISR(void *arg) {
9795
static void __touchSetCycles(uint16_t measure, uint16_t sleep) {
9896
__touchSleepCycles = sleep;
9997
__touchMeasureCycles = measure;
100-
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
98+
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
10199
touch_pad_set_measurement_clock_cycles(measure);
102100
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
103101
touch_pad_set_charge_discharge_times(measure);
@@ -127,7 +125,7 @@ static void __touchInit() {
127125

128126
esp_err_t err = ESP_OK;
129127

130-
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
128+
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
131129
err = touch_pad_init();
132130
if (err != ESP_OK) {
133131
goto err;
@@ -147,7 +145,7 @@ static void __touchInit() {
147145
if (err != ESP_OK) {
148146
goto err;
149147
}
150-
touch_pad_intr_enable(); // returns ESP_OK
148+
touch_pad_intr_enable(); // returns ESP_OK
151149
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
152150
err = touch_pad_init();
153151
if (err != ESP_OK) {
@@ -169,7 +167,6 @@ static void __touchInit() {
169167
touch_pad_fsm_start(); // returns ESP_OK
170168
//ISR setup moved to __touchChannelInit
171169
#endif
172-
173170
initialized = true;
174171
return;
175172
err:
@@ -183,11 +180,11 @@ static void __touchChannelInit(int pad) {
183180
return;
184181
}
185182

186-
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
183+
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
187184
// Initial no Threshold and setup
188185
__touchInterruptHandlers[pad].fn = NULL;
189186
touch_pad_config(pad, TOUCH_PAD_THRESHOLD_MAX); // returns ESP_OK
190-
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
187+
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
191188
// Initial no Threshold and setup
192189
__touchInterruptHandlers[pad].fn = NULL;
193190
touch_pad_config(pad); // returns ESP_OK
@@ -274,7 +271,7 @@ static void __touchDettachInterrupt(uint8_t pin) {
274271
External Public Touch API Functions
275272
*/
276273

277-
#if SOC_TOUCH_SENSOR_VERSION == 1 // Only for ESP32 SoC
274+
#if SOC_TOUCH_SENSOR_VERSION == 1 // Only for ESP32 SoC
278275
void touchInterruptSetThresholdDirection(bool mustbeLower) {
279276
if (mustbeLower) {
280277
touch_pad_set_trigger_mode(TOUCH_TRIGGER_BELOW);
@@ -328,5 +325,5 @@ extern void touchAttachInterruptArg(uint8_t, voidArgFuncPtr, void *, touch_value
328325
extern void touchDetachInterrupt(uint8_t) __attribute__((weak, alias("__touchDettachInterrupt")));
329326
extern void touchSetCycles(uint16_t, uint16_t) __attribute__((weak, alias("__touchSetCycles")));
330327

331-
#endif /* SOC_TOUCH_SENSOR_VERSION == 3 */
328+
#endif /* SOC_TOUCH_SENSOR_VERSION <= 2 */
332329
#endif /* SOC_TOUCH_SENSOR_SUPPORTED */

‎cores/esp32/esp32-hal-touch.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "soc/soc_caps.h"
2424
#if SOC_TOUCH_SENSOR_SUPPORTED
25+
#if SOC_TOUCH_SENSOR_VERSION <= 2 // ESP32 ESP32S2 ESP32S3
2526

2627
#ifdef __cplusplus
2728
extern "C" {
@@ -37,8 +38,6 @@ extern "C" {
3738
typedef uint16_t touch_value_t;
3839
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2 ESP32S3
3940
typedef uint32_t touch_value_t;
40-
#elif SOC_TOUCH_SENSOR_VERSION == 3 // ESP32P4
41-
typedef uint32_t touch_value_t;
4241
#endif
4342

4443
/*
@@ -99,5 +98,6 @@ void touchSleepWakeUpEnable(uint8_t pin, touch_value_t threshold);
9998
}
10099
#endif
101100

101+
#endif /* SOC_TOUCH_SENSOR_VERSION <= 2 */
102102
#endif /* SOC_TOUCH_SENSOR_SUPPORTED */
103103
#endif /* MAIN_ESP32_HAL_TOUCH_H_ */

‎cores/esp32/esp32-hal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ void yield(void);
7474
#include "esp32-hal-uart.h"
7575
#include "esp32-hal-gpio.h"
7676
#include "esp32-hal-touch.h"
77+
#include "esp32-hal-touch-ng.h"
7778
#include "esp32-hal-dac.h"
7879
#include "esp32-hal-adc.h"
7980
#include "esp32-hal-spi.h"

‎cores/esp32/io_pin_remap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ int8_t gpioNumberToDigitalPin(int8_t gpioNumber);
106106
#define spiAttachMOSI(spi, mosi) spiAttachMOSI(spi, digitalPinToGPIONumber(mosi))
107107
#define spiAttachSS(spi, cs_num, ss) spiAttachSS(spi, cs_num, digitalPinToGPIONumber(ss))
108108

109-
// cores/esp32/esp32-hal-touch.h
109+
// cores/esp32/esp32-hal-touch.h && cores/esp32/esp32-hal-touch-ng.h
110110
#define touchInterruptGetLastStatus(pin) touchInterruptGetLastStatus(digitalPinToGPIONumber(pin))
111111
#define touchRead(pin) touchRead(digitalPinToGPIONumber(pin))
112112
#define touchAttachInterruptArg(pin, userFunc, arg, threshold) touchAttachInterruptArg(digitalPinToGPIONumber(pin), userFunc, arg, threshold)

‎libraries/ESP32/examples/DeepSleep/TouchWakeUp/TouchWakeUp.ino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ Pranav Cherukupalli <cherukupallip@gmail.com>
1515
*/
1616

1717
#if CONFIG_IDF_TARGET_ESP32
18-
#define THRESHOLD 40 /* Greater the value, more the sensitivity */
19-
#else //ESP32-S2 and ESP32-S3 + default for other chips (to be adjusted) */
18+
#define THRESHOLD 40 /* Greater the value, more the sensitivity */
19+
#elif (CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3)
2020
#define THRESHOLD 5000 /* Lower the value, more the sensitivity */
21+
#else // ESP32-P4 + default for other chips (to be adjusted) */
22+
#define THRESHOLD 500 /* Lower the value, more the sensitivity */
2123
#endif
2224

2325
RTC_DATA_ATTR int bootCount = 0;
@@ -88,7 +90,7 @@ void setup() {
8890
touchSleepWakeUpEnable(T3, THRESHOLD);
8991
touchSleepWakeUpEnable(T7, THRESHOLD);
9092

91-
#else //ESP32-S2 + ESP32-S3
93+
#else //ESP32-S2 + ESP32-S3 + ESP32-P4
9294
//Setup sleep wakeup on Touch Pad 3 (GPIO3)
9395
touchSleepWakeUpEnable(T3, THRESHOLD);
9496

‎libraries/ESP32/examples/DeepSleep/TouchWakeUp/ci.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"targets": {
33
"esp32c3": false,
44
"esp32c6": false,
5-
"esp32h2": false,
6-
"esp32p4": false
5+
"esp32h2": false
76
}
87
}

‎libraries/ESP32/examples/Touch/TouchInterrupt/TouchInterrupt.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ This is an example how to use Touch Intrrerupts
33
The bigger the threshold, the more sensible is the touch
44
*/
55

6+
#if CONFIG_IDF_TARGET_ESP32P4
7+
int threshold = 0; // when 0 is used, the benchmarked value will be used
8+
#else
69
int threshold = 40;
10+
#endif
11+
712
bool touch1detected = false;
813
bool touch2detected = false;
914

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
22
"requires": [
33
"CONFIG_SOC_TOUCH_SENSOR_SUPPORTED=y"
4-
],
5-
"targets": {
6-
"esp32p4": false
7-
}
4+
]
85
}
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
22
"requires": [
33
"CONFIG_SOC_TOUCH_SENSOR_SUPPORTED=y"
4-
],
5-
"targets": {
6-
"esp32p4": false
7-
}
4+
]
85
}

‎tests/validation/touch/ci.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,5 @@
55
},
66
"requires": [
77
"CONFIG_SOC_TOUCH_SENSOR_SUPPORTED=y"
8-
],
9-
"targets": {
10-
"esp32p4": false
11-
}
8+
]
129
}

‎tests/validation/touch/touch.ino

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
#include "soc/soc_caps.h"
33
#include "driver/touch_pad.h"
44

5+
#if SOC_TOUCH_SENSOR_VERSION == 3
6+
#include "hal/touch_sensor_ll.h"
7+
#endif
8+
59
#if CONFIG_IDF_TARGET_ESP32
610

711
#define TEST_TOUCH_CHANNEL (9)
@@ -15,11 +19,7 @@ uint8_t TOUCH_GPIOS[] = {4, 2, 15, 13, 12, 14, 27, 33, 32};
1519

1620
#define NO_TOUCH_GPIO 25
1721

18-
#define RELEASED_VALUE 75 //75+ read value to pass test
19-
#define PRESSED_VALUE 20 //20- read value to pass test
20-
#define INTERRUPT_THRESHOLD 40
21-
22-
#else //ESP32S2 and ESP32S3
22+
#elif (CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3)
2323

2424
#define TEST_TOUCH_CHANNEL (12) //14
2525
static touch_pad_t touch_list[TEST_TOUCH_CHANNEL] = {
@@ -33,20 +33,39 @@ uint8_t TOUCH_GPIOS[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 /*,13,14*/};
3333

3434
#define NO_TOUCH_GPIO 17
3535

36-
#if CONFIG_IDF_TARGET_ESP32S2
36+
#else //ESP32P4
37+
38+
#define TEST_TOUCH_CHANNEL (5) //14
39+
static touch_pad_t touch_list[TEST_TOUCH_CHANNEL] = {
40+
TOUCH_PAD_NUM0, TOUCH_PAD_NUM1, TOUCH_PAD_NUM2,
41+
TOUCH_PAD_NUM3, TOUCH_PAD_NUM4, /* TOUCH_PAD_NUM5, TOUCH_PAD_NUM6,
42+
TOUCH_PAD_NUM7, TOUCH_PAD_NUM8, TOUCH_PAD_NUM9, TOUCH_PAD_NUM10, TOUCH_PAD_NUM11, TOUCH_PAD_NUM12, TOUCH_PAD_NUM13*/
43+
};
44+
45+
uint8_t TOUCH_GPIOS[] = {2, 3, 4, 5, 6 /*, 7, 8, 9, 10, 11, 12 ,13, 14, 15*/};
46+
47+
#define NO_TOUCH_GPIO 17
48+
#endif
49+
50+
#if CONFIG_IDF_TARGET_ESP32
51+
#define RELEASED_VALUE 75 //75+ read value to pass test
52+
#define PRESSED_VALUE 20 //20- read value to pass test
53+
#define INTERRUPT_THRESHOLD 40
54+
#elif CONFIG_IDF_TARGET_ESP32S2
3755
#define RELEASED_VALUE 10000 //10000- read value to pass test
3856
#define PRESSED_VALUE 42000 //40000+ read value to pass test
3957
#define INTERRUPT_THRESHOLD 30000
4058
#elif CONFIG_IDF_TARGET_ESP32S3
4159
#define RELEASED_VALUE 25000 //25000- read value to pass test
4260
#define PRESSED_VALUE 90000 //90000+ read value to pass test
4361
#define INTERRUPT_THRESHOLD 80000
62+
#elif CONFIG_IDF_TARGET_ESP32P4
63+
#define PRESSED_VALUE_DIFFERENCE 200 //200+ read value difference against the unpressed value
64+
#define INTERRUPT_THRESHOLD 0 // Use benchmarked threshold
4465
#else
4566
#error Test not currently supported on this chip. Please adjust and try again!
4667
#endif
4768

48-
#endif
49-
5069
bool touch1detected = false;
5170
bool touch2detected = false;
5271

@@ -59,17 +78,25 @@ void gotTouch2() {
5978
}
6079

6180
/*
62-
* Change the slope to get larger value from touch sensor.
81+
* Change the slope to get larger value from touch sensor. (Capacitor for ESP32P4)
6382
*/
6483
static void test_press_fake(touch_pad_t pad_num) {
84+
#if SOC_TOUCH_SENSOR_VERSION <= 2
6585
touch_pad_set_cnt_mode(pad_num, TOUCH_PAD_SLOPE_1, TOUCH_PAD_TIE_OPT_DEFAULT);
86+
#else
87+
touch_ll_set_internal_capacitor(0x7f);
88+
#endif
6689
}
6790

6891
/*
69-
* Change the slope to get smaller value from touch sensor.
92+
* Change the slope to get smaller value from touch sensor. (Capacitor for ESP32P4)
7093
*/
7194
static void test_release_fake(touch_pad_t pad_num) {
95+
#if SOC_TOUCH_SENSOR_VERSION <= 2
7296
touch_pad_set_cnt_mode(pad_num, TOUCH_PAD_SLOPE_7, TOUCH_PAD_TIE_OPT_DEFAULT);
97+
#else
98+
touch_ll_set_internal_capacitor(0);
99+
#endif
73100
}
74101

75102
/* These functions are intended to be called before and after each test. */
@@ -87,6 +114,7 @@ void tearDown(void) {
87114
*/
88115
void test_touch_read(void) {
89116

117+
#if SOC_TOUCH_SENSOR_VERSION <= 2
90118
//TEST RELEASE STATE
91119
for (int i = 0; i < sizeof(TOUCH_GPIOS); i++) {
92120
#ifdef CONFIG_IDF_TARGET_ESP32
@@ -109,6 +137,29 @@ void test_touch_read(void) {
109137
TEST_ASSERT_GREATER_THAN(PRESSED_VALUE, touchRead(TOUCH_GPIOS[k]));
110138
#endif
111139
}
140+
#else //TOUCH V3
141+
//TEST RELEASE STATE
142+
touch_value_t touch_unpressed[sizeof(TOUCH_GPIOS)];
143+
for (int i = 0; i < sizeof(TOUCH_GPIOS); i++) {
144+
touch_unpressed[i] = touchRead(TOUCH_GPIOS[i]);
145+
}
146+
147+
// TEST PRESS STATE
148+
for (int j = 0; j < TEST_TOUCH_CHANNEL; j++) {
149+
test_press_fake(touch_list[j]);
150+
}
151+
delay(100);
152+
153+
touch_value_t touch_pressed[sizeof(TOUCH_GPIOS)];
154+
for (int k = 0; k < sizeof(TOUCH_GPIOS); k++) {
155+
touch_pressed[k] = touchRead(TOUCH_GPIOS[k]);
156+
}
157+
158+
// COMPARE PRESSED > UNPRESSED
159+
for (int l = 0; l < sizeof(TOUCH_GPIOS); l++) {
160+
TEST_ASSERT_GREATER_THAN((touch_unpressed[l] + PRESSED_VALUE_DIFFERENCE), touch_pressed[l]);
161+
}
162+
#endif
112163
}
113164

114165
void test_touch_interrtupt(void) {
@@ -146,4 +197,6 @@ void setup() {
146197
UNITY_END();
147198
}
148199

149-
void loop() {}
200+
void loop() {
201+
delay(10);
202+
}

0 commit comments

Comments
 (0)
Please sign in to comment.