Skip to content

Commit 6af48bb

Browse files
committed
reset touchin on every vm run
1 parent 048ca2a commit 6af48bb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

ports/esp32s2/common-hal/touchio/TouchIn.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@
3131

3232
bool touch_inited = false;
3333

34+
void touchin_reset(void) {
35+
if (touch_inited) {
36+
touch_pad_deinit();
37+
touch_inited = false;
38+
}
39+
}
40+
3441
static uint16_t get_raw_reading(touchio_touchin_obj_t *self) {
3542
uint32_t touch_value;
3643
touch_pad_read_raw_data((touch_pad_t)self->pin->touch_channel, &touch_value);
@@ -78,7 +85,6 @@ void common_hal_touchio_touchin_deinit(touchio_touchin_obj_t* self) {
7885
if (common_hal_touchio_touchin_deinited(self)) {
7986
return;
8087
}
81-
touch_pad_deinit();
8288
reset_pin_number(self->pin->touch_channel);
8389
self->pin = NULL;
8490
}

ports/esp32s2/supervisor/port.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "common-hal/busio/UART.h"
4444
#include "common-hal/pulseio/PulseIn.h"
4545
#include "common-hal/pwmio/PWMOut.h"
46+
#include "common-hal/touchio/TouchIn.h"
4647
#include "common-hal/watchdog/WatchDogTimer.h"
4748
#include "common-hal/wifi/__init__.h"
4849
#include "supervisor/memory.h"
@@ -127,6 +128,10 @@ void reset_port(void) {
127128
rtc_reset();
128129
#endif
129130

131+
#if CIRCUITPY_TOUCHIO_USE_NATIVE
132+
touchin_reset();
133+
#endif
134+
130135
#if CIRCUITPY_WATCHDOG
131136
watchdog_reset();
132137
#endif

0 commit comments

Comments
 (0)