✨ SOUND_ON_DEFAULT option (#24102)
This commit is contained in:
		
				
					committed by
					
						
						Scott Lahteine
					
				
			
			
				
	
			
			
			
						parent
						
							b2b5b85045
						
					
				
				
					commit
					3443a9e18b
				
			@@ -1321,6 +1321,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#if ANY(HAS_DISPLAY, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
 | 
					#if ANY(HAS_DISPLAY, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
 | 
				
			||||||
  //#define SOUND_MENU_ITEM   // Add a mute option to the LCD menu
 | 
					  //#define SOUND_MENU_ITEM   // Add a mute option to the LCD menu
 | 
				
			||||||
 | 
					  #define SOUND_ON_DEFAULT    // Buzzer/speaker default enabled state
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if EITHER(HAS_DISPLAY, DWIN_LCD_PROUI)
 | 
					#if EITHER(HAS_DISPLAY, DWIN_LCD_PROUI)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -97,7 +97,7 @@
 | 
				
			|||||||
  #include "feature/host_actions.h"
 | 
					  #include "feature/host_actions.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if USE_BEEPER
 | 
					#if HAS_BEEPER
 | 
				
			||||||
  #include "libs/buzzer.h"
 | 
					  #include "libs/buzzer.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -824,7 +824,7 @@ void idle(bool no_stepper_sleep/*=false*/) {
 | 
				
			|||||||
  TERN_(PRINTCOUNTER, print_job_timer.tick());
 | 
					  TERN_(PRINTCOUNTER, print_job_timer.tick());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Update the Beeper queue
 | 
					  // Update the Beeper queue
 | 
				
			||||||
  TERN_(USE_BEEPER, buzzer.tick());
 | 
					  TERN_(HAS_BEEPER, buzzer.tick());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Handle UI input / draw events
 | 
					  // Handle UI input / draw events
 | 
				
			||||||
  TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update());
 | 
					  TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update());
 | 
				
			||||||
@@ -1275,7 +1275,7 @@ void setup() {
 | 
				
			|||||||
  calibrate_delay_loop();
 | 
					  calibrate_delay_loop();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Init buzzer pin(s)
 | 
					  // Init buzzer pin(s)
 | 
				
			||||||
  #if USE_BEEPER
 | 
					  #if HAS_BEEPER
 | 
				
			||||||
    SETUP_RUN(buzzer.init());
 | 
					    SETUP_RUN(buzzer.init());
 | 
				
			||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,7 +30,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "spindle_laser_types.h"
 | 
					#include "spindle_laser_types.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if USE_BEEPER
 | 
					#if HAS_BEEPER
 | 
				
			||||||
  #include "../libs/buzzer.h"
 | 
					  #include "../libs/buzzer.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -272,7 +272,7 @@ public:
 | 
				
			|||||||
       * If not set defaults to 80% power
 | 
					       * If not set defaults to 80% power
 | 
				
			||||||
       */
 | 
					       */
 | 
				
			||||||
      static void test_fire_pulse() {
 | 
					      static void test_fire_pulse() {
 | 
				
			||||||
        TERN_(USE_BEEPER, buzzer.tone(30, 3000));
 | 
					        TERN_(HAS_BEEPER, buzzer.tone(30, 3000));
 | 
				
			||||||
        enable_forward();                  // Turn Laser on (Spindle speak but same funct)
 | 
					        enable_forward();                  // Turn Laser on (Spindle speak but same funct)
 | 
				
			||||||
        delay(testPulse);                  // Delay for time set by user in pulse ms menu screen.
 | 
					        delay(testPulse);                  // Delay for time set by user in pulse ms menu screen.
 | 
				
			||||||
        disable();                         // Turn laser off
 | 
					        disable();                         // Turn laser off
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3301,9 +3301,9 @@
 | 
				
			|||||||
 * Buzzer/Speaker
 | 
					 * Buzzer/Speaker
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
#if PIN_EXISTS(BEEPER)
 | 
					#if PIN_EXISTS(BEEPER)
 | 
				
			||||||
  #define USE_BEEPER 1
 | 
					  #define HAS_BEEPER 1
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#if USE_BEEPER || ANY(LCD_USE_I2C_BUZZER, PCA9632_BUZZER)
 | 
					#if ANY(HAS_BEEPER, LCD_USE_I2C_BUZZER, PCA9632_BUZZER)
 | 
				
			||||||
  #define HAS_BUZZER 1
 | 
					  #define HAS_BUZZER 1
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -121,7 +121,7 @@ static void createChar_P(const char c, const byte * const ptr) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#if ENABLED(LCD_USE_I2C_BUZZER)
 | 
					#if ENABLED(LCD_USE_I2C_BUZZER)
 | 
				
			||||||
  void MarlinUI::buzz(const long duration, const uint16_t freq) {
 | 
					  void MarlinUI::buzz(const long duration, const uint16_t freq) {
 | 
				
			||||||
    if (!buzzer_enabled) return;
 | 
					    if (!sound_on) return;
 | 
				
			||||||
    lcd.buzz(duration, freq);
 | 
					    lcd.buzz(duration, freq);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -301,7 +301,7 @@ uint8_t MarlinUI::read_slow_buttons() {
 | 
				
			|||||||
// Duration in ms, freq in Hz
 | 
					// Duration in ms, freq in Hz
 | 
				
			||||||
void MarlinUI::buzz(const long duration, const uint16_t freq) {
 | 
					void MarlinUI::buzz(const long duration, const uint16_t freq) {
 | 
				
			||||||
  if (!PanelDetected) return;
 | 
					  if (!PanelDetected) return;
 | 
				
			||||||
  if (!buzzer_enabled) return;
 | 
					  if (!sound_on) return;
 | 
				
			||||||
  #if ENABLED(TFTGLCD_PANEL_SPI)
 | 
					  #if ENABLED(TFTGLCD_PANEL_SPI)
 | 
				
			||||||
    WRITE(TFTGLCD_CS, LOW);
 | 
					    WRITE(TFTGLCD_CS, LOW);
 | 
				
			||||||
    SPI_SEND_ONE(BUZZER);
 | 
					    SPI_SEND_ONE(BUZZER);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -51,11 +51,7 @@ ENCODER_Rate EncoderRate;
 | 
				
			|||||||
// TODO: Replace with ui.quick_feedback
 | 
					// TODO: Replace with ui.quick_feedback
 | 
				
			||||||
void Encoder_tick() {
 | 
					void Encoder_tick() {
 | 
				
			||||||
  #if PIN_EXISTS(BEEPER)
 | 
					  #if PIN_EXISTS(BEEPER)
 | 
				
			||||||
    if (ui.buzzer_enabled) {
 | 
					    if (ui.sound_on) buzzer.click(10);
 | 
				
			||||||
      WRITE(BEEPER_PIN, HIGH);
 | 
					 | 
				
			||||||
      delay(10);
 | 
					 | 
				
			||||||
      WRITE(BEEPER_PIN, LOW);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2585,11 +2585,11 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
 | 
				
			|||||||
          case ADVANCED_BEEPER:
 | 
					          case ADVANCED_BEEPER:
 | 
				
			||||||
            if (draw) {
 | 
					            if (draw) {
 | 
				
			||||||
              Draw_Menu_Item(row, ICON_Version, F("LCD Beeper"));
 | 
					              Draw_Menu_Item(row, ICON_Version, F("LCD Beeper"));
 | 
				
			||||||
              Draw_Checkbox(row, ui.buzzer_enabled);
 | 
					              Draw_Checkbox(row, ui.sound_on);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else {
 | 
					            else {
 | 
				
			||||||
              ui.buzzer_enabled = !ui.buzzer_enabled;
 | 
					              ui.sound_on = !ui.sound_on;
 | 
				
			||||||
              Draw_Checkbox(row, ui.buzzer_enabled);
 | 
					              Draw_Checkbox(row, ui.sound_on);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        #endif
 | 
					        #endif
 | 
				
			||||||
@@ -4600,7 +4600,7 @@ void CrealityDWINClass::Screen_Update() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) {
 | 
					void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) {
 | 
				
			||||||
  if (ui.buzzer_enabled)
 | 
					  if (ui.sound_on)
 | 
				
			||||||
    DONE_BUZZ(success);
 | 
					    DONE_BUZZ(success);
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    Update_Status(success ? "Success" : "Failed");
 | 
					    Update_Status(success ? "Success" : "Failed");
 | 
				
			||||||
@@ -4644,7 +4644,7 @@ void CrealityDWINClass::Reset_Settings() {
 | 
				
			|||||||
  eeprom_settings.coordinates_split_line = 0;
 | 
					  eeprom_settings.coordinates_split_line = 0;
 | 
				
			||||||
  TERN_(AUTO_BED_LEVELING_UBL, mesh_conf.tilt_grid = eeprom_settings.tilt_grid_size + 1);
 | 
					  TERN_(AUTO_BED_LEVELING_UBL, mesh_conf.tilt_grid = eeprom_settings.tilt_grid_size + 1);
 | 
				
			||||||
  corner_pos = eeprom_settings.corner_pos / 10.0f;
 | 
					  corner_pos = eeprom_settings.corner_pos / 10.0f;
 | 
				
			||||||
  TERN_(SOUND_MENU_ITEM, ui.buzzer_enabled = true);
 | 
					  TERN_(SOUND_MENU_ITEM, ui.sound_on = ENABLED(SOUND_ON_DEFAULT));
 | 
				
			||||||
  Redraw_Screen();
 | 
					  Redraw_Screen();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2155,8 +2155,8 @@ void SetPID(celsius_t t, heater_id_t h) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#if ENABLED(SOUND_MENU_ITEM)
 | 
					#if ENABLED(SOUND_MENU_ITEM)
 | 
				
			||||||
  void SetEnableSound() {
 | 
					  void SetEnableSound() {
 | 
				
			||||||
    ui.buzzer_enabled = !ui.buzzer_enabled;
 | 
					    ui.sound_on = !ui.sound_on;
 | 
				
			||||||
    Draw_Chkb_Line(CurrentMenu->line(), ui.buzzer_enabled);
 | 
					    Draw_Chkb_Line(CurrentMenu->line(), ui.sound_on);
 | 
				
			||||||
    DWIN_UpdateLCD();
 | 
					    DWIN_UpdateLCD();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,6 +35,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "../../../inc/MarlinConfigPre.h"
 | 
					#include "../../../inc/MarlinConfigPre.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// TODO: Use Marlin's built-in tone player instead.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if ENABLED(ANYCUBIC_LCD_CHIRON)
 | 
					#if ENABLED(ANYCUBIC_LCD_CHIRON)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "Tunes.h"
 | 
					#include "Tunes.h"
 | 
				
			||||||
@@ -44,15 +46,12 @@ namespace Anycubic {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  void PlayTune(uint8_t beeperPin, const uint16_t *tune, uint8_t speed=1) {
 | 
					  void PlayTune(uint8_t beeperPin, const uint16_t *tune, uint8_t speed=1) {
 | 
				
			||||||
    uint8_t pos = 1;
 | 
					    uint8_t pos = 1;
 | 
				
			||||||
    uint16_t wholenotelen = tune[0] / speed;
 | 
					    const uint16_t wholenotelen = tune[0] / speed;
 | 
				
			||||||
    do {
 | 
					    do {
 | 
				
			||||||
      uint16_t freq = tune[pos];
 | 
					      const uint16_t freq = tune[pos], notelen = wholenotelen / tune[pos + 1];
 | 
				
			||||||
      uint16_t notelen = wholenotelen / tune[pos + 1];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      ::tone(beeperPin, freq, notelen);
 | 
					      ::tone(beeperPin, freq, notelen);
 | 
				
			||||||
      ExtUI::delay_ms(notelen);
 | 
					      ExtUI::delay_ms(notelen);
 | 
				
			||||||
      pos += 2;
 | 
					      pos += 2;
 | 
				
			||||||
 | 
					 | 
				
			||||||
      if (pos >= MAX_TUNE_LENGTH) break;
 | 
					      if (pos >= MAX_TUNE_LENGTH) break;
 | 
				
			||||||
    } while (tune[pos] != n_END);
 | 
					    } while (tune[pos] != n_END);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,9 +42,7 @@ namespace ExtUI {
 | 
				
			|||||||
  void onMediaError()     { AnycubicTFT.OnSDCardError(); }
 | 
					  void onMediaError()     { AnycubicTFT.OnSDCardError(); }
 | 
				
			||||||
  void onMediaRemoved()   { AnycubicTFT.OnSDCardStateChange(false); }
 | 
					  void onMediaRemoved()   { AnycubicTFT.OnSDCardStateChange(false); }
 | 
				
			||||||
  void onPlayTone(const uint16_t frequency, const uint16_t duration) {
 | 
					  void onPlayTone(const uint16_t frequency, const uint16_t duration) {
 | 
				
			||||||
    #if ENABLED(SPEAKER)
 | 
					    TERN_(SPEAKER, ::tone(BEEPER_PIN, frequency, duration));
 | 
				
			||||||
      ::tone(BEEPER_PIN, frequency, duration);
 | 
					 | 
				
			||||||
    #endif
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  void onPrintTimerStarted()  { AnycubicTFT.OnPrintTimerStarted(); }
 | 
					  void onPrintTimerStarted()  { AnycubicTFT.OnPrintTimerStarted(); }
 | 
				
			||||||
  void onPrintTimerPaused()   { AnycubicTFT.OnPrintTimerPaused(); }
 | 
					  void onPrintTimerPaused()   { AnycubicTFT.OnPrintTimerPaused(); }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -160,6 +160,8 @@
 | 
				
			|||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  #include "../../../libs/buzzer.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void init_test_gpio() {
 | 
					  void init_test_gpio() {
 | 
				
			||||||
    endstops.init();
 | 
					    endstops.init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -201,12 +203,7 @@
 | 
				
			|||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void mks_test_beeper() {
 | 
					  void mks_test_beeper() { buzzer.click(100); }
 | 
				
			||||||
    WRITE(BEEPER_PIN, HIGH);
 | 
					 | 
				
			||||||
    delay(100);
 | 
					 | 
				
			||||||
    WRITE(BEEPER_PIN, LOW);
 | 
					 | 
				
			||||||
    delay(100);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  #if ENABLED(SDSUPPORT)
 | 
					  #if ENABLED(SDSUPPORT)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -118,19 +118,18 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if ENABLED(SOUND_MENU_ITEM)
 | 
					#if ENABLED(SOUND_MENU_ITEM)
 | 
				
			||||||
  bool MarlinUI::buzzer_enabled = true;
 | 
					  bool MarlinUI::sound_on = ENABLED(SOUND_ON_DEFAULT);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if EITHER(PCA9632_BUZZER, USE_BEEPER)
 | 
					#if EITHER(PCA9632_BUZZER, HAS_BEEPER)
 | 
				
			||||||
  #include "../libs/buzzer.h" // for BUZZ() macro
 | 
					 | 
				
			||||||
  #if ENABLED(PCA9632_BUZZER)
 | 
					  #if ENABLED(PCA9632_BUZZER)
 | 
				
			||||||
    #include "../feature/leds/pca9632.h"
 | 
					    #include "../feature/leds/pca9632.h"
 | 
				
			||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
  void MarlinUI::buzz(const long duration, const uint16_t freq) {
 | 
					  void MarlinUI::buzz(const long duration, const uint16_t freq) {
 | 
				
			||||||
    if (!buzzer_enabled) return;
 | 
					    if (!sound_on) return;
 | 
				
			||||||
    #if ENABLED(PCA9632_BUZZER)
 | 
					    #if ENABLED(PCA9632_BUZZER)
 | 
				
			||||||
      PCA9632_buzz(duration, freq);
 | 
					      PCA9632_buzz(duration, freq);
 | 
				
			||||||
    #elif USE_BEEPER
 | 
					    #elif HAS_BEEPER
 | 
				
			||||||
      buzzer.tone(duration, freq);
 | 
					      buzzer.tone(duration, freq);
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -685,7 +684,7 @@ void MarlinUI::init() {
 | 
				
			|||||||
            const millis_t ms = millis();
 | 
					            const millis_t ms = millis();
 | 
				
			||||||
          #endif
 | 
					          #endif
 | 
				
			||||||
          if (ELAPSED(ms, next_beep)) {
 | 
					          if (ELAPSED(ms, next_beep)) {
 | 
				
			||||||
            buzz(FEEDRATE_CHANGE_BEEP_DURATION, FEEDRATE_CHANGE_BEEP_FREQUENCY);
 | 
					            BUZZ(FEEDRATE_CHANGE_BEEP_DURATION, FEEDRATE_CHANGE_BEEP_FREQUENCY);
 | 
				
			||||||
            next_beep = ms + 500UL;
 | 
					            next_beep = ms + 500UL;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        #endif
 | 
					        #endif
 | 
				
			||||||
@@ -739,7 +738,7 @@ void MarlinUI::init() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    #if HAS_CHIRP
 | 
					    #if HAS_CHIRP
 | 
				
			||||||
      chirp(); // Buzz and wait. Is the delay needed for buttons to settle?
 | 
					      chirp(); // Buzz and wait. Is the delay needed for buttons to settle?
 | 
				
			||||||
      #if BOTH(HAS_MARLINUI_MENU, USE_BEEPER)
 | 
					      #if BOTH(HAS_MARLINUI_MENU, HAS_BEEPER)
 | 
				
			||||||
        for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); }
 | 
					        for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); }
 | 
				
			||||||
      #elif HAS_MARLINUI_MENU
 | 
					      #elif HAS_MARLINUI_MENU
 | 
				
			||||||
        delay(10);
 | 
					        delay(10);
 | 
				
			||||||
@@ -1632,7 +1631,7 @@ void MarlinUI::init() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  void MarlinUI::flow_fault() {
 | 
					  void MarlinUI::flow_fault() {
 | 
				
			||||||
    LCD_ALERTMESSAGE(MSG_FLOWMETER_FAULT);
 | 
					    LCD_ALERTMESSAGE(MSG_FLOWMETER_FAULT);
 | 
				
			||||||
    TERN_(HAS_BUZZER, buzz(1000, 440));
 | 
					    BUZZ(1000, 440);
 | 
				
			||||||
    TERN_(HAS_MARLINUI_MENU, return_to_status());
 | 
					    TERN_(HAS_MARLINUI_MENU, return_to_status());
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,15 +21,12 @@
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "../inc/MarlinConfig.h"
 | 
				
			||||||
#include "../sd/cardreader.h"
 | 
					#include "../sd/cardreader.h"
 | 
				
			||||||
#include "../module/motion.h"
 | 
					#include "../module/motion.h"
 | 
				
			||||||
#include "buttons.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "../inc/MarlinConfig.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if HAS_BUZZER
 | 
					 | 
				
			||||||
#include "../libs/buzzer.h"
 | 
					#include "../libs/buzzer.h"
 | 
				
			||||||
#endif
 | 
					
 | 
				
			||||||
 | 
					#include "buttons.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
 | 
					#if ENABLED(TOUCH_SCREEN_CALIBRATION)
 | 
				
			||||||
  #include "tft_io/touch_calibration.h"
 | 
					  #include "tft_io/touch_calibration.h"
 | 
				
			||||||
@@ -192,6 +189,9 @@ typedef bool (*statusResetFunc_t)();
 | 
				
			|||||||
//////////// MarlinUI Singleton ////////////
 | 
					//////////// MarlinUI Singleton ////////////
 | 
				
			||||||
////////////////////////////////////////////
 | 
					////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class MarlinUI;
 | 
				
			||||||
 | 
					extern MarlinUI ui;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class MarlinUI {
 | 
					class MarlinUI {
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -225,9 +225,9 @@ public:
 | 
				
			|||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  #if ENABLED(SOUND_MENU_ITEM)
 | 
					  #if ENABLED(SOUND_MENU_ITEM)
 | 
				
			||||||
    static bool buzzer_enabled; // Initialized by settings.load()
 | 
					    static bool sound_on; // Initialized by settings.load()
 | 
				
			||||||
  #else
 | 
					  #else
 | 
				
			||||||
    static constexpr bool buzzer_enabled = true;
 | 
					    static constexpr bool sound_on = true;
 | 
				
			||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  #if HAS_BUZZER
 | 
					  #if HAS_BUZZER
 | 
				
			||||||
@@ -235,7 +235,7 @@ public:
 | 
				
			|||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  FORCE_INLINE static void chirp() {
 | 
					  FORCE_INLINE static void chirp() {
 | 
				
			||||||
    TERN_(HAS_CHIRP, buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ));
 | 
					    TERN_(HAS_CHIRP, TERN(HAS_BUZZER, buzz, BUZZ)(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  #if ENABLED(LCD_HAS_STATUS_INDICATORS)
 | 
					  #if ENABLED(LCD_HAS_STATUS_INDICATORS)
 | 
				
			||||||
@@ -778,8 +778,6 @@ private:
 | 
				
			|||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern MarlinUI ui;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define LCD_MESSAGE_F(S)       ui.set_status(F(S))
 | 
					#define LCD_MESSAGE_F(S)       ui.set_status(F(S))
 | 
				
			||||||
#define LCD_MESSAGE(M)         ui.set_status(GET_TEXT_F(M))
 | 
					#define LCD_MESSAGE(M)         ui.set_status(GET_TEXT_F(M))
 | 
				
			||||||
#define LCD_ALERTMESSAGE_F(S)  ui.set_alert_status(F(S))
 | 
					#define LCD_ALERTMESSAGE_F(S)  ui.set_alert_status(F(S))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -247,7 +247,7 @@ static void _lcd_level_bed_corners_get_next_position() {
 | 
				
			|||||||
      probe_triggered = PROBE_TRIGGERED();
 | 
					      probe_triggered = PROBE_TRIGGERED();
 | 
				
			||||||
      if (probe_triggered) {
 | 
					      if (probe_triggered) {
 | 
				
			||||||
        endstops.hit_on_purpose();
 | 
					        endstops.hit_on_purpose();
 | 
				
			||||||
        TERN_(LEVEL_CORNERS_AUDIO_FEEDBACK, ui.buzz(200, 600));
 | 
					        TERN_(LEVEL_CORNERS_AUDIO_FEEDBACK, BUZZ(200, 600));
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      idle();
 | 
					      idle();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -574,7 +574,7 @@ void menu_configuration() {
 | 
				
			|||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  #if ENABLED(SOUND_MENU_ITEM)
 | 
					  #if ENABLED(SOUND_MENU_ITEM)
 | 
				
			||||||
    EDIT_ITEM(bool, MSG_SOUND, &ui.buzzer_enabled, []{ ui.chirp(); });
 | 
					    EDIT_ITEM(bool, MSG_SOUND, &ui.sound_on, []{ ui.chirp(); });
 | 
				
			||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  #if ENABLED(EEPROM_SETTINGS)
 | 
					  #if ENABLED(EEPROM_SETTINGS)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -596,7 +596,7 @@ MotionAxisState motionAxisState;
 | 
				
			|||||||
static void quick_feedback() {
 | 
					static void quick_feedback() {
 | 
				
			||||||
  #if HAS_CHIRP
 | 
					  #if HAS_CHIRP
 | 
				
			||||||
    ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle?
 | 
					    ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle?
 | 
				
			||||||
    #if BOTH(HAS_MARLINUI_MENU, USE_BEEPER)
 | 
					    #if BOTH(HAS_MARLINUI_MENU, HAS_BEEPER)
 | 
				
			||||||
      for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); }
 | 
					      for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); }
 | 
				
			||||||
    #elif HAS_MARLINUI_MENU
 | 
					    #elif HAS_MARLINUI_MENU
 | 
				
			||||||
      delay(10);
 | 
					      delay(10);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -578,7 +578,7 @@ MotionAxisState motionAxisState;
 | 
				
			|||||||
static void quick_feedback() {
 | 
					static void quick_feedback() {
 | 
				
			||||||
  #if HAS_CHIRP
 | 
					  #if HAS_CHIRP
 | 
				
			||||||
    ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle?
 | 
					    ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle?
 | 
				
			||||||
    #if BOTH(HAS_MARLINUI_MENU, USE_BEEPER)
 | 
					    #if BOTH(HAS_MARLINUI_MENU, HAS_BEEPER)
 | 
				
			||||||
      for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); }
 | 
					      for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); }
 | 
				
			||||||
    #elif HAS_MARLINUI_MENU
 | 
					    #elif HAS_MARLINUI_MENU
 | 
				
			||||||
      delay(10);
 | 
					      delay(10);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -583,7 +583,7 @@ MotionAxisState motionAxisState;
 | 
				
			|||||||
static void quick_feedback() {
 | 
					static void quick_feedback() {
 | 
				
			||||||
  #if HAS_CHIRP
 | 
					  #if HAS_CHIRP
 | 
				
			||||||
    ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle?
 | 
					    ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle?
 | 
				
			||||||
    #if BOTH(HAS_MARLINUI_MENU, USE_BEEPER)
 | 
					    #if BOTH(HAS_MARLINUI_MENU, HAS_BEEPER)
 | 
				
			||||||
      for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); }
 | 
					      for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); }
 | 
				
			||||||
    #elif HAS_MARLINUI_MENU
 | 
					    #elif HAS_MARLINUI_MENU
 | 
				
			||||||
      delay(10);
 | 
					      delay(10);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,7 +22,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "../inc/MarlinConfig.h"
 | 
					#include "../inc/MarlinConfig.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if USE_BEEPER
 | 
					#if HAS_BEEPER
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "buzzer.h"
 | 
					#include "buzzer.h"
 | 
				
			||||||
#include "../module/temperature.h"
 | 
					#include "../module/temperature.h"
 | 
				
			||||||
@@ -45,7 +45,7 @@ Buzzer buzzer;
 | 
				
			|||||||
 * @param frequency Frequency of the tone in hertz
 | 
					 * @param frequency Frequency of the tone in hertz
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) {
 | 
					void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) {
 | 
				
			||||||
  if (!ui.buzzer_enabled) return;
 | 
					  if (!ui.sound_on) return;
 | 
				
			||||||
  while (buffer.isFull()) {
 | 
					  while (buffer.isFull()) {
 | 
				
			||||||
    tick();
 | 
					    tick();
 | 
				
			||||||
    thermalManager.manage_heater();
 | 
					    thermalManager.manage_heater();
 | 
				
			||||||
@@ -55,7 +55,7 @@ void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Buzzer::tick() {
 | 
					void Buzzer::tick() {
 | 
				
			||||||
  if (!ui.buzzer_enabled) return;
 | 
					  if (!ui.sound_on) return;
 | 
				
			||||||
  const millis_t now = millis();
 | 
					  const millis_t now = millis();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!state.endtime) {
 | 
					  if (!state.endtime) {
 | 
				
			||||||
@@ -81,4 +81,4 @@ void Buzzer::tick() {
 | 
				
			|||||||
  else if (ELAPSED(now, state.endtime)) reset();
 | 
					  else if (ELAPSED(now, state.endtime)) reset();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // USE_BEEPER
 | 
					#endif // HAS_BEEPER
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,7 +23,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "../inc/MarlinConfig.h"
 | 
					#include "../inc/MarlinConfig.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if USE_BEEPER
 | 
					#if HAS_BEEPER
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  #include "circularqueue.h"
 | 
					  #include "circularqueue.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -61,18 +61,6 @@
 | 
				
			|||||||
       */
 | 
					       */
 | 
				
			||||||
      FORCE_INLINE static void invert() { TOGGLE(BEEPER_PIN); }
 | 
					      FORCE_INLINE static void invert() { TOGGLE(BEEPER_PIN); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /**
 | 
					 | 
				
			||||||
       * @brief Turn off a digital PIN
 | 
					 | 
				
			||||||
       * @details Alias of digitalWrite(PIN, LOW) using FastIO
 | 
					 | 
				
			||||||
       */
 | 
					 | 
				
			||||||
      FORCE_INLINE static void off() { WRITE(BEEPER_PIN, LOW); }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      /**
 | 
					 | 
				
			||||||
       * @brief Turn on a digital PIN
 | 
					 | 
				
			||||||
       * @details Alias of digitalWrite(PIN, HIGH) using FastIO
 | 
					 | 
				
			||||||
       */
 | 
					 | 
				
			||||||
      FORCE_INLINE static void on() { WRITE(BEEPER_PIN, HIGH); }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      /**
 | 
					      /**
 | 
				
			||||||
       * @brief Resets the state of the class
 | 
					       * @brief Resets the state of the class
 | 
				
			||||||
       * @details Brings the class state to a known one.
 | 
					       * @details Brings the class state to a known one.
 | 
				
			||||||
@@ -91,6 +79,20 @@
 | 
				
			|||||||
        reset();
 | 
					        reset();
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      /**
 | 
				
			||||||
 | 
					       * @brief Turn on a digital PIN
 | 
				
			||||||
 | 
					       * @details Alias of digitalWrite(PIN, HIGH) using FastIO
 | 
				
			||||||
 | 
					       */
 | 
				
			||||||
 | 
					      FORCE_INLINE static void on() { WRITE(BEEPER_PIN, HIGH); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      /**
 | 
				
			||||||
 | 
					       * @brief Turn off a digital PIN
 | 
				
			||||||
 | 
					       * @details Alias of digitalWrite(PIN, LOW) using FastIO
 | 
				
			||||||
 | 
					       */
 | 
				
			||||||
 | 
					      FORCE_INLINE static void off() { WRITE(BEEPER_PIN, LOW); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      static void click(const uint16_t duration) { on(); delay(duration); off(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /**
 | 
					      /**
 | 
				
			||||||
       * @brief Add a tone to the queue
 | 
					       * @brief Add a tone to the queue
 | 
				
			||||||
       * @details Adds a tone_t structure to the ring buffer, will block IO if the
 | 
					       * @details Adds a tone_t structure to the ring buffer, will block IO if the
 | 
				
			||||||
@@ -118,8 +120,8 @@
 | 
				
			|||||||
#elif HAS_BUZZER
 | 
					#elif HAS_BUZZER
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Buzz indirectly via the MarlinUI instance
 | 
					  // Buzz indirectly via the MarlinUI instance
 | 
				
			||||||
  #include "../lcd/marlinui.h"
 | 
					 | 
				
			||||||
  #define BUZZ(d,f) ui.buzz(d,f)
 | 
					  #define BUZZ(d,f) ui.buzz(d,f)
 | 
				
			||||||
 | 
					  #include "../lcd/marlinui.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -531,7 +531,7 @@ typedef struct SettingsDataStruct {
 | 
				
			|||||||
  // Buzzer enable/disable
 | 
					  // Buzzer enable/disable
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  #if ENABLED(SOUND_MENU_ITEM)
 | 
					  #if ENABLED(SOUND_MENU_ITEM)
 | 
				
			||||||
    bool buzzer_enabled;
 | 
					    bool sound_on;
 | 
				
			||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
@@ -1537,7 +1537,7 @@ void MarlinSettings::postprocess() {
 | 
				
			|||||||
    // Buzzer enable/disable
 | 
					    // Buzzer enable/disable
 | 
				
			||||||
    //
 | 
					    //
 | 
				
			||||||
    #if ENABLED(SOUND_MENU_ITEM)
 | 
					    #if ENABLED(SOUND_MENU_ITEM)
 | 
				
			||||||
      EEPROM_WRITE(ui.buzzer_enabled);
 | 
					      EEPROM_WRITE(ui.sound_on);
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //
 | 
					    //
 | 
				
			||||||
@@ -2479,8 +2479,8 @@ void MarlinSettings::postprocess() {
 | 
				
			|||||||
      // Buzzer enable/disable
 | 
					      // Buzzer enable/disable
 | 
				
			||||||
      //
 | 
					      //
 | 
				
			||||||
      #if ENABLED(SOUND_MENU_ITEM)
 | 
					      #if ENABLED(SOUND_MENU_ITEM)
 | 
				
			||||||
        _FIELD_TEST(buzzer_enabled);
 | 
					        _FIELD_TEST(sound_on);
 | 
				
			||||||
        EEPROM_READ(ui.buzzer_enabled);
 | 
					        EEPROM_READ(ui.sound_on);
 | 
				
			||||||
      #endif
 | 
					      #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      //
 | 
					      //
 | 
				
			||||||
@@ -2858,7 +2858,9 @@ void MarlinSettings::reset() {
 | 
				
			|||||||
  //
 | 
					  //
 | 
				
			||||||
  // Buzzer enable/disable
 | 
					  // Buzzer enable/disable
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  TERN_(SOUND_MENU_ITEM, ui.buzzer_enabled = true);
 | 
					  #if ENABLED(SOUND_MENU_ITEM)
 | 
				
			||||||
 | 
					    ui.sound_on = ENABLED(SOUND_ON_DEFAULT);
 | 
				
			||||||
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  // Magnetic Parking Extruder
 | 
					  // Magnetic Parking Extruder
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -173,7 +173,7 @@
 | 
				
			|||||||
  #include "tool_change.h"
 | 
					  #include "tool_change.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if USE_BEEPER
 | 
					#if HAS_BEEPER
 | 
				
			||||||
  #include "../libs/buzzer.h"
 | 
					  #include "../libs/buzzer.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -986,18 +986,14 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) {
 | 
				
			|||||||
inline void loud_kill(FSTR_P const lcd_msg, const heater_id_t heater_id) {
 | 
					inline void loud_kill(FSTR_P const lcd_msg, const heater_id_t heater_id) {
 | 
				
			||||||
  marlin_state = MF_KILLED;
 | 
					  marlin_state = MF_KILLED;
 | 
				
			||||||
  thermalManager.disable_all_heaters();
 | 
					  thermalManager.disable_all_heaters();
 | 
				
			||||||
  #if USE_BEEPER
 | 
					  #if HAS_BEEPER
 | 
				
			||||||
    for (uint8_t i = 20; i--;) {
 | 
					    for (uint8_t i = 20; i--;) {
 | 
				
			||||||
      WRITE(BEEPER_PIN, HIGH);
 | 
					 | 
				
			||||||
      delay(25);
 | 
					 | 
				
			||||||
      watchdog_refresh();
 | 
					      watchdog_refresh();
 | 
				
			||||||
      WRITE(BEEPER_PIN, LOW);
 | 
					      buzzer.click(25);
 | 
				
			||||||
      delay(40);
 | 
					      delay(80);
 | 
				
			||||||
      watchdog_refresh();
 | 
					 | 
				
			||||||
      delay(40);
 | 
					 | 
				
			||||||
      watchdog_refresh();
 | 
					      watchdog_refresh();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    WRITE(BEEPER_PIN, HIGH);
 | 
					    buzzer.on();
 | 
				
			||||||
  #endif
 | 
					  #endif
 | 
				
			||||||
  #if ENABLED(NOZZLE_PARK_FEATURE)
 | 
					  #if ENABLED(NOZZLE_PARK_FEATURE)
 | 
				
			||||||
    if (!homing_needed_error()) {
 | 
					    if (!homing_needed_error()) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user