SOUND_ON_DEFAULT option (#24102)

This commit is contained in:
Pauli Jokela
2022-05-12 05:23:16 +03:00
committed by Scott Lahteine
parent b2b5b85045
commit 3443a9e18b
23 changed files with 79 additions and 91 deletions

View File

@ -22,7 +22,7 @@
#include "../inc/MarlinConfig.h"
#if USE_BEEPER
#if HAS_BEEPER
#include "buzzer.h"
#include "../module/temperature.h"
@ -45,7 +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;
if (!ui.sound_on) return;
while (buffer.isFull()) {
tick();
thermalManager.manage_heater();
@ -55,7 +55,7 @@ void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) {
}
void Buzzer::tick() {
if (!ui.buzzer_enabled) return;
if (!ui.sound_on) return;
const millis_t now = millis();
if (!state.endtime) {
@ -81,4 +81,4 @@ void Buzzer::tick() {
else if (ELAPSED(now, state.endtime)) reset();
}
#endif // USE_BEEPER
#endif // HAS_BEEPER

View File

@ -23,7 +23,7 @@
#include "../inc/MarlinConfig.h"
#if USE_BEEPER
#if HAS_BEEPER
#include "circularqueue.h"
@ -61,18 +61,6 @@
*/
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
* @details Brings the class state to a known one.
@ -91,6 +79,20 @@
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
* @details Adds a tone_t structure to the ring buffer, will block IO if the
@ -118,8 +120,8 @@
#elif HAS_BUZZER
// Buzz indirectly via the MarlinUI instance
#include "../lcd/marlinui.h"
#define BUZZ(d,f) ui.buzz(d,f)
#include "../lcd/marlinui.h"
#else