mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-31 17:26:12 +00:00
Buzzer: add playForced(); fix per-channel force-on notification ignoring global mute
buzzer.play() was returning early when _is_quiet=true, so channels with explicit notification=ON were silent even though the logic correctly set play=true. playForced() bypasses the quiet check for these overrides. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
1281ec5c35
commit
9d92fb62df
@@ -2391,19 +2391,24 @@ switch(t){
|
|||||||
buzzer.play("MsgRcv3:d=4,o=6,b=200:32e,32g,32b,16c7");
|
buzzer.play("MsgRcv3:d=4,o=6,b=200:32e,32g,32b,16c7");
|
||||||
break;
|
break;
|
||||||
case UIEventType::channelMessage: {
|
case UIEventType::channelMessage: {
|
||||||
bool play = true;
|
bool play = false;
|
||||||
|
bool force = false;
|
||||||
if (_last_notif_ch_idx >= 0 && _node_prefs) {
|
if (_last_notif_ch_idx >= 0 && _node_prefs) {
|
||||||
uint64_t mask = 1ULL << _last_notif_ch_idx;
|
uint64_t mask = 1ULL << _last_notif_ch_idx;
|
||||||
if (_node_prefs->ch_notif_override & mask) {
|
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 {
|
} else {
|
||||||
play = !buzzer.isQuiet(); // follow global
|
play = !buzzer.isQuiet(); // state 0: follow global
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
play = !buzzer.isQuiet();
|
play = !buzzer.isQuiet();
|
||||||
}
|
}
|
||||||
_last_notif_ch_idx = -1;
|
_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;
|
break;
|
||||||
}
|
}
|
||||||
case UIEventType::ack:
|
case UIEventType::ack:
|
||||||
|
|||||||
@@ -15,18 +15,18 @@ void genericBuzzer::begin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void genericBuzzer::play(const char *melody) {
|
void genericBuzzer::play(const char *melody) {
|
||||||
if (isPlaying()) // interrupt existing
|
if (isPlaying()) rtttl::stop();
|
||||||
{
|
|
||||||
rtttl::stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_is_quiet) return;
|
if (_is_quiet) return;
|
||||||
|
rtttl::begin(PIN_BUZZER, melody);
|
||||||
rtttl::begin(PIN_BUZZER,melody);
|
|
||||||
// Serial.print("DBG: Playing melody - isQuiet: ");
|
// Serial.print("DBG: Playing melody - isQuiet: ");
|
||||||
// Serial.println(isQuiet());
|
// Serial.println(isQuiet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void genericBuzzer::playForced(const char *melody) {
|
||||||
|
if (isPlaying()) rtttl::stop();
|
||||||
|
rtttl::begin(PIN_BUZZER, melody);
|
||||||
|
}
|
||||||
|
|
||||||
bool genericBuzzer::isPlaying() {
|
bool genericBuzzer::isPlaying() {
|
||||||
return rtttl::isPlaying();
|
return rtttl::isPlaying();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ class genericBuzzer
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void begin(); // set up buzzer port
|
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 loop(); // loop driven-nonblocking
|
||||||
void startup(); // play startup sound
|
void startup(); // play startup sound
|
||||||
void shutdown(); // play shutdown sound
|
void shutdown(); // play shutdown sound
|
||||||
|
|||||||
Reference in New Issue
Block a user