Big Mouth Billy Bass player that takes raw wavefiles and decision list text files from an SD card

Dependencies:   SDFileSystem mbed BillyBass

Files at this revision

API Documentation at this revision

Comitter:
bikeNomad
Date:
Thu Jun 20 03:04:50 2013 +0000
Parent:
13:c13b3db9649b
Child:
15:03105423bc3b
Commit message:
Added diagnostic output and manual (keyboard) testing

Changed in this revision

BillyBass.lib Show annotated file Show diff for this revision Revisions of this file
config.hpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/BillyBass.lib	Wed Jun 19 16:12:36 2013 +0000
+++ b/BillyBass.lib	Thu Jun 20 03:04:50 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/bikeNomad/code/BillyBass/#869b3711bdb3
+http://mbed.org/users/bikeNomad/code/BillyBass/#ea8136eb6976
--- a/config.hpp	Wed Jun 19 16:12:36 2013 +0000
+++ b/config.hpp	Thu Jun 20 03:04:50 2013 +0000
@@ -40,6 +40,12 @@
 #define SERIAL_BAUD 115200
 #define ANALOG_OUTPUT_BIAS  0x8000
 
+#define BODY_ON_DELAY 0.65
+#define BODY_OFF_DELAY 0.83
+#define TAIL_ON_DELAY 0.40
+#define TAIL_OFF_DELAY 0.40
+#define MOUTH_ON_DELAY 0.30
+#define MOUTH_OFF_DELAY 0.30
 
 // Power:
 // Power GND  J9/14
--- 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);