@@ -44,6 +44,7 @@ void common_hal_alarm_touch_touchalarm_construct(alarm_touch_touchalarm_obj_t *s
4444 self -> pin = pin ;
4545}
4646
47+ // Used for light sleep.
4748mp_obj_t alarm_touch_touchalarm_find_triggered_alarm (const size_t n_alarms , const mp_obj_t * alarms ) {
4849 for (size_t i = 0 ; i < n_alarms ; i ++ ) {
4950 if (mp_obj_is_type (alarms [i ], & alarm_touch_touchalarm_type )) {
@@ -101,6 +102,8 @@ void alarm_touch_touchalarm_set_alarm(const bool deep_sleep, const size_t n_alar
101102 }
102103 touch_alarm = MP_OBJ_TO_PTR (alarms [i ]);
103104 touch_channel_mask |= 1 << touch_alarm -> pin -> number ;
105+ // Resetting the pin will set a pull-up, which we don't want.
106+ skip_reset_once_pin_number (touch_alarm -> pin -> number );
104107 touch_alarm_set = true;
105108 }
106109 }
@@ -128,8 +131,11 @@ void alarm_touch_touchalarm_set_alarm(const bool deep_sleep, const size_t n_alar
128131 // configure trigger threshold
129132 #if defined(CONFIG_IDF_TARGET_ESP32 )
130133 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.
131137 touch_pad_read (touch_channel , & touch_value );
132- touch_pad_set_thresh (touch_channel , touch_value / 10 ); // 10%
138+ touch_pad_set_thresh (touch_channel , touch_value / 2 );
133139 #else
134140 uint32_t touch_value ;
135141 touch_pad_read_benchmark (touch_channel , & touch_value );
@@ -181,8 +187,11 @@ void alarm_touch_touchalarm_prepare_for_deep_sleep(void) {
181187 // configure trigger threshold
182188 #if defined(CONFIG_IDF_TARGET_ESP32 )
183189 uint16_t touch_value ;
184- touch_pad_read_filtered (touch_channel , & touch_value );
185- 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 );
186195 #else
187196 uint32_t touch_value ;
188197 touch_pad_sleep_channel_read_smooth (touch_channel , & touch_value );
0 commit comments