From 71674059c3af806980a598590da894cee84217e1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 10 Jul 2016 19:25:23 -0700 Subject: [PATCH] Two strategies to address a stuck buzzer --- Marlin/buzzer.h | 2 +- Marlin/ultralcd.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Marlin/buzzer.h b/Marlin/buzzer.h index c87fe849d7..04aadc4963 100644 --- a/Marlin/buzzer.h +++ b/Marlin/buzzer.h @@ -124,7 +124,7 @@ class Buzzer { this->state.timestamp = millis() + this->state.tone.duration; if (this->state.tone.frequency > 0) this->on(); } - else if (millis() >= this->state.timestamp) this->reset(); + else if (ELAPSED(millis(), this->state.timestamp)) this->reset(); } }; diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index d0a9a5dd73..5cd1252dbf 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -2334,12 +2334,14 @@ void kill_screen(const char* lcd_msg) { lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; next_button_update_ms = millis() + 500; + // Buzz and wait. The delay is needed for buttons to settle! #if ENABLED(LCD_USE_I2C_BUZZER) lcd.buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ); + delay(10); #elif PIN_EXISTS(BEEPER) buzzer.tone(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ); + for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); } #endif - delay(10); // needed for buttons to settle } /**