Big Mouth Billy Bass automation library

Dependents:   BillyBass_with_SD

Revision:
7:dba9221acf48
Parent:
6:ea8136eb6976
--- a/action.hpp	Thu Jun 20 03:04:36 2013 +0000
+++ b/action.hpp	Thu Jun 20 04:10:22 2013 +0000
@@ -22,12 +22,16 @@
     }
 
     bool operator < (Action const &other) const {
-        return actionTime < other.actionTime;
+        if (actionTime < other.actionTime) return true;
+        if (actionTime > other.actionTime) return false;
+        return (code < other.code);
     }
 
     // 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;
+        float tdiff = static_cast<Action const *>(p1)->actionTime - static_cast<Action const *>(p2)->actionTime;
+        if (tdiff != 0.0) return tdiff;
+        return static_cast<Action const *>(p1)->code - static_cast<Action const *>(p2)->code;
     }
 
     bool isValid() const {
@@ -38,8 +42,12 @@
         output->write(desiredState ? 1 : 0);
     }
 
+    bool isPast(float _now) {
+        return _now >= actionTime;
+    }
+
     bool actIfPast(float _now) {
-        if (_now >= actionTime) {
+        if (isPast(_now)) {
             act();
             return true;
         } else return false;