Browse Source

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

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Lucas Seiki Oshiro 4 years ago
parent
commit
c0b4f4eb47
No account linked to committer's email address

+ 3
- 0
Marlin/Configuration_adv.h View File

1090
   // BACK menu items keep the highlight at the top
1090
   // BACK menu items keep the highlight at the top
1091
   //#define TURBO_BACK_MENU_ITEM
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
    * LED Control Menu
1097
    * LED Control Menu
1095
    * Add LED Control to the LCD menu
1098
    * Add LED Control to the LCD menu

+ 10
- 6
Marlin/src/inc/Conditionals_post.h View File

2505
 /**
2505
 /**
2506
  * Buzzer/Speaker
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
   #define HAS_BUZZER 1
2512
   #define HAS_BUZZER 1
2510
-  #if PIN_EXISTS(BEEPER)
2511
-    #define USE_BEEPER 1
2512
-  #endif
2513
 #endif
2513
 #endif
2514
 
2514
 
2515
 #if ENABLED(LCD_USE_I2C_BUZZER)
2515
 #if ENABLED(LCD_USE_I2C_BUZZER)
2528
   #endif
2528
   #endif
2529
 #endif
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
 #endif
2537
 #endif
2534
 
2538
 
2535
 /**
2539
 /**

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

113
 
113
 
114
 #if ENABLED(LCD_USE_I2C_BUZZER)
114
 #if ENABLED(LCD_USE_I2C_BUZZER)
115
   void MarlinUI::buzz(const long duration, const uint16_t freq) {
115
   void MarlinUI::buzz(const long duration, const uint16_t freq) {
116
+    if (!buzzer_enabled) return;
116
     lcd.buzz(duration, freq);
117
     lcd.buzz(duration, freq);
117
   }
118
   }
118
 #endif
119
 #endif

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

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

+ 1
- 0
Marlin/src/lcd/language/language_en.h View File

659
   PROGMEM Language_Str MSG_REHEATING                       = _UxGT("Reheating...");
659
   PROGMEM Language_Str MSG_REHEATING                       = _UxGT("Reheating...");
660
 
660
 
661
   PROGMEM Language_Str MSG_PROBE_WIZARD                    = _UxGT("Z Probe Wizard");
661
   PROGMEM Language_Str MSG_PROBE_WIZARD                    = _UxGT("Z Probe Wizard");
662
+  PROGMEM Language_Str MSG_SOUND                           = _UxGT("Sound");
662
 }
663
 }
663
 
664
 
664
 #if FAN_COUNT == 1
665
 #if FAN_COUNT == 1

+ 5
- 0
Marlin/src/lcd/marlinui.cpp View File

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

+ 6
- 0
Marlin/src/lcd/marlinui.h View File

292
     TERN_(HAS_LCD_MENU, currentScreen = status_screen);
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
   #if HAS_BUZZER
301
   #if HAS_BUZZER
296
     static void buzz(const long duration, const uint16_t freq);
302
     static void buzz(const long duration, const uint16_t freq);
297
   #endif
303
   #endif

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

45
   #endif
45
   #endif
46
 #endif
46
 #endif
47
 
47
 
48
+#if ENABLED(SOUND_MENU_ITEM)
49
+  #include "../../libs/buzzer.h"
50
+#endif
51
+
48
 #define HAS_DEBUG_MENU ENABLED(LCD_PROGRESS_BAR_TEST)
52
 #define HAS_DEBUG_MENU ENABLED(LCD_PROGRESS_BAR_TEST)
49
 
53
 
50
 void menu_advanced_settings();
54
 void menu_advanced_settings();
412
       SUBMENU_N_S(m, ui.get_preheat_label(m), MSG_PREHEAT_M_SETTINGS, _menu_configuration_preheat_settings);
416
       SUBMENU_N_S(m, ui.get_preheat_label(m), MSG_PREHEAT_M_SETTINGS, _menu_configuration_preheat_settings);
413
   #endif
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
   #if ENABLED(EEPROM_SETTINGS)
423
   #if ENABLED(EEPROM_SETTINGS)
416
     ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings);
424
     ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings);
417
     if (!busy) ACTION_ITEM(MSG_LOAD_EEPROM, ui.load_settings);
425
     if (!busy) ACTION_ITEM(MSG_LOAD_EEPROM, ui.load_settings);

+ 5
- 3
Marlin/src/libs/buzzer.cpp View File

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

+ 30
- 0
Marlin/src/module/settings.cpp View File

153
   #include "../feature/ethernet.h"
153
   #include "../feature/ethernet.h"
154
 #endif
154
 #endif
155
 
155
 
156
+#if ENABLED(SOUND_MENU_ITEM)
157
+  #include "../libs/buzzer.h"
158
+#endif
159
+
156
 #pragma pack(push, 1) // No padding between variables
160
 #pragma pack(push, 1) // No padding between variables
157
 
161
 
158
 #if HAS_ETHERNET
162
 #if HAS_ETHERNET
451
              ethernet_subnet;                           // M554 P
455
              ethernet_subnet;                           // M554 P
452
   #endif
456
   #endif
453
 
457
 
458
+  //
459
+  // Buzzer enable/disable
460
+  //
461
+  #if ENABLED(SOUND_MENU_ITEM)
462
+    bool buzzer_enabled;
463
+  #endif
454
 } SettingsData;
464
 } SettingsData;
455
 
465
 
456
 //static_assert(sizeof(SettingsData) <= MARLIN_EEPROM_SIZE, "EEPROM too small to contain SettingsData!");
466
 //static_assert(sizeof(SettingsData) <= MARLIN_EEPROM_SIZE, "EEPROM too small to contain SettingsData!");
1423
     #endif
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
     // Report final CRC and Data Size
1443
     // Report final CRC and Data Size
1427
     //
1444
     //
1428
     if (!eeprom_error) {
1445
     if (!eeprom_error) {
2294
       #endif
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
       // Validate Final Size and CRC
2322
       // Validate Final Size and CRC
2298
       //
2323
       //
2299
       eeprom_error = size_error(eeprom_index - (EEPROM_OFFSET));
2324
       eeprom_error = size_error(eeprom_index - (EEPROM_OFFSET));
2604
   TERN_(TOUCH_SCREEN_CALIBRATION, touch.calibration_reset());
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
   // Magnetic Parking Extruder
2637
   // Magnetic Parking Extruder
2608
   //
2638
   //
2609
   TERN_(MAGNETIC_PARKING_EXTRUDER, mpe_settings_init());
2639
   TERN_(MAGNETIC_PARKING_EXTRUDER, mpe_settings_init());

+ 1
- 1
buildroot/tests/LPC1768-tests View File

38
 opt_set TEMP_SENSOR_1 -1
38
 opt_set TEMP_SENSOR_1 -1
39
 opt_set TEMP_SENSOR_BED 5
39
 opt_set TEMP_SENSOR_BED 5
40
 opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SDSUPPORT ADAPTIVE_FAN_SLOWING NO_FAN_SLOWING_IN_PID_TUNING \
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
            NOZZLE_AS_PROBE AUTO_BED_LEVELING_BILINEAR G29_RETRY_AND_RECOVER Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \
42
            NOZZLE_AS_PROBE AUTO_BED_LEVELING_BILINEAR G29_RETRY_AND_RECOVER Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \
43
            BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \
43
            BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \
44
            PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT \
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 View File

27
 opt_set TEMP_SENSOR_BED 1
27
 opt_set TEMP_SENSOR_BED 1
28
 opt_enable AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT SKEW_CORRECTION \
28
 opt_enable AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT SKEW_CORRECTION \
29
            REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI STATUS_MESSAGE_SCROLLING BOOT_MARLIN_LOGO_SMALL \
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
            EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_USER_MENUS \
31
            EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_USER_MENUS \
32
            MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE EXTRA_LIN_ADVANCE_K QUICK_HOME \
32
            MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE EXTRA_LIN_ADVANCE_K QUICK_HOME \
33
            LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME \
33
            LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME \
82
 opt_set MOTHERBOARD BOARD_MEGACONTROLLER
82
 opt_set MOTHERBOARD BOARD_MEGACONTROLLER
83
 opt_set LCD_LANGUAGE de
83
 opt_set LCD_LANGUAGE de
84
 opt_enable EEPROM_SETTINGS EEPROM_CHITCHAT \
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
            AUTO_BED_LEVELING_BILINEAR PROBE_MANUALLY LCD_BED_LEVELING G26_MESH_VALIDATION MESH_EDIT_MENU \
86
            AUTO_BED_LEVELING_BILINEAR PROBE_MANUALLY LCD_BED_LEVELING G26_MESH_VALIDATION MESH_EDIT_MENU \
87
            LIN_ADVANCE EXTRA_LIN_ADVANCE_K \
87
            LIN_ADVANCE EXTRA_LIN_ADVANCE_K \
88
            INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT EXPERIMENTAL_I2CBUS M100_FREE_MEMORY_WATCHER \
88
            INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT EXPERIMENTAL_I2CBUS M100_FREE_MEMORY_WATCHER \

+ 1
- 1
buildroot/tests/teensy35-tests View File

20
 opt_set TEMP_SENSOR_1 5
20
 opt_set TEMP_SENSOR_1 5
21
 opt_set TEMP_SENSOR_BED 1
21
 opt_set TEMP_SENSOR_BED 1
22
 opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LCD_INFO_MENU SDSUPPORT SDCARD_SORT_ALPHA \
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
            FIX_MOUNTED_PROBE Z_SAFE_HOMING AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \
24
            FIX_MOUNTED_PROBE Z_SAFE_HOMING AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \
25
            BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \
25
            BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \
26
            PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT M100_FREE_MEMORY_WATCHER \
26
            PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT M100_FREE_MEMORY_WATCHER \

Loading…
Cancel
Save