Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6b91048

Browse files
ci(pre-commit): Apply automatic fixes
1 parent 0dccd26 commit 6b91048

File tree

5 files changed

+52
-58
lines changed

5 files changed

+52
-58
lines changed

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

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ typedef struct {
3737
static TouchInterruptHandle_t __touchInterruptHandlers[SOC_TOUCH_SENSOR_NUM] = {
3838
0,
3939
};
40-
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
41-
static uint8_t _sample_num = 1; // only one sample configuration supported
40+
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
41+
static uint8_t _sample_num = 1; // only one sample configuration supported
4242
static float _duration_ms = 5.0f;
4343
static touch_volt_lim_l_t _volt_low = TOUCH_VOLT_LIM_L_0V5;
4444
static touch_volt_lim_h_t _volt_high = TOUCH_VOLT_LIM_H_1V7;
4545
static touch_intr_trig_mode_t _intr_trig_mode = TOUCH_INTR_TRIG_ON_BELOW_THRESH;
46-
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
47-
static uint8_t _sample_num = 1; // only one sample configuration supported
46+
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
47+
static uint8_t _sample_num = 1; // only one sample configuration supported
4848
static uint32_t _chg_times = 500;
4949
static touch_volt_lim_l_t _volt_low = TOUCH_VOLT_LIM_L_0V5;
5050
static touch_volt_lim_h_t _volt_high = TOUCH_VOLT_LIM_H_2V2;
51-
#elif SOC_TOUCH_SENSOR_VERSION == 3 // ESP32P4
52-
static uint8_t _sample_num = 1; // TODO: can be extended to multiple samples
51+
#elif SOC_TOUCH_SENSOR_VERSION == 3 // ESP32P4
52+
static uint8_t _sample_num = 1; // TODO: can be extended to multiple samples
5353
static uint32_t _div_num = 1;
5454
static uint8_t _coarse_freq_tune = 1;
5555
static uint8_t _fine_freq_tune = 1;
@@ -169,27 +169,27 @@ bool touchBenchmarkThreshold(uint8_t pad) {
169169

170170
// Reconfigure passed pad with new threshold
171171
uint32_t benchmark[_sample_num] = {};
172-
#if SOC_TOUCH_SUPPORT_BENCHMARK // ESP32S2, ESP32S3,ESP32P4
172+
#if SOC_TOUCH_SUPPORT_BENCHMARK // ESP32S2, ESP32S3,ESP32P4
173173
if (touch_channel_read_data(touch_channel_handle[pad], TOUCH_CHAN_DATA_TYPE_BENCHMARK, benchmark) != ESP_OK) {
174174
log_e("Touch channel read data failed!");
175175
return false;
176176
}
177-
#else
177+
#else
178178
if (touch_channel_read_data(touch_channel_handle[pad], TOUCH_CHAN_DATA_TYPE_SMOOTH, benchmark) != ESP_OK) {
179179
log_e("Touch channel read data failed!");
180180
return false;
181181
}
182-
#endif
182+
#endif
183183

184184
/* Calculate the proper active thresholds regarding the initial benchmark */
185185
touch_channel_config_t chan_cfg = TOUCH_CHANNEL_DEFAULT_CONFIG();
186186
for (int i = 0; i < _sample_num; i++) {
187-
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
187+
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
188188
chan_cfg.abs_active_thresh[i] = (uint32_t)(benchmark[i] * (1 - s_thresh2bm_ratio));
189-
log_v("Configured [CH %d] sample %d: benchmark = %"PRIu32", threshold = %"PRIu32"\t", pad, i, benchmark[i], chan_cfg.abs_active_thresh[i]);
189+
log_v("Configured [CH %d] sample %d: benchmark = %"PRIu32", threshold = %"PRIu32"\t", pad, i, benchmark[i], chan_cfg.abs_active_thresh[i]);
190190
#else
191191
chan_cfg.active_thresh[i] = (uint32_t)(benchmark[i] * s_thresh2bm_ratio);
192-
log_v("Configured [CH %d] sample %d: benchmark = %"PRIu32", threshold = %"PRIu32"\t", pad, i, benchmark[i], chan_cfg.active_thresh[i]);
192+
log_v("Configured [CH %d] sample %d: benchmark = %"PRIu32", threshold = %"PRIu32"\t", pad, i, benchmark[i], chan_cfg.active_thresh[i]);
193193
#endif
194194
}
195195
/* Update the channel configuration */
@@ -221,8 +221,7 @@ static bool touchDetachBus(void *pin) {
221221
return false;
222222
}
223223
initialized = false;
224-
}
225-
else {
224+
} else {
226225
touchEnable();
227226
touchStart();
228227
}
@@ -234,31 +233,31 @@ static void __touchInit() {
234233
return;
235234
}
236235
// Support only one sample configuration for now
237-
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
236+
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
238237
touch_sensor_sample_config_t single_sample_cfg = TOUCH_SENSOR_V1_DEFAULT_SAMPLE_CONFIG(_duration_ms, _volt_low, _volt_high);
239-
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
238+
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
240239
touch_sensor_sample_config_t single_sample_cfg = TOUCH_SENSOR_V2_DEFAULT_SAMPLE_CONFIG(_chg_times, _volt_low, _volt_high);
241-
#elif SOC_TOUCH_SENSOR_VERSION == 3 // ESP32P4
240+
#elif SOC_TOUCH_SENSOR_VERSION == 3 // ESP32P4
242241
touch_sensor_sample_config_t single_sample_cfg = TOUCH_SENSOR_V3_DEFAULT_SAMPLE_CONFIG(_div_num, _coarse_freq_tune, _fine_freq_tune);
243242
#endif
244243
touch_sensor_sample_config_t sample_cfg[_sample_num] = {};
245244
sample_cfg[0] = single_sample_cfg;
246245

247246
touch_sensor_config_t sens_cfg = {
248-
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
247+
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
249248
.power_on_wait_us = __touchSleepTime,
250249
.meas_interval_us = __touchMeasureTime,
251250
.intr_trig_mode = _intr_trig_mode,
252251
.intr_trig_group = TOUCH_INTR_TRIG_GROUP_BOTH,
253252
.sample_cfg_num = _sample_num,
254253
.sample_cfg = sample_cfg,
255-
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
254+
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
256255
.power_on_wait_us = __touchSleepTime,
257256
.meas_interval_us = __touchMeasureTime,
258257
.max_meas_time_us = 0,
259258
.sample_cfg_num = _sample_num,
260259
.sample_cfg = sample_cfg,
261-
#elif SOC_TOUCH_SENSOR_VERSION == 3 // ESP32P4
260+
#elif SOC_TOUCH_SENSOR_VERSION == 3 // ESP32P4
262261
.power_on_wait_us = __touchSleepTime,
263262
.meas_interval_us = __touchMeasureTime,
264263
.max_meas_time_us = 0,
@@ -305,7 +304,7 @@ static void __touchChannelInit(int pad) {
305304
__touchInterruptHandlers[pad].fn = NULL;
306305

307306
touch_channel_config_t chan_cfg = TOUCH_CHANNEL_DEFAULT_CONFIG();
308-
307+
309308
if (!touchStop() || !touchDisable()) {
310309
log_e("Touch sensor stop and disable failed!");
311310
return;
@@ -400,7 +399,7 @@ static void __touchConfigInterrupt(uint8_t pin, void (*userFunc)(void), void *Ar
400399

401400
touch_channel_config_t chan_cfg = {};
402401
for (int i = 0; i < _sample_num; i++) {
403-
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
402+
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
404403
chan_cfg.abs_active_thresh[i] = threshold;
405404
#else
406405
chan_cfg.active_thresh[i] = threshold;
@@ -470,9 +469,9 @@ void touchSleepWakeUpEnable(uint8_t pin, touch_value_t threshold) {
470469

471470
touch_sleep_config_t deep_slp_cfg = {
472471
.slp_wakeup_lvl = TOUCH_DEEP_SLEEP_WAKEUP,
473-
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
474-
.deep_slp_sens_cfg = NULL, // Use the original touch sensor configuration
475-
#else // SOC_TOUCH_SENSOR_VERSION 2 and 3// ESP32S2, ESP32S3, ESP32P4
472+
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
473+
.deep_slp_sens_cfg = NULL, // Use the original touch sensor configuration
474+
#else // SOC_TOUCH_SENSOR_VERSION 2 and 3// ESP32S2, ESP32S3, ESP32P4
476475
.deep_slp_chan = touch_channel_handle[pad],
477476
.deep_slp_thresh = {threshold},
478477
.deep_slp_sens_cfg = NULL, // Use the original touch sensor configuration
@@ -503,7 +502,7 @@ void touchSetTiming(float measure, uint32_t sleep) {
503502
__touchMeasureTime = measure;
504503
}
505504

506-
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
505+
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
507506
void touchSetConfig(float duration_ms, touch_volt_lim_l_t volt_low, touch_volt_lim_h_t volt_high) {
508507
if (initialized) {
509508
log_e("Touch sensor already initialized. Cannot set configuration.");
@@ -514,7 +513,7 @@ void touchSetConfig(float duration_ms, touch_volt_lim_l_t volt_low, touch_volt_l
514513
_volt_high = volt_high;
515514
}
516515

517-
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
516+
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
518517
void touchSetConfig(uint32_t chg_times, touch_volt_lim_l_t volt_low, touch_volt_lim_h_t volt_high) {
519518
if (initialized) {
520519
log_e("Touch sensor already initialized. Cannot set configuration.");
@@ -525,7 +524,7 @@ void touchSetConfig(uint32_t chg_times, touch_volt_lim_l_t volt_low, touch_volt_
525524
_volt_high = volt_high;
526525
}
527526

528-
#elif SOC_TOUCH_SENSOR_VERSION == 3 // ESP32P4
527+
#elif SOC_TOUCH_SENSOR_VERSION == 3 // ESP32P4
529528
void touchSetConfig(uint32_t div_num, uint8_t coarse_freq_tune, uint8_t fine_freq_tune) {
530529
if (initialized) {
531530
log_e("Touch sensor already initialized. Cannot set configuration.");
@@ -537,7 +536,7 @@ void touchSetConfig(uint32_t div_num, uint8_t coarse_freq_tune, uint8_t fine_fre
537536
}
538537
#endif
539538

540-
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
539+
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
541540
void touchInterruptSetThresholdDirection(bool mustbeLower) {
542541
if (mustbeLower) {
543542
_intr_trig_mode = TOUCH_INTR_TRIG_ON_BELOW_THRESH;

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

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,18 @@ extern "C" {
3333
#include "esp32-hal.h"
3434
#include "driver/touch_sens.h"
3535

36-
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
37-
#define TOUCH_CHANNEL_DEFAULT_CONFIG() { \
38-
.abs_active_thresh = {1000}, \
39-
.charge_speed = TOUCH_CHARGE_SPEED_7, \
40-
.init_charge_volt = TOUCH_INIT_CHARGE_VOLT_DEFAULT, \
41-
.group = TOUCH_CHAN_TRIG_GROUP_BOTH, \
42-
}
43-
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32-S2 & ESP32-S3
44-
#define TOUCH_CHANNEL_DEFAULT_CONFIG() { \
45-
.active_thresh = {2000}, \
46-
.charge_speed = TOUCH_CHARGE_SPEED_7, \
47-
.init_charge_volt = TOUCH_INIT_CHARGE_VOLT_DEFAULT, \
48-
}
49-
#elif SOC_TOUCH_SENSOR_VERSION == 3 // ESP32-P4
50-
#define TOUCH_CHANNEL_DEFAULT_CONFIG() { \
51-
.active_thresh = {1000}, \
52-
}
36+
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
37+
#define TOUCH_CHANNEL_DEFAULT_CONFIG() \
38+
{ \
39+
.abs_active_thresh = {1000}, .charge_speed = TOUCH_CHARGE_SPEED_7, .init_charge_volt = TOUCH_INIT_CHARGE_VOLT_DEFAULT, \
40+
.group = TOUCH_CHAN_TRIG_GROUP_BOTH, \
41+
}
42+
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32-S2 & ESP32-S3
43+
#define TOUCH_CHANNEL_DEFAULT_CONFIG() \
44+
{ .active_thresh = {2000}, .charge_speed = TOUCH_CHARGE_SPEED_7, .init_charge_volt = TOUCH_INIT_CHARGE_VOLT_DEFAULT, }
45+
#elif SOC_TOUCH_SENSOR_VERSION == 3 // ESP32-P4
46+
#define TOUCH_CHANNEL_DEFAULT_CONFIG() \
47+
{ .active_thresh = {1000}, }
5348
#endif
5449

5550
typedef uint32_t touch_value_t;
@@ -62,23 +57,23 @@ typedef uint32_t touch_value_t;
6257
**/
6358
void touchSetTiming(float measure, uint32_t sleep);
6459

65-
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
60+
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
6661
/*
6762
* @param[in] duration_ms The measurement duration of the touch channel
6863
* @param[in] volt_low The low voltage limit of the touch channel
6964
* @param[in] volt_high The high voltage limit of the touch channel
7065
*/
7166
void touchSetConfig(float duration_ms, touch_volt_lim_l_t volt_low, touch_volt_lim_h_t volt_high);
7267

73-
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
68+
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
7469
/*
7570
* @param[in] chg_times The charge times of the touch channel
7671
* @param[in] volt_low The low voltage limit of the touch channel
7772
* @param[in] volt_high The high voltage limit of the touch channel
7873
*/
7974
void touchSetConfig(uint32_t chg_times, touch_volt_lim_l_t volt_low, touch_volt_lim_h_t volt_high);
8075

81-
#elif SOC_TOUCH_SENSOR_VERSION == 3 // ESP32P4
76+
#elif SOC_TOUCH_SENSOR_VERSION == 3 // ESP32P4
8277
/*
8378
* Tune the touch pad frequency.
8479
* Note: Must be called before setting up touch pads

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,4 +327,4 @@ extern void touchDetachInterrupt(uint8_t) __attribute__((weak, alias("__touchDet
327327
extern void touchSetCycles(uint16_t, uint16_t) __attribute__((weak, alias("__touchSetCycles")));
328328

329329
#endif /* ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 5, 0) && SOC_TOUCH_SENSOR_VERSION <= 2 */
330-
#endif /* SOC_TOUCH_SENSOR_SUPPORTED */
330+
#endif /* SOC_TOUCH_SENSOR_SUPPORTED */

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

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

2323
//Optional: Set the threshold to 5% of the benchmark value. Only effective if threshold = 0.
2424
touchSetDefaultThreshold(5);
25-
25+
2626
Serial.println("ESP32 Touch Interrupt Test");
2727
touchAttachInterrupt(T2, gotTouch1, threshold);
2828
touchAttachInterrupt(T3, gotTouch2, threshold);

‎tests/validation/touch/touch.ino‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44

55
#if CONFIG_IDF_TARGET_ESP32
66

7-
87
#define TEST_TOUCH_CHANNEL (7)
98
static touch_pad_t touch_list[TEST_TOUCH_CHANNEL] = {
109
TOUCH_PAD_NUM0,
1110
//TOUCH_PAD_NUM1 is GPIO0, for download.
1211
TOUCH_PAD_NUM2, TOUCH_PAD_NUM3, TOUCH_PAD_NUM4, TOUCH_PAD_NUM5, TOUCH_PAD_NUM6, TOUCH_PAD_NUM7 /*,TOUCH_PAD_NUM8, TOUCH_PAD_NUM9*/
1312
};
1413

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

1716
#define NO_TOUCH_GPIO 25
1817

1918
#elif (CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3)
2019

2120
#define TEST_TOUCH_CHANNEL (8) //14
2221
static touch_pad_t touch_list[TEST_TOUCH_CHANNEL] = {
23-
TOUCH_PAD_NUM1, TOUCH_PAD_NUM2, TOUCH_PAD_NUM3, TOUCH_PAD_NUM4, TOUCH_PAD_NUM5, TOUCH_PAD_NUM6, TOUCH_PAD_NUM7, TOUCH_PAD_NUM8
22+
TOUCH_PAD_NUM1, TOUCH_PAD_NUM2, TOUCH_PAD_NUM3, TOUCH_PAD_NUM4, TOUCH_PAD_NUM5,
23+
TOUCH_PAD_NUM6, TOUCH_PAD_NUM7, TOUCH_PAD_NUM8
2424
/*TOUCH_PAD_NUM9, TOUCH_PAD_NUM10, TOUCH_PAD_NUM11, TOUCH_PAD_NUM12, TOUCH_PAD_NUM13, TOUCH_PAD_NUM14*/
2525
};
2626

@@ -42,7 +42,7 @@ uint8_t TOUCH_GPIOS[] = {2, 3, 4, 5, 6 /*, 7, 8, 9, 10, 11, 12 ,13, 14, 15*/};
4242
#define NO_TOUCH_GPIO 17
4343
#endif
4444

45-
#define INTERRUPT_THRESHOLD 0 // Use benchmarked threshold
45+
#define INTERRUPT_THRESHOLD 0 // Use benchmarked threshold
4646

4747
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32P4
4848
#define PRESSED_VALUE_DIFFERENCE 200 //-200 for ESP32 and +200 for ESP32P4 read value difference against the unpressed value
@@ -68,7 +68,7 @@ void gotTouch2() {
6868
*/
6969
static void test_press_fake(touch_pad_t pad_num) {
7070
#if SOC_TOUCH_SENSOR_VERSION <= 2
71-
touch_ll_set_charge_speed(pad_num,TOUCH_CHARGE_SPEED_4);
71+
touch_ll_set_charge_speed(pad_num,TOUCH_CHARGE_SPEED_4);
7272
#else
7373
touch_ll_set_internal_capacitor(0x7f);
7474
#endif
@@ -79,7 +79,7 @@ static void test_press_fake(touch_pad_t pad_num) {
7979
*/
8080
static void test_release_fake(touch_pad_t pad_num) {
8181
#if SOC_TOUCH_SENSOR_VERSION <= 2
82-
touch_ll_set_charge_speed(pad_num, TOUCH_CHARGE_SPEED_7);
82+
touch_ll_set_charge_speed(pad_num, TOUCH_CHARGE_SPEED_7);
8383
#else
8484
touch_ll_set_internal_capacitor(0);
8585
#endif
@@ -139,7 +139,7 @@ void test_touch_interrtupt(void) {
139139
test_press_fake(touch_list[1]);
140140

141141
delay(100);
142-
142+
143143
touchDetachInterrupt(TOUCH_GPIOS[0]);
144144
touchDetachInterrupt(TOUCH_GPIOS[1]);
145145

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /