Kristof T'Jonck / Mbed 2 deprecated proj2_car

Dependencies:   RemoteIR m3pi mbed-rtos mbed

Revision:
1:76cff32344d1
Child:
7:1d77c7e0208c
diff -r ef54cd039c52 -r 76cff32344d1 Controller.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Controller.cpp	Tue May 09 23:02:13 2017 +0200
@@ -0,0 +1,33 @@
+//
+// Created by Kristof on 5/9/2017.
+//
+
+#include "Controller.h"
+
+Controller::Controller() {
+    //constructor once to initialise
+    static LightCommunication lightCommunication;
+    car = new m3pi();
+    receiveThread.start(&LightCommunication::receiveData);
+    ir_rx = new ReceiverIR(p21);
+}
+
+Controller::~Controller() {
+
+}
+
+int Controller::run() {
+
+    LightCommunication::mut.lock();
+    if (LightCommunication::needsToStop()){
+        car->stop();
+        LightCommunication::mut.unlock();
+    }else {
+        current_left = LightCommunication::getLeft(current_left);
+        current_right = LightCommunication::getRight(current_right);
+        LightCommunication::mut.unlock();
+        car->left_motor(current_left) ;
+        car->right_motor(current_right) ;
+    }
+    return 0;
+}