@@ -37,19 +37,19 @@ typedef struct {
3737static 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
4242static float _duration_ms = 5.0f ;
4343static touch_volt_lim_l_t _volt_low = TOUCH_VOLT_LIM_L_0V5 ;
4444static touch_volt_lim_h_t _volt_high = TOUCH_VOLT_LIM_H_1V7 ;
4545static 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
4848static uint32_t _chg_times = 500 ;
4949static touch_volt_lim_l_t _volt_low = TOUCH_VOLT_LIM_L_0V5 ;
5050static 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
5353static uint32_t _div_num = 1 ;
5454static uint8_t _coarse_freq_tune = 1 ;
5555static 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
507506void 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
518517void 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
529528void 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
541540void touchInterruptSetThresholdDirection (bool mustbeLower ) {
542541 if (mustbeLower ) {
543542 _intr_trig_mode = TOUCH_INTR_TRIG_ON_BELOW_THRESH ;
0 commit comments