Bumping keep alive when any button is pressed.

This commit is contained in:
ThePendulum
2026-05-01 22:55:33 +02:00
parent dd1a90f437
commit b9a6fecae7

View File

@@ -1,8 +1,8 @@
#include <Button.h>
#include <Adafruit_NeoPixel.h>
constexpr bool KEEPALIVE_ENABLE = false;
constexpr int KEEPALIVE_TIMEOUT = 5000; // ms
constexpr bool KEEPALIVE_ENABLE = true;
constexpr int KEEPALIVE_TIMEOUT = 30000; // ms
constexpr int LEDS_TAIL_PIN = PA6;
constexpr int LEDS_TAIL_LENGTH = 10;
@@ -106,6 +106,9 @@ unsigned long lastFrame = 0;
unsigned long lastPedalPress = millis();
unsigned long lastPedalRelease = 0;
unsigned long lastButtonPress = 0;
bool isReversing = false;
unsigned long indicatorLeftStart = 0;
@@ -532,6 +535,8 @@ void loop() {
activeMode = (Mode)((activeMode + 1) % MODE_COUNT);
animationFrame = 0; // ensures animations start cleanly instead of halfway
lastButtonPress = now;
Serial.print("BUTTON MODE ");
Serial.println(activeMode);
}
@@ -553,6 +558,8 @@ void loop() {
indicatorRightActive = false;
indicatorRightStart = 0;
lastButtonPress = now;
Serial.println("BUTTON LEFT");
}
@@ -565,6 +572,8 @@ void loop() {
indicatorLeftActive = false;
indicatorLeftStart = 0;
lastButtonPress = now;
Serial.println("BUTTON RIGHT");
}
@@ -589,7 +598,7 @@ void loop() {
}
Serial.println("PEDAL FORWARD");
}
}`3
if (pedal.released()) {
lastPedalRelease = now;
@@ -604,7 +613,7 @@ void loop() {
render();
}
if (KEEPALIVE_ENABLE && now - lastPedalPress > KEEPALIVE_TIMEOUT) {
if (KEEPALIVE_ENABLE && now - lastPedalPress > KEEPALIVE_TIMEOUT && now - lastButtonPress > KEEPALIVE_TIMEOUT) {
shutdown();
}
}