Skip to content

Commit

Permalink
improved/corrected prog button debouncing (#221)
Browse files Browse the repository at this point in the history
Co-authored-by: Waldemar Porscha <[email protected]>
  • Loading branch information
mumpf and Waldemar Porscha authored Nov 25, 2022
1 parent b51c595 commit 9894a8c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/knx_facade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9894a8c

Please sign in to comment.