Big Mouth Billy Bass automation library

Dependents:   BillyBass_with_SD

Files at this revision

API Documentation at this revision

Comitter:
bikeNomad
Date:
Thu Jun 20 03:04:36 2013 +0000
Parent:
5:869b3711bdb3
Child:
7:dba9221acf48
Commit message:
Added diagnostic output and manual (keyboard) testing

Changed in this revision

action.hpp Show annotated file Show diff for this revision Revisions of this file
player.hpp Show annotated file Show diff for this revision Revisions of this file
song.cpp Show annotated file Show diff for this revision Revisions of this file
song.hpp Show annotated file Show diff for this revision Revisions of this file
--- a/action.hpp	Wed Jun 19 16:12:11 2013 +0000
+++ b/action.hpp	Thu Jun 20 03:04:36 2013 +0000
@@ -14,14 +14,17 @@
            bool _state = false,
            DigitalOut *_out = 0,
            char const *_outName = 0)
-        : actionTime(_time), desiredState(_state)
-        , output(_out) {
+        : actionTime(_time)
+        , output(_out)
+        , desiredState(_state)
+        , code('.') {
+        if (_outName) code = _outName[0];
     }
 
     bool operator < (Action const &other) const {
         return actionTime < other.actionTime;
     }
-    
+
     // return <0 if *p1 is before *p2
     static int compare(const void* p1, const void* p2) {
         return static_cast<Action const *>(p1)->actionTime - static_cast<Action const *>(p2)->actionTime;
@@ -41,15 +44,18 @@
             return true;
         } else return false;
     }
-    void set(float _time, int _state, DigitalOut* _out) {
+
+    void set(float _time, int _state, DigitalOut* _out, char _code = '.') {
         actionTime = _time;
         desiredState = _state;
         output = _out;
+        code = _code;
     }
 
     float actionTime;
-    int desiredState;
     DigitalOut *output;
+    uint8_t desiredState;
+    char code;
 };
 
 #endif
--- a/player.hpp	Wed Jun 19 16:12:11 2013 +0000
+++ b/player.hpp	Thu Jun 20 03:04:36 2013 +0000
@@ -150,7 +150,8 @@
         Action* lastAction = song->getActions() + song->getNumActions();
         while (!isDone()) {
             while (nextAction < lastAction && nextAction->actIfPast(timeInSong)) {
-                fprintf(stderr, ".");
+                fputc(nextAction->code, stderr);
+                // fprintf(stderr, "%c", nextAction->code);
                 actionsDone++;
                 nextAction++;
             }
--- a/song.cpp	Wed Jun 19 16:12:11 2013 +0000
+++ b/song.cpp	Thu Jun 20 03:04:36 2013 +0000
@@ -129,8 +129,8 @@
         }
         // fprintf(stderr, "%d add %f %f %s\r\n", line, startTime, endTime, outName);
 
-        addAction(startTime, bass->onState(), out);
-        addAction(endTime, bass->offState(), out);
+        addAction(startTime, bass->onState(), out, toupper(outName[0]));
+        addAction(endTime, bass->offState(), out, outName[0]);
     }
     fprintf(stderr, "Added %d actions\r\n", numActions);
     qsort(actions, numActions, sizeof(Action), &Action::compare);
--- a/song.hpp	Wed Jun 19 16:12:11 2013 +0000
+++ b/song.hpp	Thu Jun 20 03:04:36 2013 +0000
@@ -53,9 +53,9 @@
     Action *getActions() {
         return actions;
     }
-    bool addAction(float _time, int _state, DigitalOut* _out) {
+    bool addAction(float _time, int _state, DigitalOut* _out, char _code) {
         if (numActions >= MAX_ACTIONS_PER_SONG) return false;
-        actions[numActions++].set(_time, _state, _out);
+        actions[numActions++].set(_time, _state, _out, _code);
         return true;
     }
     unsigned getNumActions() const {