Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: RemoteIR m3pi mbed-rtos mbed
Diff: Controller.cpp
- Revision:
- 7:1d77c7e0208c
- Parent:
- 1:76cff32344d1
- Child:
- 8:aff4290aacff
--- a/Controller.cpp	Wed May 10 00:46:48 2017 +0200
+++ b/Controller.cpp	Wed May 10 09:29:05 2017 +0200
@@ -4,28 +4,32 @@
 
 #include "Controller.h"
 
+void Controller::runThread(){
+    lightCommunication->receiveData();
+}
+
 Controller::Controller() {
     //constructor once to initialise
-    static LightCommunication lightCommunication;
+    lightCommunication = new LightCommunication();
     car = new m3pi();
-    receiveThread.start(&LightCommunication::receiveData);
+    receiveThread.start(Controller::runThread);
     ir_rx = new ReceiverIR(p21);
+
 }
 
 Controller::~Controller() {
 
 }
-
 int Controller::run() {
 
-    LightCommunication::mut.lock();
-    if (LightCommunication::needsToStop()){
+    lightCommunication->mut.lock();
+    if (lightCommunication->needsToStop()){
         car->stop();
-        LightCommunication::mut.unlock();
+        lightCommunication->mut.unlock();
     }else {
-        current_left = LightCommunication::getLeft(current_left);
-        current_right = LightCommunication::getRight(current_right);
-        LightCommunication::mut.unlock();
+        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) ;
     }
    