mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-08 14:12:05 +00:00
Boop boop boop boop
This commit is contained in:
parent
5894a99338
commit
fe0a64da80
@ -229,18 +229,33 @@ int32_t ButtonThread::runOnce()
|
||||
if (buttonCurrentlyPressed && !buttonWasPressed) {
|
||||
buttonPressStartTime = millis();
|
||||
leadUpPlayed = false;
|
||||
leadUpSequenceActive = false;
|
||||
resetLeadUpSequence();
|
||||
}
|
||||
|
||||
// Check if we should play lead-up sound
|
||||
if (buttonCurrentlyPressed && !leadUpPlayed && (millis() - buttonPressStartTime) >= BUTTON_LEADUP_MS &&
|
||||
// Progressive lead-up sound system
|
||||
if (buttonCurrentlyPressed && (millis() - buttonPressStartTime) >= BUTTON_LEADUP_MS &&
|
||||
(millis() - buttonPressStartTime) < BUTTON_LONGPRESS_MS) {
|
||||
playLongPressLeadUp();
|
||||
leadUpPlayed = true;
|
||||
|
||||
// Start the progressive sequence if not already active
|
||||
if (!leadUpSequenceActive) {
|
||||
leadUpSequenceActive = true;
|
||||
lastLeadUpNoteTime = millis();
|
||||
playNextLeadUpNote(); // Play the first note immediately
|
||||
}
|
||||
// Continue playing notes at intervals
|
||||
else if ((millis() - lastLeadUpNoteTime) >= 400) { // 400ms interval between notes
|
||||
if (playNextLeadUpNote()) {
|
||||
lastLeadUpNoteTime = millis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reset when button is released
|
||||
if (!buttonCurrentlyPressed && buttonWasPressed) {
|
||||
leadUpPlayed = false;
|
||||
leadUpSequenceActive = false;
|
||||
resetLeadUpSequence();
|
||||
}
|
||||
|
||||
buttonWasPressed = buttonCurrentlyPressed;
|
||||
|
@ -21,7 +21,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef BUTTON_LEADUP_MS
|
||||
#define BUTTON_LEADUP_MS 2500 // Play lead-up sound after 2.5 seconds of holding
|
||||
#define BUTTON_LEADUP_MS 2200 // Play lead-up sound after 2.5 seconds of holding
|
||||
#endif
|
||||
|
||||
class ButtonThread : public concurrency::OSThread
|
||||
@ -97,6 +97,8 @@ class ButtonThread : public concurrency::OSThread
|
||||
|
||||
// Long press lead-up tracking
|
||||
bool leadUpPlayed = false;
|
||||
uint32_t lastLeadUpNoteTime = 0;
|
||||
bool leadUpSequenceActive = false;
|
||||
|
||||
static void wakeOnIrq(int irq, int mode);
|
||||
|
||||
|
@ -107,6 +107,35 @@ void playLongPressLeadUp()
|
||||
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
|
||||
}
|
||||
|
||||
// Static state for progressive lead-up notes
|
||||
static int leadUpNoteIndex = 0;
|
||||
static const ToneDuration leadUpNotes[] = {
|
||||
{NOTE_C3, 100}, // Start low
|
||||
{NOTE_E3, 100}, // Step up
|
||||
{NOTE_G3, 100}, // Keep climbing
|
||||
{NOTE_B3, 150} // Peak with longer note for emphasis
|
||||
};
|
||||
static const int leadUpNotesCount = sizeof(leadUpNotes) / sizeof(ToneDuration);
|
||||
|
||||
bool playNextLeadUpNote()
|
||||
{
|
||||
if (leadUpNoteIndex >= leadUpNotesCount) {
|
||||
return false; // All notes have been played
|
||||
}
|
||||
|
||||
// Use playTones to handle buzzer logic consistently
|
||||
const auto ¬e = leadUpNotes[leadUpNoteIndex];
|
||||
playTones(¬e, 1); // Play single note using existing playTones function
|
||||
|
||||
leadUpNoteIndex++;
|
||||
return true; // Note was played (playTones handles buzzer availability internally)
|
||||
}
|
||||
|
||||
void resetLeadUpSequence()
|
||||
{
|
||||
leadUpNoteIndex = 0;
|
||||
}
|
||||
|
||||
void playComboTune()
|
||||
{
|
||||
// Quick high-pitched notes with trills
|
||||
|
@ -9,3 +9,5 @@ void playGPSDisableBeep();
|
||||
void playComboTune();
|
||||
void playBoop();
|
||||
void playLongPressLeadUp();
|
||||
bool playNextLeadUpNote(); // Play the next note in the lead-up sequence
|
||||
void resetLeadUpSequence(); // Reset the lead-up sequence to start from beginning
|
Loading…
Reference in New Issue
Block a user