diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index fddf42d7b1..5700591ca3 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -54,7 +54,11 @@ #endif #include "../lcd/ultralcd.h" -#include "../libs/buzzer.h" + +#if HAS_BUZZER + #include "../libs/buzzer.h" +#endif + #include "../libs/nozzle.h" #include "pause.h" diff --git a/Marlin/src/lcd/menu/game/brickout.cpp b/Marlin/src/lcd/menu/game/brickout.cpp index db360e44f6..b13649ca9e 100644 --- a/Marlin/src/lcd/menu/game/brickout.cpp +++ b/Marlin/src/lcd/menu/game/brickout.cpp @@ -79,7 +79,7 @@ void BrickoutGame::game_screen() { } // Did the ball go below the bottom? else if (newy > BTOF(LCD_PIXEL_HEIGHT)) { - BUZZ(500, 75); + _BUZZ(500, 75); if (--bdat.balls_left) reset_ball(); else game_state = 0; break; // done } diff --git a/Marlin/src/lcd/menu/game/game.h b/Marlin/src/lcd/menu/game/game.h index f0e76225b7..f168ccec79 100644 --- a/Marlin/src/lcd/menu/game/game.h +++ b/Marlin/src/lcd/menu/game/game.h @@ -28,7 +28,7 @@ //#define MUTE_GAMES -#ifdef MUTE_GAMES +#if ENABLED(MUTE_GAMES) || !HAS_BUZZER #define _BUZZ(D,F) NOOP #else #define _BUZZ(D,F) BUZZ(D,F) diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index 237cd69707..18fb599f56 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -31,7 +31,9 @@ #include "../../module/printcounter.h" #include "../../gcode/queue.h" #include "../../sd/cardreader.h" -#include "../../libs/buzzer.h" +#if HAS_BUZZER + #include "../../libs/buzzer.h" +#endif #if ENABLED(EEPROM_SETTINGS) #include "../../module/configuration_store.h" @@ -346,13 +348,15 @@ void scroll_screen(const uint8_t limit, const bool is_menu) { encoderTopLine = encoderLine; } -void MarlinUI::completion_feedback(const bool good/*=true*/) { - if (good) { - BUZZ(100, 659); - BUZZ(100, 698); +#if HAS_BUZZER + void MarlinUI::completion_feedback(const bool good/*=true*/) { + if (good) { + BUZZ(100, 659); + BUZZ(100, 698); + } + else BUZZ(20, 440); } - else BUZZ(20, 440); -} +#endif #if HAS_LINE_TO_Z @@ -433,8 +437,18 @@ void MarlinUI::completion_feedback(const bool good/*=true*/) { #endif #if ENABLED(EEPROM_SETTINGS) - void lcd_store_settings() { ui.completion_feedback(settings.save()); } - void lcd_load_settings() { ui.completion_feedback(settings.load()); } + void lcd_store_settings() { + const bool saved = settings.save(); + #if HAS_BUZZER + ui.completion_feedback(saved); + #endif + } + void lcd_load_settings() { + const bool loaded = settings.load(); + #if HAS_BUZZER + ui.completion_feedback(loaded); + #endif + } #endif void _lcd_draw_homing() { diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 822616c401..2dc66cee4a 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -603,7 +603,12 @@ void menu_backlash(); static void lcd_init_eeprom_confirm() { do_select_screen( PSTR(MSG_BUTTON_INIT), PSTR(MSG_BUTTON_CANCEL), - []{ ui.completion_feedback(settings.init_eeprom()); }, + []{ + const bool inited = settings.init_eeprom(); + #if HAS_BUZZER + ui.completion_feedback(inited); + #endif + }, ui.goto_previous_screen, PSTR(MSG_INIT_EEPROM), nullptr, PSTR("?") ); @@ -698,8 +703,11 @@ void menu_advanced_settings() { // // Toggle the SD Firmware Update state in EEPROM // - const bool new_state = !settings.sd_update_status(); - ui.completion_feedback(settings.set_sd_update_status(new_state)); + const bool new_state = !settings.sd_update_status(), + didset = settings.set_sd_update_status(new_state); + #if HAS_BUZZER + ui.completion_feedback(didset); + #endif ui.return_to_status(); if (new_state) LCD_MESSAGEPGM(MSG_RESET_PRINTER); else ui.reset_status(); }); diff --git a/Marlin/src/lcd/menu/menu_bed_leveling.cpp b/Marlin/src/lcd/menu/menu_bed_leveling.cpp index 70a04e2de0..3f1f746af1 100644 --- a/Marlin/src/lcd/menu/menu_bed_leveling.cpp +++ b/Marlin/src/lcd/menu/menu_bed_leveling.cpp @@ -77,7 +77,9 @@ ui.synchronize(PSTR(MSG_LEVEL_BED_DONE)); #endif ui.goto_previous_screen_no_defer(); - ui.completion_feedback(); + #if HAS_BUZZER + ui.completion_feedback(); + #endif } if (ui.should_draw()) draw_menu_item_static(LCD_HEIGHT >= 4 ? 1 : 0, PSTR(MSG_LEVEL_BED_DONE)); ui.refresh(LCDVIEW_CALL_REDRAW_NEXT); diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index f682310d47..29ab1a1716 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -56,7 +56,9 @@ void menu_advanced_settings(); static void lcd_factory_settings() { settings.reset(); - ui.completion_feedback(); + #if HAS_BUZZER + ui.completion_feedback(); + #endif } #if ENABLED(LCD_PROGRESS_BAR_TEST) diff --git a/Marlin/src/lcd/menu/menu_custom.cpp b/Marlin/src/lcd/menu/menu_custom.cpp index 33ec5352e0..ad346e71df 100644 --- a/Marlin/src/lcd/menu/menu_custom.cpp +++ b/Marlin/src/lcd/menu/menu_custom.cpp @@ -39,7 +39,7 @@ void _lcd_user_gcode(PGM_P const cmd) { queue.inject_P(cmd); - #if ENABLED(USER_SCRIPT_AUDIBLE_FEEDBACK) + #if ENABLED(USER_SCRIPT_AUDIBLE_FEEDBACK) && HAS_BUZZER ui.completion_feedback(); #endif #if ENABLED(USER_SCRIPT_RETURN) diff --git a/Marlin/src/lcd/menu/menu_service.cpp b/Marlin/src/lcd/menu/menu_service.cpp index 5f30856f0b..6eee178143 100644 --- a/Marlin/src/lcd/menu/menu_service.cpp +++ b/Marlin/src/lcd/menu/menu_service.cpp @@ -38,7 +38,9 @@ inline void _menu_service(const int index, PGM_P const name) { PSTR(MSG_BUTTON_RESET), PSTR(MSG_BUTTON_CANCEL), []{ print_job_timer.resetServiceInterval(index); - ui.completion_feedback(true); + #if HAS_BUZZER + ui.completion_feedback(); + #endif ui.reset_status(); ui.return_to_status(); }, diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index 379f41646f..efc424dc9a 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -562,7 +562,7 @@ void MarlinUI::status_screen() { if (old_frm != new_frm) { feedrate_percentage = new_frm; encoderPosition = 0; - #if ENABLED(BEEP_ON_FEEDRATE_CHANGE) + #if HAS_BUZZER && ENABLED(BEEP_ON_FEEDRATE_CHANGE) static millis_t next_beep; #ifndef GOT_MS const millis_t ms = millis(); @@ -608,8 +608,10 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { UNUSED(clear_buttons); #endif - // Buzz and wait. The delay is needed for buttons to settle! - buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ); + #if HAS_BUZZER + // Buzz and wait. Is the delay needed for buttons to settle? + buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ); + #endif #if HAS_LCD_MENU #if ENABLED(LCD_USE_I2C_BUZZER) diff --git a/Marlin/src/lcd/ultralcd.h b/Marlin/src/lcd/ultralcd.h index 5c5cee4fc1..10f37b36aa 100644 --- a/Marlin/src/lcd/ultralcd.h +++ b/Marlin/src/lcd/ultralcd.h @@ -258,15 +258,15 @@ public: #endif } - static inline void buzz(const long duration, const uint16_t freq) { - #if ENABLED(LCD_USE_I2C_BUZZER) - lcd.buzz(duration, freq); - #elif PIN_EXISTS(BEEPER) - buzzer.tone(duration, freq); - #else - UNUSED(duration); UNUSED(freq); - #endif - } + #if HAS_BUZZER + static inline void buzz(const long duration, const uint16_t freq) { + #if ENABLED(LCD_USE_I2C_BUZZER) + lcd.buzz(duration, freq); + #elif PIN_EXISTS(BEEPER) + buzzer.tone(duration, freq); + #endif + } + #endif // LCD implementations static void clear_lcd(); @@ -355,7 +355,9 @@ public: #endif static void quick_feedback(const bool clear_buttons=true); - static void completion_feedback(const bool good=true); + #if HAS_BUZZER + static void completion_feedback(const bool good=true); + #endif #if DISABLED(LIGHTWEIGHT_UI) static void draw_status_message(const bool blink); @@ -466,7 +468,11 @@ public: #endif #if ENABLED(G26_MESH_VALIDATION) - static inline void chirp() { buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ); } + static inline void chirp() { + #if HAS_BUZZER + buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ); + #endif + } #endif #if ENABLED(AUTO_BED_LEVELING_UBL) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 72e49dc06d..812a4739b6 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -68,7 +68,7 @@ #include "tool_change.h" #endif -#if HAS_BUZZER +#if HAS_BUZZER && PIN_EXISTS(BEEPER) #include "../libs/buzzer.h" #endif