premiere ebauche

Dependencies:   mbed PinDetect

Revision:
12:cf97590d9df2
Parent:
10:f0b382368614
Child:
13:47806f4dbfcd
--- a/main.cpp	Sat Nov 17 18:52:17 2018 +0000
+++ b/main.cpp	Sun Nov 18 03:30:57 2018 +0000
@@ -50,16 +50,20 @@
 {
     CANMessage msg;
     if(can.read(msg)) {
-        if (msg.id == 0x185) {
-//            float pedal = (msg.data[1] << 8 | msg.data[0]) * 0.00390625;
+        if (msg.len != 8) {
+            ; // drop message
+        } else if (msg.id == 0x185) {
+            // shift first byte to HI, then fill LO with second byte
             float speed = (msg.data[6] << 8 | msg.data[7]) * 0.1;
-
+//            float power = (msg.data[5]);
+            
             if (speed < 45) {
-//                pc.printf("Pedal: %.3f\tSpeed: %.3f\n\r", pedal, speed);
                 speedLimiter.setMeasuredSpeed(speed);
             }
         } else if(msg.id == 0x181) {
-
+//            float motorCurrent = (msg.data[2] << 8 | msg.data[3]) * 1.0;
+        } else if(msg.id == 0x322) {
+//            float energySoc = (msg.data[2] << 8 | msg.data[3]);
         }
     }
 }