From c64c196778038c0888a8e31651cd1957c6134586 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sat, 16 Aug 2025 06:10:44 -0500 Subject: [PATCH] Wait for lead up before enable longlong action (#7648) --- src/buzz/buzz.cpp | 4 ++++ src/input/ButtonThread.cpp | 9 +++++---- src/input/ButtonThread.h | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/buzz/buzz.cpp b/src/buzz/buzz.cpp index b09d7a82c..b0d162a44 100644 --- a/src/buzz/buzz.cpp +++ b/src/buzz/buzz.cpp @@ -140,6 +140,10 @@ bool playNextLeadUpNote() playTones(¬e, 1); // Play single note using existing playTones function leadUpNoteIndex++; + + if (leadUpNoteIndex >= leadUpNotesCount) { + return false; // this was the final note + } return true; // Note was played (playTones handles buzzer availability internally) } diff --git a/src/input/ButtonThread.cpp b/src/input/ButtonThread.cpp index f26b3c970..32882f7ae 100644 --- a/src/input/ButtonThread.cpp +++ b/src/input/ButtonThread.cpp @@ -140,8 +140,7 @@ int32_t ButtonThread::runOnce() } // Progressive lead-up sound system - if (buttonCurrentlyPressed && (millis() - buttonPressStartTime) >= BUTTON_LEADUP_MS && - (millis() - buttonPressStartTime) < _longLongPressTime) { + if (buttonCurrentlyPressed && (millis() - buttonPressStartTime) >= BUTTON_LEADUP_MS) { // Start the progressive sequence if not already active if (!leadUpSequenceActive) { @@ -153,13 +152,14 @@ int32_t ButtonThread::runOnce() else if ((millis() - lastLeadUpNoteTime) >= 400) { // 400ms interval between notes if (playNextLeadUpNote()) { lastLeadUpNoteTime = millis(); + } else { + leadUpPlayed = true; } } } // Reset when button is released if (!buttonCurrentlyPressed && buttonWasPressed) { - leadUpPlayed = false; leadUpSequenceActive = false; resetLeadUpSequence(); } @@ -256,12 +256,13 @@ int32_t ButtonThread::runOnce() LOG_INFO("LONG PRESS RELEASE AFTER %u MILLIS", millis() - buttonPressStartTime); if (millis() > 30000 && _longLongPress != INPUT_BROKER_NONE && - (millis() - buttonPressStartTime) >= _longLongPressTime) { + (millis() - buttonPressStartTime) >= _longLongPressTime && leadUpPlayed) { evt.inputEvent = _longLongPress; this->notifyObservers(&evt); } // Reset combination tracking waitingForLongPress = false; + leadUpPlayed = false; break; } diff --git a/src/input/ButtonThread.h b/src/input/ButtonThread.h index bbc8da2a7..c6d6557e2 100644 --- a/src/input/ButtonThread.h +++ b/src/input/ButtonThread.h @@ -92,7 +92,7 @@ class ButtonThread : public Observable, public concurrency:: voidFuncPtr _intRoutine = nullptr; uint16_t _longPressTime = 500; - uint16_t _longLongPressTime = 5000; + uint16_t _longLongPressTime = 3900; int _pinNum = 0; bool _activeLow = true; bool _touchQuirk = false;