"Sound: ON/OFF" menu item (#19901)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
parent
68ef3ac675
commit
c0b4f4eb47
|
@ -1090,6 +1090,9 @@
|
|||
// BACK menu items keep the highlight at the top
|
||||
//#define TURBO_BACK_MENU_ITEM
|
||||
|
||||
// Add a mute option to the LCD menu
|
||||
//#define SOUND_MENU_ITEM
|
||||
|
||||
/**
|
||||
* LED Control Menu
|
||||
* Add LED Control to the LCD menu
|
||||
|
|
|
@ -2505,11 +2505,11 @@
|
|||
/**
|
||||
* Buzzer/Speaker
|
||||
*/
|
||||
#if PIN_EXISTS(BEEPER) || ANY(LCD_USE_I2C_BUZZER, PCA9632_BUZZER)
|
||||
#define HAS_BUZZER 1
|
||||
#if PIN_EXISTS(BEEPER)
|
||||
#define USE_BEEPER 1
|
||||
#endif
|
||||
#if USE_BEEPER || ANY(LCD_USE_I2C_BUZZER, PCA9632_BUZZER)
|
||||
#define HAS_BUZZER 1
|
||||
#endif
|
||||
|
||||
#if ENABLED(LCD_USE_I2C_BUZZER)
|
||||
|
@ -2528,9 +2528,13 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_BUZZER && LCD_FEEDBACK_FREQUENCY_DURATION_MS && LCD_FEEDBACK_FREQUENCY_HZ
|
||||
#if HAS_BUZZER
|
||||
#if LCD_FEEDBACK_FREQUENCY_DURATION_MS && LCD_FEEDBACK_FREQUENCY_HZ
|
||||
#define HAS_CHIRP 1
|
||||
#endif
|
||||
#else
|
||||
#undef SOUND_MENU_ITEM // No buzzer menu item without a buzzer
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Make sure DOGLCD_SCK and DOGLCD_MOSI are defined.
|
||||
|
|
|
@ -113,6 +113,7 @@ static void createChar_P(const char c, const byte * const ptr) {
|
|||
|
||||
#if ENABLED(LCD_USE_I2C_BUZZER)
|
||||
void MarlinUI::buzz(const long duration, const uint16_t freq) {
|
||||
if (!buzzer_enabled) return;
|
||||
lcd.buzz(duration, freq);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -289,6 +289,7 @@ uint8_t MarlinUI::read_slow_buttons(void) {
|
|||
// Duration in ms, freq in Hz
|
||||
void MarlinUI::buzz(const long duration, const uint16_t freq) {
|
||||
if (!PanelDetected) return;
|
||||
if (!buzzer_enabled) return;
|
||||
#if ENABLED(TFTGLCD_PANEL_SPI)
|
||||
WRITE(TFTGLCD_CS, LOW);
|
||||
SPI_SEND_ONE(BUZZER);
|
||||
|
|
|
@ -659,6 +659,7 @@ namespace Language_en {
|
|||
PROGMEM Language_Str MSG_REHEATING = _UxGT("Reheating...");
|
||||
|
||||
PROGMEM Language_Str MSG_PROBE_WIZARD = _UxGT("Z Probe Wizard");
|
||||
PROGMEM Language_Str MSG_SOUND = _UxGT("Sound");
|
||||
}
|
||||
|
||||
#if FAN_COUNT == 1
|
||||
|
|
|
@ -74,12 +74,17 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(SOUND_MENU_ITEM)
|
||||
bool MarlinUI::buzzer_enabled = true;
|
||||
#endif
|
||||
|
||||
#if EITHER(PCA9632_BUZZER, USE_BEEPER)
|
||||
#include "../libs/buzzer.h" // for BUZZ() macro
|
||||
#if ENABLED(PCA9632_BUZZER)
|
||||
#include "../feature/leds/pca9632.h"
|
||||
#endif
|
||||
void MarlinUI::buzz(const long duration, const uint16_t freq) {
|
||||
if (!buzzer_enabled) return;
|
||||
#if ENABLED(PCA9632_BUZZER)
|
||||
PCA9632_buzz(duration, freq);
|
||||
#elif USE_BEEPER
|
||||
|
|
|
@ -292,6 +292,12 @@ public:
|
|||
TERN_(HAS_LCD_MENU, currentScreen = status_screen);
|
||||
}
|
||||
|
||||
#if ENABLED(SOUND_MENU_ITEM)
|
||||
static bool buzzer_enabled; // Initialized by settings.load()
|
||||
#else
|
||||
static constexpr bool buzzer_enabled = true;
|
||||
#endif
|
||||
|
||||
#if HAS_BUZZER
|
||||
static void buzz(const long duration, const uint16_t freq);
|
||||
#endif
|
||||
|
|
|
@ -45,6 +45,10 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(SOUND_MENU_ITEM)
|
||||
#include "../../libs/buzzer.h"
|
||||
#endif
|
||||
|
||||
#define HAS_DEBUG_MENU ENABLED(LCD_PROGRESS_BAR_TEST)
|
||||
|
||||
void menu_advanced_settings();
|
||||
|
@ -412,6 +416,10 @@ void menu_configuration() {
|
|||
SUBMENU_N_S(m, ui.get_preheat_label(m), MSG_PREHEAT_M_SETTINGS, _menu_configuration_preheat_settings);
|
||||
#endif
|
||||
|
||||
#if ENABLED(SOUND_MENU_ITEM)
|
||||
EDIT_ITEM(bool, MSG_SOUND, &ui.buzzer_enabled, []{ ui.chirp(); });
|
||||
#endif
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS)
|
||||
ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings);
|
||||
if (!busy) ACTION_ITEM(MSG_LOAD_EEPROM, ui.load_settings);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "buzzer.h"
|
||||
#include "../module/temperature.h"
|
||||
#include "../lcd/marlinui.h"
|
||||
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
#include "../lcd/extui/ui_api.h"
|
||||
|
@ -44,6 +45,7 @@ Buzzer buzzer;
|
|||
* @param frequency Frequency of the tone in hertz
|
||||
*/
|
||||
void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) {
|
||||
if (!ui.buzzer_enabled) return;
|
||||
while (buffer.isFull()) {
|
||||
tick();
|
||||
thermalManager.manage_heater();
|
||||
|
@ -53,6 +55,7 @@ void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) {
|
|||
}
|
||||
|
||||
void Buzzer::tick() {
|
||||
if (!ui.buzzer_enabled) return;
|
||||
const millis_t now = millis();
|
||||
|
||||
if (!state.endtime) {
|
||||
|
@ -62,12 +65,11 @@ void Buzzer::tick() {
|
|||
state.endtime = now + state.tone.duration;
|
||||
|
||||
if (state.tone.frequency > 0) {
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
#if ENABLED(EXTENSIBLE_UI) && DISABLED(EXTUI_LOCAL_BEEPER)
|
||||
CRITICAL_SECTION_START();
|
||||
ExtUI::onPlayTone(state.tone.frequency, state.tone.duration);
|
||||
CRITICAL_SECTION_END();
|
||||
#endif
|
||||
#if ENABLED(SPEAKER) && (DISABLED(EXTENSIBLE_UI) || ENABLED(EXTUI_LOCAL_BEEPER))
|
||||
#elif ENABLED(SPEAKER)
|
||||
CRITICAL_SECTION_START();
|
||||
::tone(BEEPER_PIN, state.tone.frequency, state.tone.duration);
|
||||
CRITICAL_SECTION_END();
|
||||
|
|
|
@ -153,6 +153,10 @@
|
|||
#include "../feature/ethernet.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(SOUND_MENU_ITEM)
|
||||
#include "../libs/buzzer.h"
|
||||
#endif
|
||||
|
||||
#pragma pack(push, 1) // No padding between variables
|
||||
|
||||
#if HAS_ETHERNET
|
||||
|
@ -451,6 +455,12 @@ typedef struct SettingsDataStruct {
|
|||
ethernet_subnet; // M554 P
|
||||
#endif
|
||||
|
||||
//
|
||||
// Buzzer enable/disable
|
||||
//
|
||||
#if ENABLED(SOUND_MENU_ITEM)
|
||||
bool buzzer_enabled;
|
||||
#endif
|
||||
} SettingsData;
|
||||
|
||||
//static_assert(sizeof(SettingsData) <= MARLIN_EEPROM_SIZE, "EEPROM too small to contain SettingsData!");
|
||||
|
@ -1422,6 +1432,13 @@ void MarlinSettings::postprocess() {
|
|||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// Buzzer enable/disable
|
||||
//
|
||||
#if ENABLED(SOUND_MENU_ITEM)
|
||||
EEPROM_WRITE(ui.buzzer_enabled);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Report final CRC and Data Size
|
||||
//
|
||||
|
@ -2293,6 +2310,14 @@ void MarlinSettings::postprocess() {
|
|||
EEPROM_READ(ethernet_subnet); ethernet.subnet = ethernet_subnet;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Buzzer enable/disable
|
||||
//
|
||||
#if ENABLED(SOUND_MENU_ITEM)
|
||||
_FIELD_TEST(buzzer_enabled);
|
||||
EEPROM_READ(ui.buzzer_enabled);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Validate Final Size and CRC
|
||||
//
|
||||
|
@ -2603,6 +2628,11 @@ void MarlinSettings::reset() {
|
|||
//
|
||||
TERN_(TOUCH_SCREEN_CALIBRATION, touch.calibration_reset());
|
||||
|
||||
//
|
||||
// Buzzer enable/disable
|
||||
//
|
||||
TERN_(SOUND_MENU_ITEM, ui.buzzer_enabled = true);
|
||||
|
||||
//
|
||||
// Magnetic Parking Extruder
|
||||
//
|
||||
|
|
|
@ -38,7 +38,7 @@ opt_set EXTRUDERS 2
|
|||
opt_set TEMP_SENSOR_1 -1
|
||||
opt_set TEMP_SENSOR_BED 5
|
||||
opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SDSUPPORT ADAPTIVE_FAN_SLOWING NO_FAN_SLOWING_IN_PID_TUNING \
|
||||
FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY PID_EXTRUSION_SCALING \
|
||||
FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY PID_EXTRUSION_SCALING SOUND_MENU_ITEM \
|
||||
NOZZLE_AS_PROBE AUTO_BED_LEVELING_BILINEAR G29_RETRY_AND_RECOVER Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \
|
||||
BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \
|
||||
PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT \
|
||||
|
|
|
@ -27,7 +27,7 @@ opt_set TEMP_SENSOR_4 1000
|
|||
opt_set TEMP_SENSOR_BED 1
|
||||
opt_enable AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT SKEW_CORRECTION \
|
||||
REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI STATUS_MESSAGE_SCROLLING BOOT_MARLIN_LOGO_SMALL \
|
||||
SDSUPPORT SDCARD_SORT_ALPHA USB_FLASH_DRIVE_SUPPORT SCROLL_LONG_FILENAMES CANCEL_OBJECTS \
|
||||
SDSUPPORT SDCARD_SORT_ALPHA USB_FLASH_DRIVE_SUPPORT SCROLL_LONG_FILENAMES CANCEL_OBJECTS SOUND_MENU_ITEM \
|
||||
EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_USER_MENUS \
|
||||
MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE EXTRA_LIN_ADVANCE_K QUICK_HOME \
|
||||
LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME \
|
||||
|
@ -82,7 +82,7 @@ restore_configs
|
|||
opt_set MOTHERBOARD BOARD_MEGACONTROLLER
|
||||
opt_set LCD_LANGUAGE de
|
||||
opt_enable EEPROM_SETTINGS EEPROM_CHITCHAT \
|
||||
MINIPANEL SDSUPPORT PCA9632 LCD_INFO_MENU \
|
||||
MINIPANEL SDSUPPORT PCA9632 LCD_INFO_MENU SOUND_MENU_ITEM \
|
||||
AUTO_BED_LEVELING_BILINEAR PROBE_MANUALLY LCD_BED_LEVELING G26_MESH_VALIDATION MESH_EDIT_MENU \
|
||||
LIN_ADVANCE EXTRA_LIN_ADVANCE_K \
|
||||
INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT EXPERIMENTAL_I2CBUS M100_FREE_MEMORY_WATCHER \
|
||||
|
|
|
@ -20,7 +20,7 @@ opt_set TEMP_SENSOR_0 1
|
|||
opt_set TEMP_SENSOR_1 5
|
||||
opt_set TEMP_SENSOR_BED 1
|
||||
opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LCD_INFO_MENU SDSUPPORT SDCARD_SORT_ALPHA \
|
||||
FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY CALIBRATION_GCODE BAUD_RATE_GCODE \
|
||||
FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY CALIBRATION_GCODE BAUD_RATE_GCODE SOUND_MENU_ITEM \
|
||||
FIX_MOUNTED_PROBE Z_SAFE_HOMING AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \
|
||||
BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \
|
||||
PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT M100_FREE_MEMORY_WATCHER \
|
||||
|
|
Loading…
Reference in a new issue