Matti Borchers / Mbed 2 deprecated mbed_amf_controlsystem_iO_copy

Dependencies:   mbed-rtos mbed

Fork of mbed_amf_controlsystem_iO_copy by Oliver Wenzel

Revision:
17:76636aaf80de
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Modus/Parking.cpp	Mon Feb 08 14:56:34 2016 +0000
@@ -0,0 +1,50 @@
+#include "Modus/Parking.h"
+
+int Parking::lightimpulseCounter;
+
+void Parking::increaseLightimpulseCounter(){                     
+    lightimpulseCounter++;
+}
+
+int Parking::getDistance(void){                                  
+    int distance = lightimpulseCounter * 4;
+    lightimpulseCounter = 0;
+    return distance;
+}
+
+void Parking::parking_thread(void const *args) {
+    float size_parking_space;
+    
+    if(Parking::redlight == 1){
+        while(true){
+            do{
+            }while(Parking::redlight == 1);
+                Parking::getDistance();
+            do{
+            }while(Parking::redlight == 0);
+            
+            size_parking_space = Parking::getDistance();
+            //serialMinnow.printf("Parklücke[mm]: %f\r\n", size_parking_space);
+                
+            if(size_parking_space < 600 && size_parking_space > 500){
+                    
+                drivePWM.pulsewidth_us(1700);   //Stück nach vorne fahren
+                wait_ms(400);
+                drivePWM.pulsewidth_us(1500);   //Stehen
+                wait_ms(200);
+                drivePWM.pulsewidth_us(1325);   //1. Einschlag voll rechts
+                steerPWM.pulsewidth_us(2000);
+                wait_ms(970);
+                steerPWM.pulsewidth_us(1000);   //2. Einschlag - voll links
+                wait_ms(950);
+                drivePWM.pulsewidth_us(1700);   //Korrektur nach vorne - leicht rechts
+                steerPWM.pulsewidth_us(1700);
+                wait_ms(420);
+                drivePWM.pulsewidth_us(1500);   //Ende
+                steerPWM.pulsewidth_us(1500);
+                //3mal aufblinken der Blinker
+                break;
+             }
+        }
+    }
+}
\ No newline at end of file