mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2026-01-01 20:33:52 -07:00
🩹 Advance tone queue when muted, tuning (#26278)
This commit is contained in:
parent
71ce7803e7
commit
7e45d56e66
2 changed files with 25 additions and 23 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue