summaryrefslogtreecommitdiff
path: root/lib/buzzer/buzzer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/buzzer/buzzer.cpp')
-rw-r--r--lib/buzzer/buzzer.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/buzzer/buzzer.cpp b/lib/buzzer/buzzer.cpp
index a83ec22..df67ac7 100644
--- a/lib/buzzer/buzzer.cpp
+++ b/lib/buzzer/buzzer.cpp
@@ -4,10 +4,15 @@
#define BUZZER_CHANNEL 3
#define BUZZER_RESOLUTION 8
+#define BUZZER_FREQ 2000
BUZZER::BUZZER()
{
- ledcSetup(BUZZER_CHANNEL, 2000, BUZZER_RESOLUTION);
+}
+
+void BUZZER::init()
+{
+ ledcSetup(BUZZER_CHANNEL, BUZZER_FREQ, BUZZER_RESOLUTION);
ledcAttachPin(BUZZER_PIN, BUZZER_CHANNEL);
}
@@ -23,7 +28,6 @@ void BUZZER::playTone(uint16_t frequency, uint32_t duration)
void BUZZER::playMelody(const uint16_t melody[][2], size_t length)
{
-
for (size_t i = 0; i < length; i++)
{
playTone(melody[i][0], melody[i][1]);