reset touchin on every vm run

This commit is contained in:
microDev 2020-11-26 11:22:44 +05:30
parent 048ca2a570
commit 6af48bb24c
No known key found for this signature in database
GPG Key ID: 2C0867BE60967730
2 changed files with 12 additions and 1 deletions

View File

@ -31,6 +31,13 @@
bool touch_inited = false; bool touch_inited = false;
void touchin_reset(void) {
if (touch_inited) {
touch_pad_deinit();
touch_inited = false;
}
}
static uint16_t get_raw_reading(touchio_touchin_obj_t *self) { static uint16_t get_raw_reading(touchio_touchin_obj_t *self) {
uint32_t touch_value; uint32_t touch_value;
touch_pad_read_raw_data((touch_pad_t)self->pin->touch_channel, &touch_value); 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) {
if (common_hal_touchio_touchin_deinited(self)) { if (common_hal_touchio_touchin_deinited(self)) {
return; return;
} }
touch_pad_deinit();
reset_pin_number(self->pin->touch_channel); reset_pin_number(self->pin->touch_channel);
self->pin = NULL; self->pin = NULL;
} }

View File

@ -43,6 +43,7 @@
#include "common-hal/busio/UART.h" #include "common-hal/busio/UART.h"
#include "common-hal/pulseio/PulseIn.h" #include "common-hal/pulseio/PulseIn.h"
#include "common-hal/pwmio/PWMOut.h" #include "common-hal/pwmio/PWMOut.h"
#include "common-hal/touchio/TouchIn.h"
#include "common-hal/watchdog/WatchDogTimer.h" #include "common-hal/watchdog/WatchDogTimer.h"
#include "common-hal/wifi/__init__.h" #include "common-hal/wifi/__init__.h"
#include "supervisor/memory.h" #include "supervisor/memory.h"
@ -127,6 +128,10 @@ void reset_port(void) {
rtc_reset(); rtc_reset();
#endif #endif
#if CIRCUITPY_TOUCHIO_USE_NATIVE
touchin_reset();
#endif
#if CIRCUITPY_WATCHDOG #if CIRCUITPY_WATCHDOG
watchdog_reset(); watchdog_reset();
#endif #endif