diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index aeb0ae8c..e4ee3b02 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -2391,19 +2391,24 @@ switch(t){ buzzer.play("MsgRcv3:d=4,o=6,b=200:32e,32g,32b,16c7"); break; case UIEventType::channelMessage: { - bool play = true; + bool play = false; + bool force = false; if (_last_notif_ch_idx >= 0 && _node_prefs) { uint64_t mask = 1ULL << _last_notif_ch_idx; if (_node_prefs->ch_notif_override & mask) { - play = !(_node_prefs->ch_notif_muted & mask); // explicit override + if (!(_node_prefs->ch_notif_muted & mask)) { play = true; force = true; } // state 2: force-on + // state 1: muted — play stays false } else { - play = !buzzer.isQuiet(); // follow global + play = !buzzer.isQuiet(); // state 0: follow global } } else { play = !buzzer.isQuiet(); } _last_notif_ch_idx = -1; - if (play) buzzer.play("kerplop:d=16,o=6,b=120:32g#,32c#"); + if (play) { + if (force) buzzer.playForced("kerplop:d=16,o=6,b=120:32g#,32c#"); + else buzzer.play("kerplop:d=16,o=6,b=120:32g#,32c#"); + } break; } case UIEventType::ack: diff --git a/src/helpers/ui/buzzer.cpp b/src/helpers/ui/buzzer.cpp index 29fb3e26..983e5c93 100644 --- a/src/helpers/ui/buzzer.cpp +++ b/src/helpers/ui/buzzer.cpp @@ -15,18 +15,18 @@ void genericBuzzer::begin() { } void genericBuzzer::play(const char *melody) { - if (isPlaying()) // interrupt existing - { - rtttl::stop(); - } - + if (isPlaying()) rtttl::stop(); if (_is_quiet) return; - - rtttl::begin(PIN_BUZZER,melody); + rtttl::begin(PIN_BUZZER, melody); // Serial.print("DBG: Playing melody - isQuiet: "); // Serial.println(isQuiet()); } +void genericBuzzer::playForced(const char *melody) { + if (isPlaying()) rtttl::stop(); + rtttl::begin(PIN_BUZZER, melody); +} + bool genericBuzzer::isPlaying() { return rtttl::isPlaying(); } diff --git a/src/helpers/ui/buzzer.h b/src/helpers/ui/buzzer.h index 0a500552..ae040814 100644 --- a/src/helpers/ui/buzzer.h +++ b/src/helpers/ui/buzzer.h @@ -20,7 +20,8 @@ class genericBuzzer { public: void begin(); // set up buzzer port - void play(const char *melody); // Generic play function + void play(const char *melody); + void playForced(const char *melody); // play regardless of quiet state void loop(); // loop driven-nonblocking void startup(); // play startup sound void shutdown(); // play shutdown sound