|
@ -26,6 +26,7 @@ |
|
|
|
|
|
|
|
|
#include "buzzer.h" |
|
|
#include "buzzer.h" |
|
|
#include "../module/temperature.h" |
|
|
#include "../module/temperature.h" |
|
|
|
|
|
#include "../lcd/marlinui.h" |
|
|
|
|
|
|
|
|
#if ENABLED(EXTENSIBLE_UI) |
|
|
#if ENABLED(EXTENSIBLE_UI) |
|
|
#include "../lcd/extui/ui_api.h" |
|
|
#include "../lcd/extui/ui_api.h" |
|
@ -44,6 +45,7 @@ Buzzer buzzer; |
|
|
* @param frequency Frequency of the tone in hertz |
|
|
* @param frequency Frequency of the tone in hertz |
|
|
*/ |
|
|
*/ |
|
|
void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) { |
|
|
void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) { |
|
|
|
|
|
if (!ui.buzzer_enabled) return; |
|
|
while (buffer.isFull()) { |
|
|
while (buffer.isFull()) { |
|
|
tick(); |
|
|
tick(); |
|
|
thermalManager.manage_heater(); |
|
|
thermalManager.manage_heater(); |
|
@ -53,6 +55,7 @@ void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void Buzzer::tick() { |
|
|
void Buzzer::tick() { |
|
|
|
|
|
if (!ui.buzzer_enabled) return; |
|
|
const millis_t now = millis(); |
|
|
const millis_t now = millis(); |
|
|
|
|
|
|
|
|
if (!state.endtime) { |
|
|
if (!state.endtime) { |
|
@ -62,12 +65,11 @@ void Buzzer::tick() { |
|
|
state.endtime = now + state.tone.duration; |
|
|
state.endtime = now + state.tone.duration; |
|
|
|
|
|
|
|
|
if (state.tone.frequency > 0) { |
|
|
if (state.tone.frequency > 0) { |
|
|
#if ENABLED(EXTENSIBLE_UI) |
|
|
#if ENABLED(EXTENSIBLE_UI) && DISABLED(EXTUI_LOCAL_BEEPER) |
|
|
CRITICAL_SECTION_START(); |
|
|
CRITICAL_SECTION_START(); |
|
|
ExtUI::onPlayTone(state.tone.frequency, state.tone.duration); |
|
|
ExtUI::onPlayTone(state.tone.frequency, state.tone.duration); |
|
|
CRITICAL_SECTION_END(); |
|
|
CRITICAL_SECTION_END(); |
|
|
#endif |
|
|
#elif ENABLED(SPEAKER) |
|
|
#if ENABLED(SPEAKER) && (DISABLED(EXTENSIBLE_UI) || ENABLED(EXTUI_LOCAL_BEEPER)) |
|
|
|
|
|
CRITICAL_SECTION_START(); |
|
|
CRITICAL_SECTION_START(); |
|
|
::tone(BEEPER_PIN, state.tone.frequency, state.tone.duration); |
|
|
::tone(BEEPER_PIN, state.tone.frequency, state.tone.duration); |
|
|
CRITICAL_SECTION_END(); |
|
|
CRITICAL_SECTION_END(); |
|
|