@@ -77,8 +77,6 @@ mp_obj_t alarm_touch_touchalarm_record_wake_alarm(void) {
7777 const mcu_pin_obj_t * pin_obj = MP_OBJ_TO_PTR (mcu_pin_globals .map .table [i ].value );
7878 if (pin_obj -> touch_channel == wake_channel ) {
7979 alarm -> pin = mcu_pin_globals .map .table [i ].value ;
80- // Undo the never reset in case it was a fake deep sleep.
81- reset_pin_number (alarm -> pin -> number );
8280 break ;
8381 }
8482 }
@@ -105,7 +103,7 @@ void alarm_touch_touchalarm_set_alarm(const bool deep_sleep, const size_t n_alar
105103 touch_alarm = MP_OBJ_TO_PTR (alarms [i ]);
106104 touch_channel_mask |= 1 << touch_alarm -> pin -> number ;
107105 // Resetting the pin will set a pull-up, which we don't want.
108- never_reset_pin_number (touch_alarm -> pin -> number );
106+ skip_reset_once_pin_number (touch_alarm -> pin -> number );
109107 touch_alarm_set = true;
110108 }
111109 }
@@ -133,8 +131,11 @@ void alarm_touch_touchalarm_set_alarm(const bool deep_sleep, const size_t n_alar
133131 // configure trigger threshold
134132 #if defined(CONFIG_IDF_TARGET_ESP32 )
135133 uint16_t touch_value ;
134+ // ESP32 touch_pad_read() returns a lower value when a pin is touched, not a higher value
135+ // Typical values on a Feather ESP32 V2 are 600 with a short jumper untouched,
136+ // 70 touched.
136137 touch_pad_read (touch_channel , & touch_value );
137- touch_pad_set_thresh (touch_channel , touch_value / 10 ); // 10%
138+ touch_pad_set_thresh (touch_channel , touch_value / 2 );
138139 #else
139140 uint32_t touch_value ;
140141 touch_pad_read_benchmark (touch_channel , & touch_value );
@@ -186,8 +187,11 @@ void alarm_touch_touchalarm_prepare_for_deep_sleep(void) {
186187 // configure trigger threshold
187188 #if defined(CONFIG_IDF_TARGET_ESP32 )
188189 uint16_t touch_value ;
189- touch_pad_read_filtered (touch_channel , & touch_value );
190- touch_pad_set_thresh (touch_channel , touch_value );
190+ touch_pad_read (touch_channel , & touch_value );
191+ // ESP32 touch_pad_read() returns a lower value when a pin is touched, not a higher value
192+ // Typical values on a Feather ESP32 V2 are 600 with a short jumper untouched,
193+ // 70 touched.
194+ touch_pad_set_thresh (touch_channel , touch_value / 2 );
191195 #else
192196 uint32_t touch_value ;
193197 touch_pad_sleep_channel_read_smooth (touch_channel , & touch_value );
0 commit comments