Browse Source

BUZZ cleanup (#14760)

Ludy 4 years ago
parent
commit
c4bb458763

+ 5
- 1
Marlin/src/feature/pause.cpp View File

@@ -54,7 +54,11 @@
54 54
 #endif
55 55
 
56 56
 #include "../lcd/ultralcd.h"
57
-#include "../libs/buzzer.h"
57
+
58
+#if HAS_BUZZER
59
+  #include "../libs/buzzer.h"
60
+#endif
61
+
58 62
 #include "../libs/nozzle.h"
59 63
 #include "pause.h"
60 64
 

+ 1
- 1
Marlin/src/lcd/menu/game/brickout.cpp View File

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

+ 1
- 1
Marlin/src/lcd/menu/game/game.h View File

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

+ 23
- 9
Marlin/src/lcd/menu/menu.cpp View File

@@ -31,7 +31,9 @@
31 31
 #include "../../module/printcounter.h"
32 32
 #include "../../gcode/queue.h"
33 33
 #include "../../sd/cardreader.h"
34
-#include "../../libs/buzzer.h"
34
+#if HAS_BUZZER
35
+  #include "../../libs/buzzer.h"
36
+#endif
35 37
 
36 38
 #if ENABLED(EEPROM_SETTINGS)
37 39
   #include "../../module/configuration_store.h"
@@ -346,13 +348,15 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
346 348
     encoderTopLine = encoderLine;
347 349
 }
348 350
 
349
-void MarlinUI::completion_feedback(const bool good/*=true*/) {
350
-  if (good) {
351
-    BUZZ(100, 659);
352
-    BUZZ(100, 698);
351
+#if HAS_BUZZER
352
+  void MarlinUI::completion_feedback(const bool good/*=true*/) {
353
+    if (good) {
354
+      BUZZ(100, 659);
355
+      BUZZ(100, 698);
356
+    }
357
+    else BUZZ(20, 440);
353 358
   }
354
-  else BUZZ(20, 440);
355
-}
359
+#endif
356 360
 
357 361
 #if HAS_LINE_TO_Z
358 362
 
@@ -433,8 +437,18 @@ void MarlinUI::completion_feedback(const bool good/*=true*/) {
433 437
 #endif
434 438
 
435 439
 #if ENABLED(EEPROM_SETTINGS)
436
-  void lcd_store_settings()   { ui.completion_feedback(settings.save()); }
437
-  void lcd_load_settings()    { ui.completion_feedback(settings.load()); }
440
+  void lcd_store_settings() {
441
+    const bool saved = settings.save();
442
+    #if HAS_BUZZER
443
+      ui.completion_feedback(saved);
444
+    #endif
445
+  }
446
+  void lcd_load_settings() {
447
+    const bool loaded = settings.load();
448
+    #if HAS_BUZZER
449
+      ui.completion_feedback(loaded);
450
+    #endif
451
+  }
438 452
 #endif
439 453
 
440 454
 void _lcd_draw_homing() {

+ 11
- 3
Marlin/src/lcd/menu/menu_advanced.cpp View File

@@ -603,7 +603,12 @@ void menu_backlash();
603 603
     static void lcd_init_eeprom_confirm() {
604 604
       do_select_screen(
605 605
         PSTR(MSG_BUTTON_INIT), PSTR(MSG_BUTTON_CANCEL),
606
-        []{ ui.completion_feedback(settings.init_eeprom()); },
606
+        []{
607
+          const bool inited = settings.init_eeprom();
608
+          #if HAS_BUZZER
609
+            ui.completion_feedback(inited);
610
+          #endif
611
+        },
607 612
         ui.goto_previous_screen,
608 613
         PSTR(MSG_INIT_EEPROM), nullptr, PSTR("?")
609 614
       );
@@ -698,8 +703,11 @@ void menu_advanced_settings() {
698 703
       //
699 704
       // Toggle the SD Firmware Update state in EEPROM
700 705
       //
701
-      const bool new_state = !settings.sd_update_status();
702
-      ui.completion_feedback(settings.set_sd_update_status(new_state));
706
+      const bool new_state = !settings.sd_update_status(),
707
+                 didset = settings.set_sd_update_status(new_state);
708
+      #if HAS_BUZZER
709
+        ui.completion_feedback(didset);
710
+      #endif
703 711
       ui.return_to_status();
704 712
       if (new_state) LCD_MESSAGEPGM(MSG_RESET_PRINTER); else ui.reset_status();
705 713
     });

+ 3
- 1
Marlin/src/lcd/menu/menu_bed_leveling.cpp View File

@@ -77,7 +77,9 @@
77 77
         ui.synchronize(PSTR(MSG_LEVEL_BED_DONE));
78 78
       #endif
79 79
       ui.goto_previous_screen_no_defer();
80
-      ui.completion_feedback();
80
+      #if HAS_BUZZER
81
+        ui.completion_feedback();
82
+      #endif
81 83
     }
82 84
     if (ui.should_draw()) draw_menu_item_static(LCD_HEIGHT >= 4 ? 1 : 0, PSTR(MSG_LEVEL_BED_DONE));
83 85
     ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);

+ 3
- 1
Marlin/src/lcd/menu/menu_configuration.cpp View File

@@ -56,7 +56,9 @@ void menu_advanced_settings();
56 56
 
57 57
 static void lcd_factory_settings() {
58 58
   settings.reset();
59
-  ui.completion_feedback();
59
+  #if HAS_BUZZER
60
+    ui.completion_feedback();
61
+  #endif
60 62
 }
61 63
 
62 64
 #if ENABLED(LCD_PROGRESS_BAR_TEST)

+ 1
- 1
Marlin/src/lcd/menu/menu_custom.cpp View File

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

+ 3
- 1
Marlin/src/lcd/menu/menu_service.cpp View File

@@ -38,7 +38,9 @@ inline void _menu_service(const int index, PGM_P const name) {
38 38
     PSTR(MSG_BUTTON_RESET), PSTR(MSG_BUTTON_CANCEL),
39 39
     []{
40 40
       print_job_timer.resetServiceInterval(index);
41
-      ui.completion_feedback(true);
41
+      #if HAS_BUZZER
42
+        ui.completion_feedback();
43
+      #endif
42 44
       ui.reset_status();
43 45
       ui.return_to_status();
44 46
     },

+ 5
- 3
Marlin/src/lcd/ultralcd.cpp View File

@@ -562,7 +562,7 @@ void MarlinUI::status_screen() {
562 562
     if (old_frm != new_frm) {
563 563
       feedrate_percentage = new_frm;
564 564
       encoderPosition = 0;
565
-      #if ENABLED(BEEP_ON_FEEDRATE_CHANGE)
565
+      #if HAS_BUZZER && ENABLED(BEEP_ON_FEEDRATE_CHANGE)
566 566
         static millis_t next_beep;
567 567
         #ifndef GOT_MS
568 568
           const millis_t ms = millis();
@@ -608,8 +608,10 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) {
608 608
     UNUSED(clear_buttons);
609 609
   #endif
610 610
 
611
-  // Buzz and wait. The delay is needed for buttons to settle!
612
-  buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
611
+  #if HAS_BUZZER
612
+    // Buzz and wait. Is the delay needed for buttons to settle?
613
+    buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
614
+  #endif
613 615
 
614 616
   #if HAS_LCD_MENU
615 617
     #if ENABLED(LCD_USE_I2C_BUZZER)

+ 17
- 11
Marlin/src/lcd/ultralcd.h View File

@@ -258,15 +258,15 @@ public:
258 258
     #endif
259 259
   }
260 260
 
261
-  static inline void buzz(const long duration, const uint16_t freq) {
262
-    #if ENABLED(LCD_USE_I2C_BUZZER)
263
-      lcd.buzz(duration, freq);
264
-    #elif PIN_EXISTS(BEEPER)
265
-      buzzer.tone(duration, freq);
266
-    #else
267
-      UNUSED(duration); UNUSED(freq);
268
-    #endif
269
-  }
261
+  #if HAS_BUZZER
262
+    static inline void buzz(const long duration, const uint16_t freq) {
263
+      #if ENABLED(LCD_USE_I2C_BUZZER)
264
+        lcd.buzz(duration, freq);
265
+      #elif PIN_EXISTS(BEEPER)
266
+        buzzer.tone(duration, freq);
267
+      #endif
268
+    }
269
+  #endif
270 270
 
271 271
   // LCD implementations
272 272
   static void clear_lcd();
@@ -355,7 +355,9 @@ public:
355 355
       #endif
356 356
 
357 357
       static void quick_feedback(const bool clear_buttons=true);
358
-      static void completion_feedback(const bool good=true);
358
+      #if HAS_BUZZER
359
+        static void completion_feedback(const bool good=true);
360
+      #endif
359 361
 
360 362
       #if DISABLED(LIGHTWEIGHT_UI)
361 363
         static void draw_status_message(const bool blink);
@@ -466,7 +468,11 @@ public:
466 468
     #endif
467 469
 
468 470
     #if ENABLED(G26_MESH_VALIDATION)
469
-      static inline void chirp() { buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ); }
471
+      static inline void chirp() {
472
+        #if HAS_BUZZER
473
+          buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
474
+        #endif
475
+      }
470 476
     #endif
471 477
 
472 478
     #if ENABLED(AUTO_BED_LEVELING_UBL)

+ 1
- 1
Marlin/src/module/temperature.cpp View File

@@ -68,7 +68,7 @@
68 68
   #include "tool_change.h"
69 69
 #endif
70 70
 
71
-#if HAS_BUZZER
71
+#if HAS_BUZZER && PIN_EXISTS(BEEPER)
72 72
   #include "../libs/buzzer.h"
73 73
 #endif
74 74
 

Loading…
Cancel
Save