2016-05-27 21:43:58 +00:00
|
|
|
#include "Arduboy2.h"
|
2015-05-01 05:26:58 +00:00
|
|
|
#include "audio.h"
|
|
|
|
|
|
|
|
bool ArduboyAudio::audio_enabled = false;
|
|
|
|
|
|
|
|
void ArduboyAudio::on()
|
|
|
|
{
|
2016-03-02 01:49:46 +00:00
|
|
|
// fire up audio pins
|
|
|
|
#ifdef ARDUBOY_10
|
|
|
|
pinMode(PIN_SPEAKER_1, OUTPUT);
|
|
|
|
pinMode(PIN_SPEAKER_2, OUTPUT);
|
|
|
|
#else
|
|
|
|
pinMode(PIN_SPEAKER_1, OUTPUT);
|
|
|
|
#endif
|
2015-05-01 05:26:58 +00:00
|
|
|
audio_enabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ArduboyAudio::off()
|
|
|
|
{
|
|
|
|
audio_enabled = false;
|
2016-03-02 01:49:46 +00:00
|
|
|
// shut off audio pins
|
2016-06-26 21:28:41 +00:00
|
|
|
#ifdef ARDUBOY_10
|
|
|
|
pinMode(PIN_SPEAKER_1, INPUT);
|
|
|
|
pinMode(PIN_SPEAKER_2, INPUT);
|
|
|
|
#else
|
|
|
|
pinMode(PIN_SPEAKER_1, INPUT);
|
|
|
|
#endif
|
2015-05-01 05:26:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ArduboyAudio::saveOnOff()
|
|
|
|
{
|
2016-03-02 17:31:41 +00:00
|
|
|
EEPROM.update(EEPROM_AUDIO_ON_OFF, audio_enabled);
|
2015-05-01 05:26:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ArduboyAudio::begin()
|
|
|
|
{
|
|
|
|
if (EEPROM.read(EEPROM_AUDIO_ON_OFF))
|
|
|
|
on();
|
|
|
|
}
|
|
|
|
|
2016-06-26 21:28:41 +00:00
|
|
|
bool ArduboyAudio::enabled()
|
|
|
|
{
|
|
|
|
return audio_enabled;
|
|
|
|
}
|