fix debounce
This commit is contained in:
parent
5c3645d69d
commit
c0c97bdbf2
1 changed files with 2 additions and 2 deletions
4
main.ino
4
main.ino
|
@ -224,9 +224,9 @@ class DisplayConfig {
|
|||
};
|
||||
|
||||
|
||||
const byte DEBOUNCE_DELAY = 50;
|
||||
unsigned long previousMillis = -1000000000;
|
||||
unsigned long lastDebounceTime = 0;
|
||||
unsigned long debounceDelay = 50;
|
||||
bool buttonPressedLastCycle = false;
|
||||
bool sht3xErrorLastCycle = false;
|
||||
|
||||
|
@ -337,7 +337,7 @@ void loop() {
|
|||
}
|
||||
}
|
||||
if (digitalRead(buttonPin)){
|
||||
if (!buttonPressedLastCycle && millis() - lastDebounceTime > debounceDelay){
|
||||
if (!buttonPressedLastCycle && millis() - lastDebounceTime > DEBOUNCE_DELAY){
|
||||
config->cycleScreen()->draw();
|
||||
buttonPressedLastCycle = true;
|
||||
lastDebounceTime = millis();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue