@@ -43,21 +43,14 @@ uint8_t TOUCH_GPIOS[] = {2, 3, 4, 5, 6 /*, 7, 8, 9, 10, 11, 12 ,13, 14, 15*/};
43
43
#define NO_TOUCH_GPIO 17
44
44
#endif
45
45
46
+ #define INTERRUPT_THRESHOLD 0 // Use benchmarked threshold
47
+
46
48
#if CONFIG_IDF_TARGET_ESP32
47
- #define RELEASED_VALUE 75 // 75+ read value to pass test
48
- #define PRESSED_VALUE 20 // 20- read value to pass test
49
- #define INTERRUPT_THRESHOLD 40
50
- #elif CONFIG_IDF_TARGET_ESP32S2
51
- #define RELEASED_VALUE 10000 // 10000- read value to pass test
52
- #define PRESSED_VALUE 42000 // 40000+ read value to pass test
53
- #define INTERRUPT_THRESHOLD 30000
54
- #elif CONFIG_IDF_TARGET_ESP32S3
55
- #define RELEASED_VALUE 25000 // 25000- read value to pass test
56
- #define PRESSED_VALUE 90000 // 90000+ read value to pass test
57
- #define INTERRUPT_THRESHOLD 80000
58
- #elif CONFIG_IDF_TARGET_ESP32P4
49
+ #define PRESSED_VALUE_DIFFERENCE 200 // -200 read value difference against the unpressed value
50
+ #elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32S2
51
+ #define PRESSED_VALUE_DIFFERENCE 2000 // 2000+ read value difference against the unpressed value
52
+ #elif CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
59
53
#define PRESSED_VALUE_DIFFERENCE 200 // 200+ read value difference against the unpressed value
60
- #define INTERRUPT_THRESHOLD 0 // Use benchmarked threshold
61
54
#else
62
55
#error Test not currently supported on this chip. Please adjust and try again!
63
56
#endif
@@ -109,31 +102,6 @@ void tearDown(void) {
109
102
* Test Touch read on all available channels - compare values if reading is right
110
103
*/
111
104
void test_touch_read (void ) {
112
-
113
- #if SOC_TOUCH_SENSOR_VERSION <= 2
114
- // TEST RELEASE STATE
115
- for (int i = 0 ; i < sizeof (TOUCH_GPIOS); i++) {
116
- #ifdef CONFIG_IDF_TARGET_ESP32
117
- TEST_ASSERT_GREATER_THAN (RELEASED_VALUE, touchRead (TOUCH_GPIOS[i]));
118
- #else
119
- TEST_ASSERT_LESS_THAN (RELEASED_VALUE, touchRead (TOUCH_GPIOS[i]));
120
- #endif
121
- }
122
-
123
- // TEST PRESS STATE
124
- for (int j = 0 ; j < TEST_TOUCH_CHANNEL; j++) {
125
- test_press_fake (touch_list[j]);
126
- }
127
- delay (100 );
128
-
129
- for (int k = 0 ; k < sizeof (TOUCH_GPIOS); k++) {
130
- #ifdef CONFIG_IDF_TARGET_ESP32
131
- TEST_ASSERT_LESS_THAN (PRESSED_VALUE, touchRead (TOUCH_GPIOS[k]));
132
- #else
133
- TEST_ASSERT_GREATER_THAN (PRESSED_VALUE, touchRead (TOUCH_GPIOS[k]));
134
- #endif
135
- }
136
- #else // TOUCH V3
137
105
// TEST RELEASE STATE
138
106
touch_value_t touch_unpressed[sizeof (TOUCH_GPIOS)];
139
107
for (int i = 0 ; i < sizeof (TOUCH_GPIOS); i++) {
@@ -151,11 +119,14 @@ void test_touch_read(void) {
151
119
touch_pressed[k] = touchRead (TOUCH_GPIOS[k]);
152
120
}
153
121
154
- // COMPARE PRESSED > UNPRESSED
122
+ // COMPARE PRESSED <- > UNPRESSED
155
123
for (int l = 0 ; l < sizeof (TOUCH_GPIOS); l++) {
124
+ #if CONFIG_IDF_TARGET_ESP32
125
+ TEST_ASSERT_LESS_THAN ((touch_unpressed[l] - PRESSED_VALUE_DIFFERENCE), touch_pressed[l]);
126
+ #else
156
127
TEST_ASSERT_GREATER_THAN ((touch_unpressed[l] + PRESSED_VALUE_DIFFERENCE), touch_pressed[l]);
157
- }
158
128
#endif
129
+ }
159
130
}
160
131
161
132
void test_touch_interrtupt (void ) {
@@ -166,7 +137,6 @@ void test_touch_interrtupt(void) {
166
137
test_press_fake (touch_list[0 ]);
167
138
test_press_fake (touch_list[1 ]);
168
139
169
- delay (300 );
170
140
171
141
touchDetachInterrupt (TOUCH_GPIOS[0 ]);
172
142
touchDetachInterrupt (TOUCH_GPIOS[1 ]);
0 commit comments