1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-25 12:57:53 +00:00
MarlinFirmware/Marlin/buzzer.cpp

23 lines
495 B
C++
Raw Normal View History

#include "Marlin.h"
#include "buzzer.h"
#include "ultralcd.h"
#if HAS_BUZZER
void buzz(long duration, uint16_t freq) {
if (freq > 0) {
#ifdef LCD_USE_I2C_BUZZER
lcd_buzz(duration, freq);
#elif defined(BEEPER) && BEEPER >= 0 // on-board buzzers have no further condition
SET_OUTPUT(BEEPER);
tone(BEEPER, freq, duration);
delay(duration);
#else
delay(duration);
#endif
}
else {
delay(duration);
}
}
#endif