Skip to content

Commit 04459fa

Browse files
committed
fix(touch): Update test and example
1 parent f691a42 commit 04459fa

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ set(CORE_SRCS
4646
cores/esp32/esp32-hal-time.c
4747
cores/esp32/esp32-hal-timer.c
4848
cores/esp32/esp32-hal-tinyusb.c
49+
cores/esp32/esp32-hal-touch.c
4950
cores/esp32/esp32-hal-touch-ng.c
5051
cores/esp32/esp32-hal-uart.c
5152
cores/esp32/esp32-hal-rmt.c

libraries/ESP32/examples/Touch/TouchButton/TouchButton.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void setup() {
2929

3030
//Set the touch pads
3131
Serial.println("\n ESP32 Touch Interrupt Test\n");
32-
touchAttachInterrupt(T0, gotTouch1, threshold);
32+
touchAttachInterrupt(T1, gotTouch1, threshold);
3333
touchAttachInterrupt(T2, gotTouch2, threshold);
3434
}
3535

tests/validation/touch/touch.ino

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,30 @@
44

55
#if CONFIG_IDF_TARGET_ESP32
66

7-
#define TEST_TOUCH_CHANNEL (9)
7+
#define TEST_TOUCH_CHANNEL (7)
88
static touch_pad_t touch_list[TEST_TOUCH_CHANNEL] = {
99
TOUCH_PAD_NUM0,
1010
//TOUCH_PAD_NUM1 is GPIO0, for download.
11-
TOUCH_PAD_NUM2, TOUCH_PAD_NUM3, TOUCH_PAD_NUM4, TOUCH_PAD_NUM5, TOUCH_PAD_NUM6, TOUCH_PAD_NUM7, TOUCH_PAD_NUM8, TOUCH_PAD_NUM9
11+
TOUCH_PAD_NUM2, TOUCH_PAD_NUM3, TOUCH_PAD_NUM4, TOUCH_PAD_NUM5, TOUCH_PAD_NUM6, TOUCH_PAD_NUM7 /*,TOUCH_PAD_NUM8, TOUCH_PAD_NUM9*/
1212
};
1313

14-
uint8_t TOUCH_GPIOS[] = {4, 2, 15, 13, 12, 14, 27, 33, 32};
14+
uint8_t TOUCH_GPIOS[] = {4,/* 0,*/ 2, 15, 13, 12, 14, 27/*, 33, 32*/};
1515

1616
#define NO_TOUCH_GPIO 25
1717

1818
#elif (CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3)
1919

20-
#define TEST_TOUCH_CHANNEL (12) //14
20+
#define TEST_TOUCH_CHANNEL (9) //14
2121
static touch_pad_t touch_list[TEST_TOUCH_CHANNEL] = {
2222
TOUCH_PAD_NUM1, TOUCH_PAD_NUM2, TOUCH_PAD_NUM3, TOUCH_PAD_NUM4, TOUCH_PAD_NUM5, TOUCH_PAD_NUM6, TOUCH_PAD_NUM7,
23-
TOUCH_PAD_NUM8, TOUCH_PAD_NUM9, TOUCH_PAD_NUM10, TOUCH_PAD_NUM11, TOUCH_PAD_NUM12
23+
TOUCH_PAD_NUM8, /*TOUCH_PAD_NUM9,*/ TOUCH_PAD_NUM10
24+
//TOUCH_PAD_NUM11, //Wrong reading
25+
//TOUCH_PAD_NUM12, //Wrong reading
2426
//TOUCH_PAD_NUM13, //Wrong reading
2527
//TOUCH_PAD_NUM14
2628
};
2729

28-
uint8_t TOUCH_GPIOS[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 /*,13,14*/};
30+
uint8_t TOUCH_GPIOS[] = {1, 2, 3, 4, 5, 6, 7, 8,/*9,*/ 10/*, 11, 12, 13, 14*/};
2931

3032
#define NO_TOUCH_GPIO 17
3133

@@ -120,6 +122,9 @@ void test_touch_read(void) {
120122
}
121123

122124
// COMPARE PRESSED <-> UNPRESSED
125+
for (int l = 0; l < sizeof(TOUCH_GPIOS); l++) {
126+
log_v("Touch %d: %d -> %d", TOUCH_GPIOS[l], touch_unpressed[l], touch_pressed[l]);
127+
}
123128
for (int l = 0; l < sizeof(TOUCH_GPIOS); l++) {
124129
#if CONFIG_IDF_TARGET_ESP32
125130
TEST_ASSERT_LESS_THAN((touch_unpressed[l] - PRESSED_VALUE_DIFFERENCE), touch_pressed[l]);

0 commit comments

Comments
 (0)