UVControl/src/Buzzer.cpp

58 lines
827 B
C++
Raw Permalink Normal View History

#include "buzzer.h"
2017-11-26 19:22:15 +00:00
#include <Arduino.h>
#include "config.h"
#include "state.h"
2017-11-26 19:22:15 +00:00
void Buzzer::playNote(uint16_t frequency, uint16_t duration)
{
tone(PinBuzzer, frequency);
delay(duration);
noTone(PinBuzzer);
}
void Buzzer::startup()
2017-11-26 19:22:15 +00:00
{
if (GetBuzzer() == BuzzerSetting::CompletedButtonStartup)
playNote(1000, 50);
2017-11-26 19:22:15 +00:00
}
void Buzzer::select()
2017-11-26 19:22:15 +00:00
{
if (GetBuzzer() <= BuzzerSetting::CompletedButton)
playNote(1000, 1);
2017-11-26 19:22:15 +00:00
}
void Buzzer::click()
2017-11-26 19:22:15 +00:00
{
if (GetBuzzer() <= BuzzerSetting::CompletedButton)
playNote(1000, 25);
2017-11-26 19:22:15 +00:00
}
void Buzzer::completed()
2017-11-26 19:22:15 +00:00
{
if (GetBuzzer() <= BuzzerSetting::Completed)
2017-11-26 19:22:15 +00:00
{
for (int i = 0; i < 3; i++)
{
playNote(1000, 250);
delay(500);
}
2017-11-26 19:22:15 +00:00
}
}
void Buzzer::memoryCleared()
2017-11-26 19:22:15 +00:00
{
for (int i = 0; i < 5; i++)
{
playNote(1000, 25);
2017-11-26 19:22:15 +00:00
delay(250);
}
2017-11-26 19:22:15 +00:00
}