From 9894a8c8b80b3785f040480476a9b12bdc546fb1 Mon Sep 17 00:00:00 2001 From: mumpf Date: Fri, 25 Nov 2022 07:24:27 +0100 Subject: [PATCH] improved/corrected prog button debouncing (#221) Co-authored-by: Waldemar Porscha --- src/knx_facade.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/knx_facade.cpp b/src/knx_facade.cpp index 35a6a6b..1dee9fc 100644 --- a/src/knx_facade.cpp +++ b/src/knx_facade.cpp @@ -27,11 +27,16 @@ ICACHE_RAM_ATTR void buttonEvent() { static uint32_t lastEvent=0; + static uint32_t lastPressed=0; + uint32_t diff = millis() - lastEvent; if (diff >= PROG_BTN_PRESS_MIN_MILLIS && diff <= PROG_BTN_PRESS_MAX_MILLIS){ - knx.toggleProgMode(); + if (millis() - lastPressed > 200) + { + knx.toggleProgMode(); + lastPressed = millis(); + } } - lastEvent = millis(); } #endif