Sakis Kasampalis
/
cricket
Cricket (insect) emulation
Fork of talking by
Revision 3:1b91d910dabd, committed 2017-02-11
- Comitter:
- faif
- Date:
- Sat Feb 11 15:49:06 2017 +0000
- Parent:
- 2:c6c74e788985
- Commit message:
- Reorganize code
Changed in this revision
cricket.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r c6c74e788985 -r 1b91d910dabd cricket.cpp --- a/cricket.cpp Sat Feb 11 15:45:54 2017 +0000 +++ b/cricket.cpp Sat Feb 11 15:49:06 2017 +0000 @@ -12,15 +12,6 @@ static const float ticker_rhythm = 10E-5; // 9.766 kHz sample rate (1/9766 sec delay) static const char clip_path[] = "/local/cricket.wav"; - -bool done = false; - - -void myrhythm() -{ - done = true; -} - int main () { const int size = 1165; // 32K max in total (~30K is enough for testing) @@ -38,6 +29,13 @@ } } +bool done = false; + +void myrhythm() +{ + done = true; +} + void waitForButton(DigitalOut& led, DigitalIn& button) { led = ON; @@ -68,12 +66,12 @@ void randomPause() { float c = rand() % 100; - // 30% percentage to wait 2 sec + // 30% chance to wait 2 sec if (c > 70) { wait(2); } - // 70% percentage to wait 0-1 sec + // 70% chance to wait 0-1 sec else { wait(c / 100);