Skip to content

Commit 676c1e9

Browse files
committed
Add debounce to powerOnCheck - #84 fix
1 parent 6ded685 commit 676c1e9

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

Firmware/RTK_Surveyor/Buttons.ino

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,14 @@
33
//Let's make sure they continue to press for 500ms
44
void powerOnCheck()
55
{
6-
#ifdef ENABLE_DEVELOPER
7-
return;
8-
#endif
9-
106
powerPressedStartTime = millis();
7+
if (digitalRead(pin_powerSenseAndControl) == LOW)
8+
delay(500);
119

12-
while (digitalRead(pin_powerSenseAndControl) == LOW)
13-
{
14-
delay(10);
15-
16-
if (millis() - powerPressedStartTime > 500)
17-
break;
18-
}
19-
20-
if (millis() - powerPressedStartTime < 500)
10+
#ifndef ENABLE_DEVELOPER
11+
if (digitalRead(pin_powerSenseAndControl) != LOW)
2112
powerDown(false); //Power button tap. Returning to off state.
13+
#endif
2214

2315
powerPressedStartTime = 0; //Reset var to return to normal 'on' state
2416
}

0 commit comments

Comments
 (0)