audio on/off sets up pins appropriately for each mode

This commit is contained in:
Josh Goebel 2016-03-01 20:49:46 -05:00 committed by Scott Allen
parent 305423f600
commit 2361d0d20f
2 changed files with 18 additions and 5 deletions

View File

@ -5,6 +5,13 @@ bool ArduboyAudio::audio_enabled = false;
void ArduboyAudio::on() void ArduboyAudio::on()
{ {
// fire up audio pins
#ifdef ARDUBOY_10
pinMode(PIN_SPEAKER_1, OUTPUT);
pinMode(PIN_SPEAKER_2, OUTPUT);
#else
pinMode(PIN_SPEAKER_1, OUTPUT);
#endif
audio_enabled = true; audio_enabled = true;
} }
@ -16,6 +23,13 @@ bool ArduboyAudio::enabled()
void ArduboyAudio::off() void ArduboyAudio::off()
{ {
audio_enabled = false; audio_enabled = false;
// shut off audio pins
#ifdef ARDUBOY_10
pinMode(PIN_SPEAKER_1, INPUT);
pinMode(PIN_SPEAKER_2, INPUT);
#else
pinMode(PIN_SPEAKER_1, INPUT);
#endif
} }
void ArduboyAudio::saveOnOff() void ArduboyAudio::saveOnOff()

View File

@ -100,13 +100,12 @@
#define B_BUTTON _BV(0) #define B_BUTTON _BV(0)
#define PIN_SPEAKER_1 A2 #define PIN_SPEAKER_1 A2
#define PIN_SPEAKER_2 A3
#define PIN_SPEAKER_1_PORT &PORTF #define PIN_SPEAKER_1_PORT &PORTF
#define PIN_SPEAKER_2_PORT &PORTF
#define PIN_SPEAKER_1_BITMASK _BV(5) #define PIN_SPEAKER_1_BITMASK _BV(5)
#define PIN_SPEAKER_2_BITMASK _BV(4) // SPEAKER_2 is purposely not defined for DEVKIT as it could potentially
// be dangerous and fry your hardware (because of the devkit wiring).
//
// Reference: https://github.com/Arduboy/Arduboy/issues/108
#endif #endif