forked from bxparks/AceRoutine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSoundRoutine.cpp
37 lines (31 loc) · 884 Bytes
/
SoundRoutine.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <Arduino.h>
#include "SoundRoutine.h"
void SoundRoutine::playSound(int sound) {
currentSound = sound;
reset();
}
int SoundRoutine::runCoroutine() {
COROUTINE_LOOP() {
switch (currentSound) {
case SOUND_NONE:
Serial.println("<silence>");
break;
case SOUND_BEEP:
// Calls to tone() go here, interspersed with some COROUTINE_DELAYs.
Serial.println("First BEEP");
COROUTINE_DELAY(500);
Serial.println("Second BEEP");
break;
case SOUND_BOOP:
// Calls to tone() go here, interspersed with some COROUTINE_DELAYs.
Serial.println("First BOOP");
COROUTINE_DELAY(500);
Serial.println("Second BOOP");
break;
default:
Serial.println("Unknown sound!");
}
currentSound = SOUND_NONE;
COROUTINE_AWAIT(currentSound != SOUND_NONE);
}
}