Quellcode durchsuchen

"Sound: ON/OFF" menu item (#19901)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Lucas Seiki Oshiro vor 3 Jahren
Ursprung
Commit
c0b4f4eb47
Es ist kein Account mit der E-Mail-Adresse des Committers verbunden

+ 3
- 0
Marlin/Configuration_adv.h Datei anzeigen

@@ -1090,6 +1090,9 @@
1090 1090
   // BACK menu items keep the highlight at the top
1091 1091
   //#define TURBO_BACK_MENU_ITEM
1092 1092
 
1093
+  // Add a mute option to the LCD menu
1094
+  //#define SOUND_MENU_ITEM
1095
+
1093 1096
   /**
1094 1097
    * LED Control Menu
1095 1098
    * Add LED Control to the LCD menu

+ 10
- 6
Marlin/src/inc/Conditionals_post.h Datei anzeigen

@@ -2505,11 +2505,11 @@
2505 2505
 /**
2506 2506
  * Buzzer/Speaker
2507 2507
  */
2508
-#if PIN_EXISTS(BEEPER) || ANY(LCD_USE_I2C_BUZZER, PCA9632_BUZZER)
2508
+#if PIN_EXISTS(BEEPER)
2509
+  #define USE_BEEPER 1
2510
+#endif
2511
+#if USE_BEEPER || ANY(LCD_USE_I2C_BUZZER, PCA9632_BUZZER)
2509 2512
   #define HAS_BUZZER 1
2510
-  #if PIN_EXISTS(BEEPER)
2511
-    #define USE_BEEPER 1
2512
-  #endif
2513 2513
 #endif
2514 2514
 
2515 2515
 #if ENABLED(LCD_USE_I2C_BUZZER)
@@ -2528,8 +2528,12 @@
2528 2528
   #endif
2529 2529
 #endif
2530 2530
 
2531
-#if HAS_BUZZER && LCD_FEEDBACK_FREQUENCY_DURATION_MS && LCD_FEEDBACK_FREQUENCY_HZ
2532
-  #define HAS_CHIRP 1
2531
+#if HAS_BUZZER
2532
+  #if LCD_FEEDBACK_FREQUENCY_DURATION_MS && LCD_FEEDBACK_FREQUENCY_HZ
2533
+    #define HAS_CHIRP 1
2534
+  #endif
2535
+#else
2536
+  #undef SOUND_MENU_ITEM   // No buzzer menu item without a buzzer
2533 2537
 #endif
2534 2538
 
2535 2539
 /**

+ 1
- 0
Marlin/src/lcd/HD44780/marlinui_HD44780.cpp Datei anzeigen

@@ -113,6 +113,7 @@ static void createChar_P(const char c, const byte * const ptr) {
113 113
 
114 114
 #if ENABLED(LCD_USE_I2C_BUZZER)
115 115
   void MarlinUI::buzz(const long duration, const uint16_t freq) {
116
+    if (!buzzer_enabled) return;
116 117
     lcd.buzz(duration, freq);
117 118
   }
118 119
 #endif

+ 1
- 0
Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp Datei anzeigen

@@ -289,6 +289,7 @@ uint8_t MarlinUI::read_slow_buttons(void) {
289 289
 // Duration in ms, freq in Hz
290 290
 void MarlinUI::buzz(const long duration, const uint16_t freq) {
291 291
   if (!PanelDetected) return;
292
+  if (!buzzer_enabled) return;
292 293
   #if ENABLED(TFTGLCD_PANEL_SPI)
293 294
     WRITE(TFTGLCD_CS, LOW);
294 295
     SPI_SEND_ONE(BUZZER);

+ 1
- 0
Marlin/src/lcd/language/language_en.h Datei anzeigen

@@ -659,6 +659,7 @@ namespace Language_en {
659 659
   PROGMEM Language_Str MSG_REHEATING                       = _UxGT("Reheating...");
660 660
 
661 661
   PROGMEM Language_Str MSG_PROBE_WIZARD                    = _UxGT("Z Probe Wizard");
662
+  PROGMEM Language_Str MSG_SOUND                           = _UxGT("Sound");
662 663
 }
663 664
 
664 665
 #if FAN_COUNT == 1

+ 5
- 0
Marlin/src/lcd/marlinui.cpp Datei anzeigen

@@ -74,12 +74,17 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
74 74
   #endif
75 75
 #endif
76 76
 
77
+#if ENABLED(SOUND_MENU_ITEM)
78
+  bool MarlinUI::buzzer_enabled = true;
79
+#endif
80
+
77 81
 #if EITHER(PCA9632_BUZZER, USE_BEEPER)
78 82
   #include "../libs/buzzer.h" // for BUZZ() macro
79 83
   #if ENABLED(PCA9632_BUZZER)
80 84
     #include "../feature/leds/pca9632.h"
81 85
   #endif
82 86
   void MarlinUI::buzz(const long duration, const uint16_t freq) {
87
+    if (!buzzer_enabled) return;
83 88
     #if ENABLED(PCA9632_BUZZER)
84 89
       PCA9632_buzz(duration, freq);
85 90
     #elif USE_BEEPER

+ 6
- 0
Marlin/src/lcd/marlinui.h Datei anzeigen

@@ -292,6 +292,12 @@ public:
292 292
     TERN_(HAS_LCD_MENU, currentScreen = status_screen);
293 293
   }
294 294
 
295
+  #if ENABLED(SOUND_MENU_ITEM)
296
+    static bool buzzer_enabled; // Initialized by settings.load()
297
+  #else
298
+    static constexpr bool buzzer_enabled = true;
299
+  #endif
300
+
295 301
   #if HAS_BUZZER
296 302
     static void buzz(const long duration, const uint16_t freq);
297 303
   #endif

+ 8
- 0
Marlin/src/lcd/menu/menu_configuration.cpp Datei anzeigen

@@ -45,6 +45,10 @@
45 45
   #endif
46 46
 #endif
47 47
 
48
+#if ENABLED(SOUND_MENU_ITEM)
49
+  #include "../../libs/buzzer.h"
50
+#endif
51
+
48 52
 #define HAS_DEBUG_MENU ENABLED(LCD_PROGRESS_BAR_TEST)
49 53
 
50 54
 void menu_advanced_settings();
@@ -412,6 +416,10 @@ void menu_configuration() {
412 416
       SUBMENU_N_S(m, ui.get_preheat_label(m), MSG_PREHEAT_M_SETTINGS, _menu_configuration_preheat_settings);
413 417
   #endif
414 418
 
419
+  #if ENABLED(SOUND_MENU_ITEM)
420
+    EDIT_ITEM(bool, MSG_SOUND, &ui.buzzer_enabled, []{ ui.chirp(); });
421
+  #endif
422
+
415 423
   #if ENABLED(EEPROM_SETTINGS)
416 424
     ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings);
417 425
     if (!busy) ACTION_ITEM(MSG_LOAD_EEPROM, ui.load_settings);

+ 5
- 3
Marlin/src/libs/buzzer.cpp Datei anzeigen

@@ -26,6 +26,7 @@
26 26
 
27 27
 #include "buzzer.h"
28 28
 #include "../module/temperature.h"
29
+#include "../lcd/marlinui.h"
29 30
 
30 31
 #if ENABLED(EXTENSIBLE_UI)
31 32
   #include "../lcd/extui/ui_api.h"
@@ -44,6 +45,7 @@ Buzzer buzzer;
44 45
  * @param frequency Frequency of the tone in hertz
45 46
  */
46 47
 void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) {
48
+  if (!ui.buzzer_enabled) return;
47 49
   while (buffer.isFull()) {
48 50
     tick();
49 51
     thermalManager.manage_heater();
@@ -53,6 +55,7 @@ void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) {
53 55
 }
54 56
 
55 57
 void Buzzer::tick() {
58
+  if (!ui.buzzer_enabled) return;
56 59
   const millis_t now = millis();
57 60
 
58 61
   if (!state.endtime) {
@@ -62,12 +65,11 @@ void Buzzer::tick() {
62 65
     state.endtime = now + state.tone.duration;
63 66
 
64 67
     if (state.tone.frequency > 0) {
65
-      #if ENABLED(EXTENSIBLE_UI)
68
+      #if ENABLED(EXTENSIBLE_UI) && DISABLED(EXTUI_LOCAL_BEEPER)
66 69
         CRITICAL_SECTION_START();
67 70
         ExtUI::onPlayTone(state.tone.frequency, state.tone.duration);
68 71
         CRITICAL_SECTION_END();
69
-      #endif
70
-      #if ENABLED(SPEAKER) && (DISABLED(EXTENSIBLE_UI) || ENABLED(EXTUI_LOCAL_BEEPER))
72
+      #elif ENABLED(SPEAKER)
71 73
         CRITICAL_SECTION_START();
72 74
         ::tone(BEEPER_PIN, state.tone.frequency, state.tone.duration);
73 75
         CRITICAL_SECTION_END();

+ 30
- 0
Marlin/src/module/settings.cpp Datei anzeigen

@@ -153,6 +153,10 @@
153 153
   #include "../feature/ethernet.h"
154 154
 #endif
155 155
 
156
+#if ENABLED(SOUND_MENU_ITEM)
157
+  #include "../libs/buzzer.h"
158
+#endif
159
+
156 160
 #pragma pack(push, 1) // No padding between variables
157 161
 
158 162
 #if HAS_ETHERNET
@@ -451,6 +455,12 @@ typedef struct SettingsDataStruct {
451 455
              ethernet_subnet;                           // M554 P
452 456
   #endif
453 457
 
458
+  //
459
+  // Buzzer enable/disable
460
+  //
461
+  #if ENABLED(SOUND_MENU_ITEM)
462
+    bool buzzer_enabled;
463
+  #endif
454 464
 } SettingsData;
455 465
 
456 466
 //static_assert(sizeof(SettingsData) <= MARLIN_EEPROM_SIZE, "EEPROM too small to contain SettingsData!");
@@ -1423,6 +1433,13 @@ void MarlinSettings::postprocess() {
1423 1433
     #endif
1424 1434
 
1425 1435
     //
1436
+    // Buzzer enable/disable
1437
+    //
1438
+    #if ENABLED(SOUND_MENU_ITEM)
1439
+      EEPROM_WRITE(ui.buzzer_enabled);
1440
+    #endif
1441
+
1442
+    //
1426 1443
     // Report final CRC and Data Size
1427 1444
     //
1428 1445
     if (!eeprom_error) {
@@ -2294,6 +2311,14 @@ void MarlinSettings::postprocess() {
2294 2311
       #endif
2295 2312
 
2296 2313
       //
2314
+      // Buzzer enable/disable
2315
+      //
2316
+      #if ENABLED(SOUND_MENU_ITEM)
2317
+        _FIELD_TEST(buzzer_enabled);
2318
+        EEPROM_READ(ui.buzzer_enabled);
2319
+      #endif
2320
+
2321
+      //
2297 2322
       // Validate Final Size and CRC
2298 2323
       //
2299 2324
       eeprom_error = size_error(eeprom_index - (EEPROM_OFFSET));
@@ -2604,6 +2629,11 @@ void MarlinSettings::reset() {
2604 2629
   TERN_(TOUCH_SCREEN_CALIBRATION, touch.calibration_reset());
2605 2630
 
2606 2631
   //
2632
+  // Buzzer enable/disable
2633
+  //
2634
+  TERN_(SOUND_MENU_ITEM, ui.buzzer_enabled = true);
2635
+
2636
+  //
2607 2637
   // Magnetic Parking Extruder
2608 2638
   //
2609 2639
   TERN_(MAGNETIC_PARKING_EXTRUDER, mpe_settings_init());

+ 1
- 1
buildroot/tests/LPC1768-tests Datei anzeigen

@@ -38,7 +38,7 @@ opt_set EXTRUDERS 2
38 38
 opt_set TEMP_SENSOR_1 -1
39 39
 opt_set TEMP_SENSOR_BED 5
40 40
 opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SDSUPPORT ADAPTIVE_FAN_SLOWING NO_FAN_SLOWING_IN_PID_TUNING \
41
-           FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY PID_EXTRUSION_SCALING \
41
+           FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY PID_EXTRUSION_SCALING SOUND_MENU_ITEM \
42 42
            NOZZLE_AS_PROBE AUTO_BED_LEVELING_BILINEAR G29_RETRY_AND_RECOVER Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \
43 43
            BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \
44 44
            PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT \

+ 2
- 2
buildroot/tests/mega2560-tests Datei anzeigen

@@ -27,7 +27,7 @@ opt_set TEMP_SENSOR_4 1000
27 27
 opt_set TEMP_SENSOR_BED 1
28 28
 opt_enable AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT SKEW_CORRECTION \
29 29
            REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI STATUS_MESSAGE_SCROLLING BOOT_MARLIN_LOGO_SMALL \
30
-           SDSUPPORT SDCARD_SORT_ALPHA USB_FLASH_DRIVE_SUPPORT SCROLL_LONG_FILENAMES CANCEL_OBJECTS \
30
+           SDSUPPORT SDCARD_SORT_ALPHA USB_FLASH_DRIVE_SUPPORT SCROLL_LONG_FILENAMES CANCEL_OBJECTS SOUND_MENU_ITEM \
31 31
            EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_USER_MENUS \
32 32
            MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE EXTRA_LIN_ADVANCE_K QUICK_HOME \
33 33
            LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME \
@@ -82,7 +82,7 @@ restore_configs
82 82
 opt_set MOTHERBOARD BOARD_MEGACONTROLLER
83 83
 opt_set LCD_LANGUAGE de
84 84
 opt_enable EEPROM_SETTINGS EEPROM_CHITCHAT \
85
-           MINIPANEL SDSUPPORT PCA9632 LCD_INFO_MENU \
85
+           MINIPANEL SDSUPPORT PCA9632 LCD_INFO_MENU SOUND_MENU_ITEM \
86 86
            AUTO_BED_LEVELING_BILINEAR PROBE_MANUALLY LCD_BED_LEVELING G26_MESH_VALIDATION MESH_EDIT_MENU \
87 87
            LIN_ADVANCE EXTRA_LIN_ADVANCE_K \
88 88
            INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT EXPERIMENTAL_I2CBUS M100_FREE_MEMORY_WATCHER \

+ 1
- 1
buildroot/tests/teensy35-tests Datei anzeigen

@@ -20,7 +20,7 @@ opt_set TEMP_SENSOR_0 1
20 20
 opt_set TEMP_SENSOR_1 5
21 21
 opt_set TEMP_SENSOR_BED 1
22 22
 opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LCD_INFO_MENU SDSUPPORT SDCARD_SORT_ALPHA \
23
-           FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY CALIBRATION_GCODE BAUD_RATE_GCODE \
23
+           FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY CALIBRATION_GCODE BAUD_RATE_GCODE SOUND_MENU_ITEM \
24 24
            FIX_MOUNTED_PROBE Z_SAFE_HOMING AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \
25 25
            BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \
26 26
            PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT M100_FREE_MEMORY_WATCHER \

Laden…
Abbrechen
Speichern