From e45adb4cee0a5e83cb2b0255e1a26c1141affdb0 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sat, 31 Dec 2022 00:41:16 +0100 Subject: [PATCH 1/2] Make M300 S0 pause like Marlin Follow Marlin's behavior and simply insert a delay for the requested duration when using M300 S0. When S is not specified, use the default tone instead. Fixes #3856 --- Firmware/Marlin_main.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 650bac1d6..96478b3bd 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -7277,7 +7277,6 @@ Sigma_Exit: #endif // NUM_SERVOS > 0 #if (LARGE_FLASH == true && BEEPER > 0 ) - /*! ### M300 - Play tone M300: Play beep sound In Prusa Firmware the defaults are `100Hz` and `1000ms`, so that `M300` without parameters will beep for a second. @@ -7291,12 +7290,19 @@ Sigma_Exit: */ case 300: // M300 { - uint16_t beepS = code_seen('S') ? code_value() : 0; uint16_t beepP = code_seen('P') ? code_value() : 1000; - #if BEEPER > 0 - if (beepP > 0) - Sound_MakeCustom(beepP,beepS,false); - #endif + uint16_t beepS; + if (!code_seen('S')) + beepS = 0; + else { + beepS = code_value(); + if (!beepS) { + // handle S0 as a pause + _delay(beepP); + break; + } + } + Sound_MakeCustom(beepP, beepS, false); } break; #endif // M300 From 543b333007dae03b0b951493fa0051944e5996c6 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sat, 31 Dec 2022 00:51:44 +0100 Subject: [PATCH 2/2] Remove extra delay after critical sound This delay doesn't exist for the tone generator, so remove it from the pure version as well. --- Firmware/sound.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Firmware/sound.cpp b/Firmware/sound.cpp index f4c6ee1d0..27c951b97 100644 --- a/Firmware/sound.cpp +++ b/Firmware/sound.cpp @@ -84,7 +84,6 @@ void Sound_MakeCustom(uint16_t ms,uint16_t tone_,bool critical){ WRITE(BEEPER, HIGH); _delay(ms); WRITE(BEEPER, LOW); - _delay(ms); } else{ _tone(BEEPER, tone_);