I have added the low battery function, but I have yet to be able to try the amplifier power function since I am away from home at work. The whole file is at http://www.r2db.me/TIE/TKTalkie.ino
int OUTPUT_ENABLE_PIN = -1; // This pin is for the amplifier output enable signal, used by some amplifiers
// to put the amplifier in a low-power state when no audio is being played.
// Set to -1 to disable this feature
int LOW_BATTERY_PIN = -1; // This pin is a digital input, used if your power supply has a low power warning.
// This is assumed to be a high = adequate battery voltage, low = low battery
// voltage. Set to -1 to disable this feature.
bool BATTERY_GOOD = true;
String LOW_BATTERY_WAV = "LOWBATT.wav";
String GOOD_BATTERY_WAV = "GOODBATT.wav";
Bounce LBP = Bounce(); // Used to read low battery pin (if feature is enabled)
/***
* Check if the low battery signal has gone low
*/
boolean checkBattery()
{
if (LBP.update()) { // If there was a change in the battery state since the last update then:
if (!LBP.read()) { // If the battery was previously good and now is low, play .wav file.
playEffect(EFFECTS_PLAYER, LOW_BATTERY_WAV);
return false; // sample: "Critical failure in power bus. Expect comm system failure."
} else { // The battery was previously low but is now good.
playEffect(EFFECTS_PLAYER, GOOD_BATTERY_WAV);
return true; // sample: "Power bus reconfiguration successful."
}
} else {
return BATTERY_GOOD; // Return the same value currently in the variable, the state hasn't changed.
}
}