switch(mode){
case Mode::Ready:
// Rising edge occurs when the handset is lifted
if (buttonRecord.risingEdge()) {
Serial.println("Handset lifted");
mode = Mode::Prompting;
}
else if(buttonPlay.fallingEdge()) {
playAllRecordings();
}
break;
case Mode::Prompting:
// Wait a second for users to put the handset to their ear
wait(1000);
// Play the greeting inviting them to record their message
playWav1.play("greeting.wav");
// Wait until the message has finished playing
while (playWav1.isPlaying()) {
// Check whether the handset is replaced
buttonRecord.update();
// Handset is replaced
if(buttonRecord.fallingEdge()) {
playWav1.stop();
mode = Mode::Ready;
return;
}
}
// Debug message
Serial.println("Starting Recording");
// Play the tone sound effect
waveform1.frequency(440);
waveform1.amplitude(0.9);
wait(250);
waveform1.amplitude(0);
// Start the recording function
startRecording();
break;