Big Mouth Billy Bass player that takes raw wavefiles and decision list text files from an SD card
Dependencies: SDFileSystem mbed BillyBass
Diff: main.cpp
- Revision:
- 14:79b3fd23c7b5
- Parent:
- 13:c13b3db9649b
- Child:
- 16:82a1bdc3320f
--- a/main.cpp Wed Jun 19 16:12:36 2013 +0000 +++ b/main.cpp Thu Jun 20 03:04:50 2013 +0000 @@ -3,6 +3,7 @@ #include "song.hpp" #include "player.hpp" #include "action.hpp" +#include <ctype.h> // tailPin, mouthPin, bodyPin inverted // BillyBass testBass(LED_RED, LED_GREEN, LED_BLUE, true); @@ -23,10 +24,45 @@ SDFileSystem sd(SD_MOSI, SD_MISO, SD_SCLK, SD_CS, SD_NAME); Serial pc(USBTX, USBRX); +Timer t; + +void serialIrqHandler() +{ + int c = pc.getc(); + bool isLower = islower(c); + c = toupper(c); + DigitalOut *out = 0; + float elapsed = t.read(); + t.reset(); + pc.printf("%d %f\r\n", (int)!isLower, elapsed); + + switch (c) { + case 'H': + case 'B': + out = bass1.outputNamed("body"); + break; + case 'T': + out = bass1.outputNamed("tail"); + break; + case 'M': + out = bass1.outputNamed("mouth"); + default: + break; + } + if (out) { + if (isLower) + out->write(0); + else + out->write(1); + } +} + int main() { SongPlayer player; pc.baud(SERIAL_BAUD); + t.start(); + pc.attach(serialIrqHandler); button1.mode(PullUp); button2.mode(PullUp);