m3pi for proj2

Dependencies:   RemoteIR m3pi mbed-rtos mbed

Revision:
6:02f045d7695d
Parent:
5:5d2beac511c1
Child:
7:1d77c7e0208c
--- a/LightCommunication.cpp	Wed May 10 00:01:25 2017 +0200
+++ b/LightCommunication.cpp	Wed May 10 00:46:48 2017 +0200
@@ -27,14 +27,13 @@
 
 void LightCommunication::getIRStyle(uint8_t * buf) {
     RemoteIR::Format format;
-    int bitcount;
     if (ir_rx.getState() == ReceiverIR::Received) {
-        bitcount = ir_rx.getData(&format, buf, sizeof(buf) * 8);
+        ir_rx.getData(&format, buf, sizeof(buf) * 8);
     }
 }
 
 void LightCommunication::receiveData() {
-    mut.lock();
+    LightCommunication::mut.lock();
     //uint8_t *  data = LightCommunication::getIRStyle();
     char  data[3];
     LightCommunication::getSerial(data);
@@ -45,16 +44,17 @@
         left = LightCommunication::toFloat(data[1]);
         right = LightCommunication::toFloat(data[2]);
     }
-    mut.unlock();
+
+    LightCommunication::mut.unlock();
 }
 
 float LightCommunication::getRight(float cur_right){
     float r = right - cur_right;
     if (r>0){
-        return (cur_right + 0.005);
+        return (float)(cur_right + 0.005);
     }else if (r<0){
 
-        return (cur_right -0.005);
+        return (float)(cur_right -0.005);
     }else{
         return cur_right;
     }
@@ -65,9 +65,9 @@
     mut.lock();
     float l = left - cur_left;
     if (l>0){
-        return (cur_left + 0.005);
+        return (float)(cur_left + 0.005);
     }else if (l<0){
-        return (cur_left -0.005);
+        return (float)(cur_left -0.005);
     }else{
         return cur_left;
     }
@@ -78,10 +78,7 @@
 }
 
 bool LightCommunication::needsToStop() {
-    if (right == 0 && left == 0){
-        return true;
-    }
-    return false;
+    return right == 0 && left == 0;
 }