From bfe6f71794875f7401e7f2d341279fed14eb8c76 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 10 Feb 2017 00:30:33 -0600 Subject: [PATCH] Simplify filament_change_beep function --- Marlin/Marlin_main.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 3a93bc63ef..885e07c535 100755 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -7294,18 +7294,12 @@ inline void gcode_M503() { unsigned long int runout_beep = 0; void filament_change_beep() { - millis_t ms = millis(); - if (ms >= next_buzz) { - if (runout_beep <= FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS ) { // Only beep as long as we are supposed to! - BUZZ(300, 2000); - next_buzz = ms + 2500; // Beep every 2.5s while waiting - runout_beep++; - } - else if (runout_beep > FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS && - runout_beep <= (FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS + 5)) { // End with a burst of short beeps - BUZZ(200, 2000); - next_buzz = ms + 400; // Beep - runout_beep++; + const millis_t ms = millis(); + if (ELAPSED(ms, next_buzz)) { + if (runout_beep <= FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS + 5) { // Only beep as long as we're supposed to + next_buzz = ms + (runout_beep <= FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS ? 2500 : 400); + BUZZ(300, 2000); + runout_beep++; } } }