Browse Source

BUZZ cleanup (#14760)

pull/1/head
Ludy 5 years ago
committed by Scott Lahteine
parent
commit
c4bb458763
  1. 6
      Marlin/src/feature/pause.cpp
  2. 2
      Marlin/src/lcd/menu/game/brickout.cpp
  3. 2
      Marlin/src/lcd/menu/game/game.h
  4. 32
      Marlin/src/lcd/menu/menu.cpp
  5. 14
      Marlin/src/lcd/menu/menu_advanced.cpp
  6. 4
      Marlin/src/lcd/menu/menu_bed_leveling.cpp
  7. 4
      Marlin/src/lcd/menu/menu_configuration.cpp
  8. 2
      Marlin/src/lcd/menu/menu_custom.cpp
  9. 4
      Marlin/src/lcd/menu/menu_service.cpp
  10. 8
      Marlin/src/lcd/ultralcd.cpp
  11. 28
      Marlin/src/lcd/ultralcd.h
  12. 2
      Marlin/src/module/temperature.cpp

6
Marlin/src/feature/pause.cpp

@ -54,7 +54,11 @@
#endif #endif
#include "../lcd/ultralcd.h" #include "../lcd/ultralcd.h"
#include "../libs/buzzer.h"
#if HAS_BUZZER
#include "../libs/buzzer.h"
#endif
#include "../libs/nozzle.h" #include "../libs/nozzle.h"
#include "pause.h" #include "pause.h"

2
Marlin/src/lcd/menu/game/brickout.cpp

@ -79,7 +79,7 @@ void BrickoutGame::game_screen() {
} }
// Did the ball go below the bottom? // Did the ball go below the bottom?
else if (newy > BTOF(LCD_PIXEL_HEIGHT)) { else if (newy > BTOF(LCD_PIXEL_HEIGHT)) {
BUZZ(500, 75); _BUZZ(500, 75);
if (--bdat.balls_left) reset_ball(); else game_state = 0; if (--bdat.balls_left) reset_ball(); else game_state = 0;
break; // done break; // done
} }

2
Marlin/src/lcd/menu/game/game.h

@ -28,7 +28,7 @@
//#define MUTE_GAMES //#define MUTE_GAMES
#ifdef MUTE_GAMES #if ENABLED(MUTE_GAMES) || !HAS_BUZZER
#define _BUZZ(D,F) NOOP #define _BUZZ(D,F) NOOP
#else #else
#define _BUZZ(D,F) BUZZ(D,F) #define _BUZZ(D,F) BUZZ(D,F)

32
Marlin/src/lcd/menu/menu.cpp

@ -31,7 +31,9 @@
#include "../../module/printcounter.h" #include "../../module/printcounter.h"
#include "../../gcode/queue.h" #include "../../gcode/queue.h"
#include "../../sd/cardreader.h" #include "../../sd/cardreader.h"
#include "../../libs/buzzer.h" #if HAS_BUZZER
#include "../../libs/buzzer.h"
#endif
#if ENABLED(EEPROM_SETTINGS) #if ENABLED(EEPROM_SETTINGS)
#include "../../module/configuration_store.h" #include "../../module/configuration_store.h"
@ -346,13 +348,15 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
encoderTopLine = encoderLine; encoderTopLine = encoderLine;
} }
void MarlinUI::completion_feedback(const bool good/*=true*/) { #if HAS_BUZZER
if (good) { void MarlinUI::completion_feedback(const bool good/*=true*/) {
BUZZ(100, 659); if (good) {
BUZZ(100, 698); BUZZ(100, 659);
BUZZ(100, 698);
}
else BUZZ(20, 440);
} }
else BUZZ(20, 440); #endif
}
#if HAS_LINE_TO_Z #if HAS_LINE_TO_Z
@ -433,8 +437,18 @@ void MarlinUI::completion_feedback(const bool good/*=true*/) {
#endif #endif
#if ENABLED(EEPROM_SETTINGS) #if ENABLED(EEPROM_SETTINGS)
void lcd_store_settings() { ui.completion_feedback(settings.save()); } void lcd_store_settings() {
void lcd_load_settings() { ui.completion_feedback(settings.load()); } 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 #endif
void _lcd_draw_homing() { void _lcd_draw_homing() {

14
Marlin/src/lcd/menu/menu_advanced.cpp

@ -603,7 +603,12 @@ void menu_backlash();
static void lcd_init_eeprom_confirm() { static void lcd_init_eeprom_confirm() {
do_select_screen( do_select_screen(
PSTR(MSG_BUTTON_INIT), PSTR(MSG_BUTTON_CANCEL), 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, ui.goto_previous_screen,
PSTR(MSG_INIT_EEPROM), nullptr, PSTR("?") PSTR(MSG_INIT_EEPROM), nullptr, PSTR("?")
); );
@ -698,8 +703,11 @@ void menu_advanced_settings() {
// //
// Toggle the SD Firmware Update state in EEPROM // Toggle the SD Firmware Update state in EEPROM
// //
const bool new_state = !settings.sd_update_status(); const bool new_state = !settings.sd_update_status(),
ui.completion_feedback(settings.set_sd_update_status(new_state)); didset = settings.set_sd_update_status(new_state);
#if HAS_BUZZER
ui.completion_feedback(didset);
#endif
ui.return_to_status(); ui.return_to_status();
if (new_state) LCD_MESSAGEPGM(MSG_RESET_PRINTER); else ui.reset_status(); if (new_state) LCD_MESSAGEPGM(MSG_RESET_PRINTER); else ui.reset_status();
}); });

4
Marlin/src/lcd/menu/menu_bed_leveling.cpp

@ -77,7 +77,9 @@
ui.synchronize(PSTR(MSG_LEVEL_BED_DONE)); ui.synchronize(PSTR(MSG_LEVEL_BED_DONE));
#endif #endif
ui.goto_previous_screen_no_defer(); 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)); if (ui.should_draw()) draw_menu_item_static(LCD_HEIGHT >= 4 ? 1 : 0, PSTR(MSG_LEVEL_BED_DONE));
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT); ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);

4
Marlin/src/lcd/menu/menu_configuration.cpp

@ -56,7 +56,9 @@ void menu_advanced_settings();
static void lcd_factory_settings() { static void lcd_factory_settings() {
settings.reset(); settings.reset();
ui.completion_feedback(); #if HAS_BUZZER
ui.completion_feedback();
#endif
} }
#if ENABLED(LCD_PROGRESS_BAR_TEST) #if ENABLED(LCD_PROGRESS_BAR_TEST)

2
Marlin/src/lcd/menu/menu_custom.cpp

@ -39,7 +39,7 @@
void _lcd_user_gcode(PGM_P const cmd) { void _lcd_user_gcode(PGM_P const cmd) {
queue.inject_P(cmd); queue.inject_P(cmd);
#if ENABLED(USER_SCRIPT_AUDIBLE_FEEDBACK) #if ENABLED(USER_SCRIPT_AUDIBLE_FEEDBACK) && HAS_BUZZER
ui.completion_feedback(); ui.completion_feedback();
#endif #endif
#if ENABLED(USER_SCRIPT_RETURN) #if ENABLED(USER_SCRIPT_RETURN)

4
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), PSTR(MSG_BUTTON_RESET), PSTR(MSG_BUTTON_CANCEL),
[]{ []{
print_job_timer.resetServiceInterval(index); print_job_timer.resetServiceInterval(index);
ui.completion_feedback(true); #if HAS_BUZZER
ui.completion_feedback();
#endif
ui.reset_status(); ui.reset_status();
ui.return_to_status(); ui.return_to_status();
}, },

8
Marlin/src/lcd/ultralcd.cpp

@ -562,7 +562,7 @@ void MarlinUI::status_screen() {
if (old_frm != new_frm) { if (old_frm != new_frm) {
feedrate_percentage = new_frm; feedrate_percentage = new_frm;
encoderPosition = 0; encoderPosition = 0;
#if ENABLED(BEEP_ON_FEEDRATE_CHANGE) #if HAS_BUZZER && ENABLED(BEEP_ON_FEEDRATE_CHANGE)
static millis_t next_beep; static millis_t next_beep;
#ifndef GOT_MS #ifndef GOT_MS
const millis_t ms = millis(); const millis_t ms = millis();
@ -608,8 +608,10 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) {
UNUSED(clear_buttons); UNUSED(clear_buttons);
#endif #endif
// Buzz and wait. The delay is needed for buttons to settle! #if HAS_BUZZER
buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ); // 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 HAS_LCD_MENU
#if ENABLED(LCD_USE_I2C_BUZZER) #if ENABLED(LCD_USE_I2C_BUZZER)

28
Marlin/src/lcd/ultralcd.h

@ -258,15 +258,15 @@ public:
#endif #endif
} }
static inline void buzz(const long duration, const uint16_t freq) { #if HAS_BUZZER
#if ENABLED(LCD_USE_I2C_BUZZER) static inline void buzz(const long duration, const uint16_t freq) {
lcd.buzz(duration, freq); #if ENABLED(LCD_USE_I2C_BUZZER)
#elif PIN_EXISTS(BEEPER) lcd.buzz(duration, freq);
buzzer.tone(duration, freq); #elif PIN_EXISTS(BEEPER)
#else buzzer.tone(duration, freq);
UNUSED(duration); UNUSED(freq); #endif
#endif }
} #endif
// LCD implementations // LCD implementations
static void clear_lcd(); static void clear_lcd();
@ -355,7 +355,9 @@ public:
#endif #endif
static void quick_feedback(const bool clear_buttons=true); 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) #if DISABLED(LIGHTWEIGHT_UI)
static void draw_status_message(const bool blink); static void draw_status_message(const bool blink);
@ -466,7 +468,11 @@ public:
#endif #endif
#if ENABLED(G26_MESH_VALIDATION) #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 #endif
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)

2
Marlin/src/module/temperature.cpp

@ -68,7 +68,7 @@
#include "tool_change.h" #include "tool_change.h"
#endif #endif
#if HAS_BUZZER #if HAS_BUZZER && PIN_EXISTS(BEEPER)
#include "../libs/buzzer.h" #include "../libs/buzzer.h"
#endif #endif

Loading…
Cancel
Save