diff --git a/main.ino b/main.ino index f411cb0..ef4e086 100644 --- a/main.ino +++ b/main.ino @@ -225,6 +225,8 @@ class DisplayConfig { unsigned long previousMillis = -1000000000; +unsigned long lastDebounceTime = 0; +unsigned long debounceDelay = 50; bool buttonPressedLastCycle = false; bool sht3xErrorLastCycle = false; @@ -335,9 +337,10 @@ void loop() { } } if (digitalRead(buttonPin)){ - if (!buttonPressedLastCycle){ + if (!buttonPressedLastCycle && millis() - lastDebounceTime > debounceDelay){ config->cycleScreen()->draw(); buttonPressedLastCycle = true; + lastDebounceTime = millis(); } } else { buttonPressedLastCycle = false;