summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-05-31 10:58:21 +0200
committerDaniel Friesel <derf@finalrewind.org>2018-05-31 10:58:21 +0200
commita13d74779b25dda964d81b36b1ab12863111e8f5 (patch)
tree9e3065c1f05ccf651d5460ed6394057177771ca3
parentd040ed5eecb104c201b330c468df3b6d8c59b7f1 (diff)
Handle high-frequency key presses in debounce logic
-rw-r--r--src/system.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/system.cc b/src/system.cc
index 9b04f69..66b3a53 100644
--- a/src/system.cc
+++ b/src/system.cc
@@ -152,10 +152,12 @@ void System::next_mode(void)
void System::debounce_start(void)
{
- btn_debounce = 1;
- wdt_reset();
- WDTCSR = _BV(WDE) | _BV(WDCE);
- WDTCSR = _BV(WDIE) | _BV(WDP1) | _BV(WDP0);
+ if (!btn_debounce) {
+ btn_debounce = 1;
+ wdt_reset();
+ WDTCSR = _BV(WDE) | _BV(WDCE);
+ WDTCSR = _BV(WDIE) | _BV(WDP1) | _BV(WDP0);
+ }
}
void System::debounce_done(void)