From 7e45d56e66383c4ff5d2c0af4e1a75632f0510c0 Mon Sep 17 00:00:00 2001 From: MageDelfador <9780339+MageDelfador@users.noreply.github.com> Date: Sun, 8 Dec 2024 12:50:41 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20Advance=20tone=20queue=20when=20?= =?UTF-8?q?muted,=20tuning=20(#26278)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/libs/buzzer.cpp | 45 +++++++++++++++---------------- Marlin/src/module/temperature.cpp | 3 +++ 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Marlin/src/libs/buzzer.cpp b/Marlin/src/libs/buzzer.cpp index 1e2f23c5fd..350baa333f 100644 --- a/Marlin/src/libs/buzzer.cpp +++ b/Marlin/src/libs/buzzer.cpp @@ -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 diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 96295d7db5..45dae77d5e 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -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; }