Browse Source

✨ SOUND_ON_DEFAULT option (#24102)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
Pauli Jokela 2 years ago
parent
commit
04fe50936e
No account linked to committer's email address

+ 1
- 0
Marlin/Configuration_adv.h View File

@@ -1337,6 +1337,7 @@
1337 1337
 
1338 1338
 #if ANY(HAS_DISPLAY, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
1339 1339
   //#define SOUND_MENU_ITEM   // Add a mute option to the LCD menu
1340
+  #define SOUND_ON_DEFAULT    // Buzzer/speaker default enabled state
1340 1341
 #endif
1341 1342
 
1342 1343
 #if EITHER(HAS_DISPLAY, DWIN_LCD_PROUI)

+ 3
- 3
Marlin/src/MarlinCore.cpp View File

@@ -97,7 +97,7 @@
97 97
   #include "feature/host_actions.h"
98 98
 #endif
99 99
 
100
-#if USE_BEEPER
100
+#if HAS_BEEPER
101 101
   #include "libs/buzzer.h"
102 102
 #endif
103 103
 
@@ -827,7 +827,7 @@ void idle(bool no_stepper_sleep/*=false*/) {
827 827
   TERN_(PRINTCOUNTER, print_job_timer.tick());
828 828
 
829 829
   // Update the Beeper queue
830
-  TERN_(USE_BEEPER, buzzer.tick());
830
+  TERN_(HAS_BEEPER, buzzer.tick());
831 831
 
832 832
   // Handle UI input / draw events
833 833
   TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update());
@@ -1287,7 +1287,7 @@ void setup() {
1287 1287
   calibrate_delay_loop();
1288 1288
 
1289 1289
   // Init buzzer pin(s)
1290
-  #if USE_BEEPER
1290
+  #if HAS_BEEPER
1291 1291
     SETUP_RUN(buzzer.init());
1292 1292
   #endif
1293 1293
 

+ 2
- 2
Marlin/src/feature/spindle_laser.h View File

@@ -30,7 +30,7 @@
30 30
 
31 31
 #include "spindle_laser_types.h"
32 32
 
33
-#if USE_BEEPER
33
+#if HAS_BEEPER
34 34
   #include "../libs/buzzer.h"
35 35
 #endif
36 36
 
@@ -272,7 +272,7 @@ public:
272 272
        * If not set defaults to 80% power
273 273
        */
274 274
       static void test_fire_pulse() {
275
-        TERN_(USE_BEEPER, buzzer.tone(30, 3000));
275
+        TERN_(HAS_BEEPER, buzzer.tone(30, 3000));
276 276
         enable_forward();                  // Turn Laser on (Spindle speak but same funct)
277 277
         delay(testPulse);                  // Delay for time set by user in pulse ms menu screen.
278 278
         disable();                         // Turn laser off

+ 2
- 2
Marlin/src/inc/Conditionals_post.h View File

@@ -3552,9 +3552,9 @@
3552 3552
  * Buzzer/Speaker
3553 3553
  */
3554 3554
 #if PIN_EXISTS(BEEPER)
3555
-  #define USE_BEEPER 1
3555
+  #define HAS_BEEPER 1
3556 3556
 #endif
3557
-#if USE_BEEPER || ANY(LCD_USE_I2C_BUZZER, PCA9632_BUZZER)
3557
+#if ANY(HAS_BEEPER, LCD_USE_I2C_BUZZER, PCA9632_BUZZER)
3558 3558
   #define HAS_BUZZER 1
3559 3559
 #endif
3560 3560
 

+ 1
- 1
Marlin/src/lcd/HD44780/marlinui_HD44780.cpp View File

@@ -121,7 +121,7 @@ static void createChar_P(const char c, const byte * const ptr) {
121 121
 
122 122
 #if ENABLED(LCD_USE_I2C_BUZZER)
123 123
   void MarlinUI::buzz(const long duration, const uint16_t freq) {
124
-    if (!buzzer_enabled) return;
124
+    if (!sound_on) return;
125 125
     lcd.buzz(duration, freq);
126 126
   }
127 127
 #endif

+ 1
- 1
Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp View File

@@ -301,7 +301,7 @@ uint8_t MarlinUI::read_slow_buttons() {
301 301
 // Duration in ms, freq in Hz
302 302
 void MarlinUI::buzz(const long duration, const uint16_t freq) {
303 303
   if (!PanelDetected) return;
304
-  if (!buzzer_enabled) return;
304
+  if (!sound_on) return;
305 305
   #if ENABLED(TFTGLCD_PANEL_SPI)
306 306
     WRITE(TFTGLCD_CS, LOW);
307 307
     SPI_SEND_ONE(BUZZER);

+ 1
- 5
Marlin/src/lcd/e3v2/common/encoder.cpp View File

@@ -51,11 +51,7 @@ ENCODER_Rate EncoderRate;
51 51
 // TODO: Replace with ui.quick_feedback
52 52
 void Encoder_tick() {
53 53
   #if PIN_EXISTS(BEEPER)
54
-    if (ui.buzzer_enabled) {
55
-      WRITE(BEEPER_PIN, HIGH);
56
-      delay(10);
57
-      WRITE(BEEPER_PIN, LOW);
58
-    }
54
+    if (ui.sound_on) buzzer.click(10);
59 55
   #endif
60 56
 }
61 57
 

+ 5
- 5
Marlin/src/lcd/e3v2/jyersui/dwin.cpp View File

@@ -2587,11 +2587,11 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
2587 2587
           case ADVANCED_BEEPER:
2588 2588
             if (draw) {
2589 2589
               Draw_Menu_Item(row, ICON_Version, F("LCD Beeper"));
2590
-              Draw_Checkbox(row, ui.buzzer_enabled);
2590
+              Draw_Checkbox(row, ui.sound_on);
2591 2591
             }
2592 2592
             else {
2593
-              ui.buzzer_enabled = !ui.buzzer_enabled;
2594
-              Draw_Checkbox(row, ui.buzzer_enabled);
2593
+              ui.sound_on = !ui.sound_on;
2594
+              Draw_Checkbox(row, ui.sound_on);
2595 2595
             }
2596 2596
             break;
2597 2597
         #endif
@@ -4602,7 +4602,7 @@ void CrealityDWINClass::Screen_Update() {
4602 4602
 }
4603 4603
 
4604 4604
 void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) {
4605
-  if (ui.buzzer_enabled)
4605
+  if (ui.sound_on)
4606 4606
     DONE_BUZZ(success);
4607 4607
   else
4608 4608
     Update_Status(success ? "Success" : "Failed");
@@ -4646,7 +4646,7 @@ void CrealityDWINClass::Reset_Settings() {
4646 4646
   eeprom_settings.coordinates_split_line = 0;
4647 4647
   TERN_(AUTO_BED_LEVELING_UBL, mesh_conf.tilt_grid = eeprom_settings.tilt_grid_size + 1);
4648 4648
   corner_pos = eeprom_settings.corner_pos / 10.0f;
4649
-  TERN_(SOUND_MENU_ITEM, ui.buzzer_enabled = true);
4649
+  TERN_(SOUND_MENU_ITEM, ui.sound_on = ENABLED(SOUND_ON_DEFAULT));
4650 4650
   Redraw_Screen();
4651 4651
 }
4652 4652
 

+ 3
- 3
Marlin/src/lcd/e3v2/proui/dwin.cpp View File

@@ -2106,8 +2106,8 @@ void SetPID(celsius_t t, heater_id_t h) {
2106 2106
 
2107 2107
 #if ENABLED(SOUND_MENU_ITEM)
2108 2108
   void SetEnableSound() {
2109
-    ui.buzzer_enabled = !ui.buzzer_enabled;
2110
-    Draw_Chkb_Line(CurrentMenu->line(), ui.buzzer_enabled);
2109
+    ui.sound_on = !ui.sound_on;
2110
+    Draw_Chkb_Line(CurrentMenu->line(), ui.sound_on);
2111 2111
     DWIN_UpdateLCD();
2112 2112
   }
2113 2113
 #endif
@@ -2638,7 +2638,7 @@ void onDrawLanguage(MenuItemClass* menuitem, int8_t line) {
2638 2638
 #endif
2639 2639
 
2640 2640
 #if ENABLED(SOUND_MENU_ITEM)
2641
-  void onDrawEnableSound(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, ui.buzzer_enabled); }
2641
+  void onDrawEnableSound(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, ui.sound_on); }
2642 2642
 #endif
2643 2643
 
2644 2644
 #ifdef BLTOUCH_HS_MODE

+ 4
- 5
Marlin/src/lcd/extui/anycubic_chiron/Tunes.cpp View File

@@ -35,6 +35,8 @@
35 35
 
36 36
 #include "../../../inc/MarlinConfigPre.h"
37 37
 
38
+// TODO: Use Marlin's built-in tone player instead.
39
+
38 40
 #if ENABLED(ANYCUBIC_LCD_CHIRON)
39 41
 
40 42
 #include "Tunes.h"
@@ -44,15 +46,12 @@ namespace Anycubic {
44 46
 
45 47
   void PlayTune(uint8_t beeperPin, const uint16_t *tune, uint8_t speed=1) {
46 48
     uint8_t pos = 1;
47
-    uint16_t wholenotelen = tune[0] / speed;
49
+    const uint16_t wholenotelen = tune[0] / speed;
48 50
     do {
49
-      uint16_t freq = tune[pos];
50
-      uint16_t notelen = wholenotelen / tune[pos + 1];
51
-
51
+      const uint16_t freq = tune[pos], notelen = wholenotelen / tune[pos + 1];
52 52
       ::tone(beeperPin, freq, notelen);
53 53
       ExtUI::delay_ms(notelen);
54 54
       pos += 2;
55
-
56 55
       if (pos >= MAX_TUNE_LENGTH) break;
57 56
     } while (tune[pos] != n_END);
58 57
   }

+ 1
- 3
Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp View File

@@ -42,9 +42,7 @@ namespace ExtUI {
42 42
   void onMediaError()     { AnycubicTFT.OnSDCardError(); }
43 43
   void onMediaRemoved()   { AnycubicTFT.OnSDCardStateChange(false); }
44 44
   void onPlayTone(const uint16_t frequency, const uint16_t duration) {
45
-    #if ENABLED(SPEAKER)
46
-      ::tone(BEEPER_PIN, frequency, duration);
47
-    #endif
45
+    TERN_(SPEAKER, ::tone(BEEPER_PIN, frequency, duration));
48 46
   }
49 47
   void onPrintTimerStarted()  { AnycubicTFT.OnPrintTimerStarted(); }
50 48
   void onPrintTimerPaused()   { AnycubicTFT.OnPrintTimerPaused(); }

+ 3
- 6
Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp View File

@@ -160,6 +160,8 @@
160 160
     #endif
161 161
   }
162 162
 
163
+  #include "../../../libs/buzzer.h"
164
+
163 165
   void init_test_gpio() {
164 166
     endstops.init();
165 167
 
@@ -201,12 +203,7 @@
201 203
     #endif
202 204
   }
203 205
 
204
-  void mks_test_beeper() {
205
-    WRITE(BEEPER_PIN, HIGH);
206
-    delay(100);
207
-    WRITE(BEEPER_PIN, LOW);
208
-    delay(100);
209
-  }
206
+  void mks_test_beeper() { buzzer.click(100); }
210 207
 
211 208
   #if ENABLED(SDSUPPORT)
212 209
 

+ 7
- 8
Marlin/src/lcd/marlinui.cpp View File

@@ -118,19 +118,18 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
118 118
 #endif
119 119
 
120 120
 #if ENABLED(SOUND_MENU_ITEM)
121
-  bool MarlinUI::buzzer_enabled = true;
121
+  bool MarlinUI::sound_on = ENABLED(SOUND_ON_DEFAULT);
122 122
 #endif
123 123
 
124
-#if EITHER(PCA9632_BUZZER, USE_BEEPER)
125
-  #include "../libs/buzzer.h" // for BUZZ() macro
124
+#if EITHER(PCA9632_BUZZER, HAS_BEEPER)
126 125
   #if ENABLED(PCA9632_BUZZER)
127 126
     #include "../feature/leds/pca9632.h"
128 127
   #endif
129 128
   void MarlinUI::buzz(const long duration, const uint16_t freq) {
130
-    if (!buzzer_enabled) return;
129
+    if (!sound_on) return;
131 130
     #if ENABLED(PCA9632_BUZZER)
132 131
       PCA9632_buzz(duration, freq);
133
-    #elif USE_BEEPER
132
+    #elif HAS_BEEPER
134 133
       buzzer.tone(duration, freq);
135 134
     #endif
136 135
   }
@@ -694,7 +693,7 @@ void MarlinUI::init() {
694 693
             const millis_t ms = millis();
695 694
           #endif
696 695
           if (ELAPSED(ms, next_beep)) {
697
-            buzz(FEEDRATE_CHANGE_BEEP_DURATION, FEEDRATE_CHANGE_BEEP_FREQUENCY);
696
+            BUZZ(FEEDRATE_CHANGE_BEEP_DURATION, FEEDRATE_CHANGE_BEEP_FREQUENCY);
698 697
             next_beep = ms + 500UL;
699 698
           }
700 699
         #endif
@@ -748,7 +747,7 @@ void MarlinUI::init() {
748 747
 
749 748
     #if HAS_CHIRP
750 749
       chirp(); // Buzz and wait. Is the delay needed for buttons to settle?
751
-      #if BOTH(HAS_MARLINUI_MENU, USE_BEEPER)
750
+      #if BOTH(HAS_MARLINUI_MENU, HAS_BEEPER)
752 751
         for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); }
753 752
       #elif HAS_MARLINUI_MENU
754 753
         delay(10);
@@ -1646,7 +1645,7 @@ void MarlinUI::init() {
1646 1645
 
1647 1646
   void MarlinUI::flow_fault() {
1648 1647
     LCD_ALERTMESSAGE(MSG_FLOWMETER_FAULT);
1649
-    TERN_(HAS_BUZZER, buzz(1000, 440));
1648
+    BUZZ(1000, 440);
1650 1649
     TERN_(HAS_MARLINUI_MENU, return_to_status());
1651 1650
   }
1652 1651
 

+ 9
- 11
Marlin/src/lcd/marlinui.h View File

@@ -21,15 +21,12 @@
21 21
  */
22 22
 #pragma once
23 23
 
24
+#include "../inc/MarlinConfig.h"
24 25
 #include "../sd/cardreader.h"
25 26
 #include "../module/motion.h"
26
-#include "buttons.h"
27
+#include "../libs/buzzer.h"
27 28
 
28
-#include "../inc/MarlinConfig.h"
29
-
30
-#if HAS_BUZZER
31
-  #include "../libs/buzzer.h"
32
-#endif
29
+#include "buttons.h"
33 30
 
34 31
 #if ENABLED(TOUCH_SCREEN_CALIBRATION)
35 32
   #include "tft_io/touch_calibration.h"
@@ -192,6 +189,9 @@ typedef bool (*statusResetFunc_t)();
192 189
 //////////// MarlinUI Singleton ////////////
193 190
 ////////////////////////////////////////////
194 191
 
192
+class MarlinUI;
193
+extern MarlinUI ui;
194
+
195 195
 class MarlinUI {
196 196
 public:
197 197
 
@@ -225,9 +225,9 @@ public:
225 225
   #endif
226 226
 
227 227
   #if ENABLED(SOUND_MENU_ITEM)
228
-    static bool buzzer_enabled; // Initialized by settings.load()
228
+    static bool sound_on; // Initialized by settings.load()
229 229
   #else
230
-    static constexpr bool buzzer_enabled = true;
230
+    static constexpr bool sound_on = true;
231 231
   #endif
232 232
 
233 233
   #if HAS_BUZZER
@@ -235,7 +235,7 @@ public:
235 235
   #endif
236 236
 
237 237
   FORCE_INLINE static void chirp() {
238
-    TERN_(HAS_CHIRP, buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ));
238
+    TERN_(HAS_CHIRP, TERN(HAS_BUZZER, buzz, BUZZ)(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ));
239 239
   }
240 240
 
241 241
   #if ENABLED(LCD_HAS_STATUS_INDICATORS)
@@ -786,8 +786,6 @@ private:
786 786
   #endif
787 787
 };
788 788
 
789
-extern MarlinUI ui;
790
-
791 789
 #define LCD_MESSAGE_F(S)       ui.set_status(F(S))
792 790
 #define LCD_MESSAGE(M)         ui.set_status(GET_TEXT_F(M))
793 791
 #define LCD_ALERTMESSAGE_F(S)  ui.set_alert_status(F(S))

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

@@ -247,7 +247,7 @@ static void _lcd_level_bed_corners_get_next_position() {
247 247
       probe_triggered = PROBE_TRIGGERED();
248 248
       if (probe_triggered) {
249 249
         endstops.hit_on_purpose();
250
-        TERN_(LEVEL_CORNERS_AUDIO_FEEDBACK, ui.buzz(200, 600));
250
+        TERN_(LEVEL_CORNERS_AUDIO_FEEDBACK, BUZZ(200, 600));
251 251
       }
252 252
       idle();
253 253
     }

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

@@ -574,7 +574,7 @@ void menu_configuration() {
574 574
   #endif
575 575
 
576 576
   #if ENABLED(SOUND_MENU_ITEM)
577
-    EDIT_ITEM(bool, MSG_SOUND, &ui.buzzer_enabled, []{ ui.chirp(); });
577
+    EDIT_ITEM(bool, MSG_SOUND, &ui.sound_on, []{ ui.chirp(); });
578 578
   #endif
579 579
 
580 580
   #if ENABLED(EEPROM_SETTINGS)

+ 1
- 1
Marlin/src/lcd/tft/ui_1024x600.cpp View File

@@ -596,7 +596,7 @@ MotionAxisState motionAxisState;
596 596
 static void quick_feedback() {
597 597
   #if HAS_CHIRP
598 598
     ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle?
599
-    #if BOTH(HAS_MARLINUI_MENU, USE_BEEPER)
599
+    #if BOTH(HAS_MARLINUI_MENU, HAS_BEEPER)
600 600
       for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); }
601 601
     #elif HAS_MARLINUI_MENU
602 602
       delay(10);

+ 1
- 1
Marlin/src/lcd/tft/ui_320x240.cpp View File

@@ -578,7 +578,7 @@ MotionAxisState motionAxisState;
578 578
 static void quick_feedback() {
579 579
   #if HAS_CHIRP
580 580
     ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle?
581
-    #if BOTH(HAS_MARLINUI_MENU, USE_BEEPER)
581
+    #if BOTH(HAS_MARLINUI_MENU, HAS_BEEPER)
582 582
       for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); }
583 583
     #elif HAS_MARLINUI_MENU
584 584
       delay(10);

+ 1
- 1
Marlin/src/lcd/tft/ui_480x320.cpp View File

@@ -583,7 +583,7 @@ MotionAxisState motionAxisState;
583 583
 static void quick_feedback() {
584 584
   #if HAS_CHIRP
585 585
     ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle?
586
-    #if BOTH(HAS_MARLINUI_MENU, USE_BEEPER)
586
+    #if BOTH(HAS_MARLINUI_MENU, HAS_BEEPER)
587 587
       for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); }
588 588
     #elif HAS_MARLINUI_MENU
589 589
       delay(10);

+ 4
- 4
Marlin/src/libs/buzzer.cpp View File

@@ -22,7 +22,7 @@
22 22
 
23 23
 #include "../inc/MarlinConfig.h"
24 24
 
25
-#if USE_BEEPER
25
+#if HAS_BEEPER
26 26
 
27 27
 #include "buzzer.h"
28 28
 #include "../module/temperature.h"
@@ -45,7 +45,7 @@ Buzzer buzzer;
45 45
  * @param frequency Frequency of the tone in hertz
46 46
  */
47 47
 void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) {
48
-  if (!ui.buzzer_enabled) return;
48
+  if (!ui.sound_on) return;
49 49
   while (buffer.isFull()) {
50 50
     tick();
51 51
     thermalManager.manage_heater();
@@ -55,7 +55,7 @@ void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) {
55 55
 }
56 56
 
57 57
 void Buzzer::tick() {
58
-  if (!ui.buzzer_enabled) return;
58
+  if (!ui.sound_on) return;
59 59
   const millis_t now = millis();
60 60
 
61 61
   if (!state.endtime) {
@@ -81,4 +81,4 @@ void Buzzer::tick() {
81 81
   else if (ELAPSED(now, state.endtime)) reset();
82 82
 }
83 83
 
84
-#endif // USE_BEEPER
84
+#endif // HAS_BEEPER

+ 16
- 14
Marlin/src/libs/buzzer.h View File

@@ -23,7 +23,7 @@
23 23
 
24 24
 #include "../inc/MarlinConfig.h"
25 25
 
26
-#if USE_BEEPER
26
+#if HAS_BEEPER
27 27
 
28 28
   #include "circularqueue.h"
29 29
 
@@ -62,18 +62,6 @@
62 62
       FORCE_INLINE static void invert() { TOGGLE(BEEPER_PIN); }
63 63
 
64 64
       /**
65
-       * @brief Turn off a digital PIN
66
-       * @details Alias of digitalWrite(PIN, LOW) using FastIO
67
-       */
68
-      FORCE_INLINE static void off() { WRITE(BEEPER_PIN, LOW); }
69
-
70
-      /**
71
-       * @brief Turn on a digital PIN
72
-       * @details Alias of digitalWrite(PIN, HIGH) using FastIO
73
-       */
74
-      FORCE_INLINE static void on() { WRITE(BEEPER_PIN, HIGH); }
75
-
76
-      /**
77 65
        * @brief Resets the state of the class
78 66
        * @details Brings the class state to a known one.
79 67
        */
@@ -92,6 +80,20 @@
92 80
       }
93 81
 
94 82
       /**
83
+       * @brief Turn on a digital PIN
84
+       * @details Alias of digitalWrite(PIN, HIGH) using FastIO
85
+       */
86
+      FORCE_INLINE static void on() { WRITE(BEEPER_PIN, HIGH); }
87
+
88
+      /**
89
+       * @brief Turn off a digital PIN
90
+       * @details Alias of digitalWrite(PIN, LOW) using FastIO
91
+       */
92
+      FORCE_INLINE static void off() { WRITE(BEEPER_PIN, LOW); }
93
+
94
+      static void click(const uint16_t duration) { on(); delay(duration); off(); }
95
+
96
+      /**
95 97
        * @brief Add a tone to the queue
96 98
        * @details Adds a tone_t structure to the ring buffer, will block IO if the
97 99
        *          queue is full waiting for one slot to get available.
@@ -118,8 +120,8 @@
118 120
 #elif HAS_BUZZER
119 121
 
120 122
   // Buzz indirectly via the MarlinUI instance
121
-  #include "../lcd/marlinui.h"
122 123
   #define BUZZ(d,f) ui.buzz(d,f)
124
+  #include "../lcd/marlinui.h"
123 125
 
124 126
 #else
125 127
 

+ 7
- 5
Marlin/src/module/settings.cpp View File

@@ -541,7 +541,7 @@ typedef struct SettingsDataStruct {
541 541
   // Buzzer enable/disable
542 542
   //
543 543
   #if ENABLED(SOUND_MENU_ITEM)
544
-    bool buzzer_enabled;
544
+    bool sound_on;
545 545
   #endif
546 546
 
547 547
   //
@@ -1576,7 +1576,7 @@ void MarlinSettings::postprocess() {
1576 1576
     // Buzzer enable/disable
1577 1577
     //
1578 1578
     #if ENABLED(SOUND_MENU_ITEM)
1579
-      EEPROM_WRITE(ui.buzzer_enabled);
1579
+      EEPROM_WRITE(ui.sound_on);
1580 1580
     #endif
1581 1581
 
1582 1582
     //
@@ -2546,8 +2546,8 @@ void MarlinSettings::postprocess() {
2546 2546
       // Buzzer enable/disable
2547 2547
       //
2548 2548
       #if ENABLED(SOUND_MENU_ITEM)
2549
-        _FIELD_TEST(buzzer_enabled);
2550
-        EEPROM_READ(ui.buzzer_enabled);
2549
+        _FIELD_TEST(sound_on);
2550
+        EEPROM_READ(ui.sound_on);
2551 2551
       #endif
2552 2552
 
2553 2553
       //
@@ -2945,7 +2945,9 @@ void MarlinSettings::reset() {
2945 2945
   //
2946 2946
   // Buzzer enable/disable
2947 2947
   //
2948
-  TERN_(SOUND_MENU_ITEM, ui.buzzer_enabled = true);
2948
+  #if ENABLED(SOUND_MENU_ITEM)
2949
+    ui.sound_on = ENABLED(SOUND_ON_DEFAULT);
2950
+  #endif
2949 2951
 
2950 2952
   //
2951 2953
   // Magnetic Parking Extruder

+ 5
- 9
Marlin/src/module/temperature.cpp View File

@@ -178,7 +178,7 @@
178 178
   #include "tool_change.h"
179 179
 #endif
180 180
 
181
-#if USE_BEEPER
181
+#if HAS_BEEPER
182 182
   #include "../libs/buzzer.h"
183 183
 #endif
184 184
 
@@ -1224,18 +1224,14 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) {
1224 1224
 inline void loud_kill(FSTR_P const lcd_msg, const heater_id_t heater_id) {
1225 1225
   marlin_state = MF_KILLED;
1226 1226
   thermalManager.disable_all_heaters();
1227
-  #if USE_BEEPER
1227
+  #if HAS_BEEPER
1228 1228
     for (uint8_t i = 20; i--;) {
1229
-      WRITE(BEEPER_PIN, HIGH);
1230
-      delay(25);
1231 1229
       watchdog_refresh();
1232
-      WRITE(BEEPER_PIN, LOW);
1233
-      delay(40);
1234
-      watchdog_refresh();
1235
-      delay(40);
1230
+      buzzer.click(25);
1231
+      delay(80);
1236 1232
       watchdog_refresh();
1237 1233
     }
1238
-    WRITE(BEEPER_PIN, HIGH);
1234
+    buzzer.on();
1239 1235
   #endif
1240 1236
   #if ENABLED(NOZZLE_PARK_FEATURE)
1241 1237
     if (!homing_needed_error()) {

Loading…
Cancel
Save