From b9a6fecae7fc85862d7cc94df1c4c0636fca66d1 Mon Sep 17 00:00:00 2001 From: ThePendulum Date: Fri, 1 May 2026 22:55:33 +0200 Subject: [PATCH] Bumping keep alive when any button is pressed. --- QuadLightsV3.ino | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/QuadLightsV3.ino b/QuadLightsV3.ino index 4c1294c..b0915c5 100644 --- a/QuadLightsV3.ino +++ b/QuadLightsV3.ino @@ -1,8 +1,8 @@ #include #include -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(); } } \ No newline at end of file