improved/corrected prog button debouncing (#221)

Co-authored-by: Waldemar Porscha <wp@porscha.eu>
This commit is contained in:
mumpf 2022-11-25 07:24:27 +01:00 committed by GitHub
parent b51c5950c5
commit 9894a8c8b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,11 +27,16 @@
ICACHE_RAM_ATTR void buttonEvent() ICACHE_RAM_ATTR void buttonEvent()
{ {
static uint32_t lastEvent=0; static uint32_t lastEvent=0;
static uint32_t lastPressed=0;
uint32_t diff = millis() - lastEvent; uint32_t diff = millis() - lastEvent;
if (diff >= PROG_BTN_PRESS_MIN_MILLIS && diff <= PROG_BTN_PRESS_MAX_MILLIS){ 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(); lastEvent = millis();
} }
#endif #endif