![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Cricket (insect) emulation
Fork of talking by
Diff: cricket.cpp
- Revision:
- 3:1b91d910dabd
- Parent:
- 2:c6c74e788985
--- 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);