Speedup boot by not waiting for Serial

This commit is contained in:
Dave Allie
2025-12-05 17:47:23 +11:00
parent ddec7f78dd
commit 85502b417e
3 changed files with 23 additions and 25 deletions

View File

@@ -29,15 +29,15 @@ Button getPressedButton() {
return NONE;
}
Input getInput(const bool skipWait) {
Input getInput(const long maxHoldMs) {
const Button button = getPressedButton();
if (button == NONE) return {NONE, 0};
if (skipWait) {
return {button, 0};
}
const auto start = millis();
while (getPressedButton() == button) delay(50);
return {button, millis() - start};
unsigned long held = 0;
while (getPressedButton() == button && (maxHoldMs < 0 || held < maxHoldMs)) {
delay(50);
held = millis() - start;
}
return {button, held};
}