forked from Mirrors/Marlin
🩹 Advance tone queue when muted, tuning (#26278)
This commit is contained in:
@@ -55,30 +55,29 @@ void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) {
|
||||
}
|
||||
|
||||
void Buzzer::tick() {
|
||||
if (!ui.sound_on) return;
|
||||
const millis_t now = millis();
|
||||
|
||||
if (!state.endtime) {
|
||||
if (buffer.isEmpty()) return;
|
||||
|
||||
state.tone = buffer.dequeue();
|
||||
state.endtime = now + state.tone.duration;
|
||||
|
||||
if (state.tone.frequency > 0) {
|
||||
#if ENABLED(EXTENSIBLE_UI) && DISABLED(EXTUI_LOCAL_BEEPER)
|
||||
CRITICAL_SECTION_START();
|
||||
ExtUI::onPlayTone(state.tone.frequency, state.tone.duration);
|
||||
CRITICAL_SECTION_END();
|
||||
#elif ENABLED(SPEAKER)
|
||||
CRITICAL_SECTION_START();
|
||||
::tone(BEEPER_PIN, state.tone.frequency, state.tone.duration);
|
||||
CRITICAL_SECTION_END();
|
||||
#else
|
||||
on();
|
||||
#endif
|
||||
}
|
||||
if (state.endtime) {
|
||||
if (ELAPSED(millis(), state.endtime)) reset();
|
||||
return;
|
||||
}
|
||||
|
||||
if (buffer.isEmpty()) return;
|
||||
|
||||
state.tone = buffer.dequeue();
|
||||
state.endtime = millis() + state.tone.duration;
|
||||
|
||||
if (state.tone.frequency > 0) {
|
||||
#if ENABLED(EXTENSIBLE_UI) && DISABLED(EXTUI_LOCAL_BEEPER)
|
||||
CRITICAL_SECTION_START();
|
||||
ExtUI::onPlayTone(state.tone.frequency, state.tone.duration);
|
||||
CRITICAL_SECTION_END();
|
||||
#elif ENABLED(SPEAKER)
|
||||
CRITICAL_SECTION_START();
|
||||
::tone(BEEPER_PIN, state.tone.frequency, state.tone.duration);
|
||||
CRITICAL_SECTION_END();
|
||||
#else
|
||||
on();
|
||||
#endif
|
||||
}
|
||||
else if (ELAPSED(now, state.endtime)) reset();
|
||||
}
|
||||
|
||||
#endif // HAS_BEEPER
|
||||
|
||||
@@ -703,6 +703,9 @@ volatile bool Temperature::raw_temps_ready = false;
|
||||
ui.update();
|
||||
#endif
|
||||
|
||||
// Update beeper queue
|
||||
TERN_(HAS_BEEPER, buzzer.tick());
|
||||
|
||||
return temp_ready;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user