Skip to content

Commit ec720a8

Browse files
committed
fix(touch): Update touchSetConfig for S2 and S3
1 parent 399094d commit ec720a8

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,7 @@ void touchSetTiming(float measure, uint32_t sleep) {
491491
__touchMeasureTime = measure;
492492
}
493493

494-
#if SOC_TOUCH_SENSOR_VERSION == 1 || SOC_TOUCH_SENSOR_VERSION == 2 // ESP32, ESP32S2, ESP32S3
495-
494+
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
496495
void touchSetConfig(float duration_ms, touch_volt_lim_l_t volt_low, touch_volt_lim_h_t volt_high) {
497496
if (initialized) {
498497
log_e("Touch sensor already initialized. Cannot set configuration.");
@@ -503,8 +502,18 @@ void touchSetConfig(float duration_ms, touch_volt_lim_l_t volt_low, touch_volt_l
503502
_volt_high = volt_high;
504503
}
505504

506-
#elif SOC_TOUCH_SENSOR_VERSION == 3 // ESP32P4
505+
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
506+
void touchSetConfig(uint32_t chg_times, touch_volt_lim_l_t volt_low, touch_volt_lim_h_t volt_high) {
507+
if (initialized) {
508+
log_e("Touch sensor already initialized. Cannot set configuration.");
509+
return;
510+
}
511+
_chg_times = chg_times;
512+
_volt_low = volt_low;
513+
_volt_high = volt_high;
514+
}
507515

516+
#elif SOC_TOUCH_SENSOR_VERSION == 3 // ESP32P4
508517
void touchSetConfig(uint32_t div_num, uint8_t coarse_freq_tune, uint8_t fine_freq_tune) {
509518
if (initialized) {
510519
log_e("Touch sensor already initialized. Cannot set configuration.");

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,22 @@ typedef uint32_t touch_value_t;
5959
**/
6060
void touchSetTiming(float measure, uint32_t sleep);
6161

62-
#if SOC_TOUCH_SENSOR_VERSION == 1 || SOC_TOUCH_SENSOR_VERSION == 2 // ESP32, ESP32S2, ESP32S3
62+
#if SOC_TOUCH_SENSOR_VERSION == 1 // ESP32
6363
/*
6464
* @param[in] duration_ms The measurement duration of the touch channel
6565
* @param[in] volt_low The low voltage limit of the touch channel
6666
* @param[in] volt_high The high voltage limit of the touch channel
6767
*/
6868
void touchSetConfig(float duration_ms, touch_volt_lim_l_t volt_low, touch_volt_lim_h_t volt_high);
6969

70+
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32S2, ESP32S3
71+
/*
72+
* @param[in] chg_times The charge times of the touch channel
73+
* @param[in] volt_low The low voltage limit of the touch channel
74+
* @param[in] volt_high The high voltage limit of the touch channel
75+
*/
76+
void touchSetConfig(uint32_t chg_times, touch_volt_lim_l_t volt_low, touch_volt_lim_h_t volt_high);
77+
7078
#elif SOC_TOUCH_SENSOR_VERSION == 3 // ESP32P4
7179
/*
7280
* Tune the touch pad frequency.

0 commit comments

Comments
 (0)