Aleksandar Kodzhabashev / Mbed 2 deprecated TrackballQuery

Dependencies:   Servo mbed

Files at this revision

API Documentation at this revision

Comitter:
d3alek
Date:
Wed Mar 19 18:44:49 2014 +0000
Parent:
13:582064cfb9b2
Commit message:
best achieved;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mylib/PS2/PS2MS_INIT.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Mar 13 16:59:09 2014 +0000
+++ b/main.cpp	Wed Mar 19 18:44:49 2014 +0000
@@ -140,6 +140,8 @@
     int mTooFarOffFor = 0;
     const int MAX_TOO_FAR_OFF_COUNT = 2;
     
+    long thisMs = 0, lastMs = 0;
+    
     while(1) {
         if (pc.readable()) {
             processSerial();
@@ -214,21 +216,24 @@
                 awaitingPackets = true;
             }
         }
-
+        // dilemma - else or no else?
         if (expectingAck1) {
             expectingAck1 = !getPacket(0);
-        } else if (expectingAck2) {
+        } 
+        else if (expectingAck2) {
             expectingAck2 = !getPacket(1);
-        } else if (expectingAck3) {
+        }
+        else if (expectingAck3) {
             expectingAck3 = !getPacket(2);
         }
         // TODO only prints when both are enabled now
         if (sensorToPrint[0] && sensorToPrint[1] && sensorToPrint[2]) {
+            thisMs = timer.read_ms();
             if ((sensorXs[0] | sensorYs[0] | sensorXs[1] | sensorYs[1] | sensorXs[2] | sensorYs[2]) ) {
                 // some of the velocities are not 0
                 if (notTooFarOff()) {
-                    printf("%d : %d %d %d %d %d %d\n\r", SENSORS_NUM, sensorXs[0], sensorYs[0], sensorXs[1], sensorYs[1],
-                       sensorXs[2], sensorYs[2]);
+                    printf("%d : %d %d %d %d %d %d %d\n\r", SENSORS_NUM, sensorXs[0], sensorYs[0], sensorXs[1], sensorYs[1],
+                       sensorXs[2], sensorYs[2], thisMs - lastMs);
                 }
                 else {
                     mTooFarOffFor++;
@@ -246,6 +251,7 @@
                     }
                 }
             }
+            lastMs = thisMs;
             mTooFarOffFor = 0;
             sensorToPrint[0] = sensorToPrint[1] = sensorToPrint[2] = false;
             sensorXs[0] = sensorYs[0] = sensorXs[1] = sensorYs[1] = sensorXs[2] = sensorYs[2] = 0;
--- a/mylib/PS2/PS2MS_INIT.cpp	Thu Mar 13 16:59:09 2014 +0000
+++ b/mylib/PS2/PS2MS_INIT.cpp	Wed Mar 19 18:44:49 2014 +0000
@@ -27,7 +27,7 @@
      */
     //char txdat[17] = "\xFF\xFF\xFF\xF3\xC8\xF3\x64\xF3\x50\xF2\xE8\x03\xE6\xF3\x28\xF4";
     //char txdat[11] = "\xFF\xFF\xFF\xF2\xE8\x03\xE6\xF3\xC8\xF4";
-    char txdat[12] = "\xFF\xFF\xFF\xF2\xE8\x03\xE6\xF3\x28\xF0\xF4";
+    char txdat[12] = "\xFF\xFF\xFF\xF2\xE8\x02\xE6\xF3\x28\xF0\xF4";
     const int n = sizeof(txdat);
     int txerrcnt = 0;
     int rxerrcnt = 0;