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