"Sound: ON/OFF" menu item (#19901)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
committed by
Scott Lahteine
parent
d4669dbf6a
commit
d7d1ef8228
@ -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)
|
||||
#if PIN_EXISTS(BEEPER)
|
||||
#define USE_BEEPER 1
|
||||
#endif
|
||||
#if USE_BEEPER || ANY(LCD_USE_I2C_BUZZER, PCA9632_BUZZER)
|
||||
#define HAS_BUZZER 1
|
||||
#if PIN_EXISTS(BEEPER)
|
||||
#define USE_BEEPER 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(LCD_USE_I2C_BUZZER)
|
||||
@ -2528,8 +2528,12 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_BUZZER && LCD_FEEDBACK_FREQUENCY_DURATION_MS && LCD_FEEDBACK_FREQUENCY_HZ
|
||||
#define HAS_CHIRP 1
|
||||
#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
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
//
|
||||
|
Reference in New Issue
Block a user