Skip to content

Commit 9e995a5

Browse files
committed
Fix Espressif TouchAlarm
1 parent f2bfced commit 9e995a5

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

ports/espressif/common-hal/alarm/touch/TouchAlarm.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
4748
mp_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)) {
@@ -76,6 +77,8 @@ mp_obj_t alarm_touch_touchalarm_record_wake_alarm(void) {
7677
const mcu_pin_obj_t *pin_obj = MP_OBJ_TO_PTR(mcu_pin_globals.map.table[i].value);
7778
if (pin_obj->touch_channel == wake_channel) {
7879
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);
7982
break;
8083
}
8184
}
@@ -101,6 +104,8 @@ void alarm_touch_touchalarm_set_alarm(const bool deep_sleep, const size_t n_alar
101104
}
102105
touch_alarm = MP_OBJ_TO_PTR(alarms[i]);
103106
touch_channel_mask |= 1 << touch_alarm->pin->number;
107+
// Resetting the pin will set a pull-up, which we don't want.
108+
never_reset_pin_number(touch_alarm->pin->number);
104109
touch_alarm_set = true;
105110
}
106111
}

ports/espressif/peripherals/touch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void peripherals_touch_never_reset(const bool enable) {
4343
void peripherals_touch_init(const touch_pad_t touchpad) {
4444
if (!touch_inited) {
4545
touch_pad_init();
46-
touch_pad_set_fsm_mode(TOUCH_FSM_MODE_SW);
46+
touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER);
4747
}
4848
// touch_pad_config() must be done before touch_pad_fsm_start() the first time.
4949
// Otherwise the calibration is wrong and we get maximum raw values if there is

0 commit comments

Comments
 (0)