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

@ -35,6 +35,8 @@
#include "../../../inc/MarlinConfigPre.h"
// TODO: Use Marlin's built-in tone player instead.
#if ENABLED(ANYCUBIC_LCD_CHIRON)
#include "Tunes.h"
@ -44,15 +46,12 @@ namespace Anycubic {
void PlayTune(uint8_t beeperPin, const uint16_t *tune, uint8_t speed=1) {
uint8_t pos = 1;
uint16_t wholenotelen = tune[0] / speed;
const uint16_t wholenotelen = tune[0] / speed;
do {
uint16_t freq = tune[pos];
uint16_t notelen = wholenotelen / tune[pos + 1];
const uint16_t freq = tune[pos], notelen = wholenotelen / tune[pos + 1];
::tone(beeperPin, freq, notelen);
ExtUI::delay_ms(notelen);
pos += 2;
if (pos >= MAX_TUNE_LENGTH) break;
} while (tune[pos] != n_END);
}

View File

@ -42,9 +42,7 @@ namespace ExtUI {
void onMediaError() { AnycubicTFT.OnSDCardError(); }
void onMediaRemoved() { AnycubicTFT.OnSDCardStateChange(false); }
void onPlayTone(const uint16_t frequency, const uint16_t duration) {
#if ENABLED(SPEAKER)
::tone(BEEPER_PIN, frequency, duration);
#endif
TERN_(SPEAKER, ::tone(BEEPER_PIN, frequency, duration));
}
void onPrintTimerStarted() { AnycubicTFT.OnPrintTimerStarted(); }
void onPrintTimerPaused() { AnycubicTFT.OnPrintTimerPaused(); }

View File

@ -160,6 +160,8 @@
#endif
}
#include "../../../libs/buzzer.h"
void init_test_gpio() {
endstops.init();
@ -201,12 +203,7 @@
#endif
}
void mks_test_beeper() {
WRITE(BEEPER_PIN, HIGH);
delay(100);
WRITE(BEEPER_PIN, LOW);
delay(100);
}
void mks_test_beeper() { buzzer.click(100); }
#if ENABLED(SDSUPPORT)