♻️ Small sound / buzz refactor (#24520)

This commit is contained in:
Scott Lahteine
2022-07-18 19:53:36 -05:00
parent 97a73147fa
commit f752fe75ee
16 changed files with 49 additions and 55 deletions

View File

@ -36,7 +36,7 @@
#include "../../marlinui.h"
#include "../../../HAL/shared/Delay.h"
#if HAS_BUZZER
#if HAS_SOUND
#include "../../../libs/buzzer.h"
#endif
@ -50,9 +50,7 @@ ENCODER_Rate EncoderRate;
// TODO: Replace with ui.quick_feedback
void Encoder_tick() {
#if PIN_EXISTS(BEEPER)
if (ui.sound_on) buzzer.click(10);
#endif
TERN_(HAS_BEEPER, if (ui.sound_on) buzzer.click(10));
}
// Encoder initialization
@ -66,7 +64,7 @@ void Encoder_Configuration() {
#if BUTTON_EXISTS(ENC)
SET_INPUT_PULLUP(BTN_ENC);
#endif
#if PIN_EXISTS(BEEPER)
#if HAS_BEEPER
SET_OUTPUT(BEEPER_PIN); // TODO: Use buzzer.h which already inits this
#endif
}

View File

@ -2625,15 +2625,13 @@ void Draw_HomeOff_Menu() {
#include "../../../libs/buzzer.h"
void HMI_AudioFeedback(const bool success=true) {
#if HAS_BUZZER
if (success) {
buzzer.tone(100, 659);
buzzer.tone(10, 0);
buzzer.tone(100, 698);
}
else
buzzer.tone(40, 440);
#endif
if (success) {
BUZZ(100, 659);
BUZZ(10, 0);
BUZZ(100, 698);
}
else
BUZZ(40, 440);
}
// Prepare