From 92231e88ca95ed92c98f62ee3cd301e57519ec90 Mon Sep 17 00:00:00 2001 From: Hanns Holger Rutz Date: Wed, 10 Aug 2022 21:49:18 +0200 Subject: [PATCH] Touchin.c - fix clean up in constructor before exception is thrown When the constructor value reading times out, an exception is thrown, but the digital pin is not de-initialised. Make sure to run the clean up, so user could catch the exception and retry using the same pin. --- shared-module/touchio/TouchIn.c | 1 + 1 file changed, 1 insertion(+) diff --git a/shared-module/touchio/TouchIn.c b/shared-module/touchio/TouchIn.c index 840c14571d..35dd56a6e4 100644 --- a/shared-module/touchio/TouchIn.c +++ b/shared-module/touchio/TouchIn.c @@ -78,6 +78,7 @@ void common_hal_touchio_touchin_construct(touchio_touchin_obj_t *self, const mcu uint16_t raw_reading = get_raw_reading(self); if (raw_reading == TIMEOUT_TICKS) { + common_hal_touchio_touchin_deinit(self); mp_raise_ValueError(translate("No pulldown on pin; 1Mohm recommended")); } self->threshold = raw_reading * 1.05 + 100;