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: mbed
Diff: main.cpp
- Revision:
- 15:31d09ee65cf1
- Parent:
- 14:0caa7b93af7a
diff -r 0caa7b93af7a -r 31d09ee65cf1 main.cpp
--- a/main.cpp	Wed May 23 11:50:58 2018 +0000
+++ b/main.cpp	Wed Jul 04 09:14:37 2018 +0000
@@ -7,32 +7,41 @@
 #include "AutoDrive.h"
 #include "RouteCalculation.h"
 
-
+DigitalIn ModeSwitch (PB_0);
 char* route;
 
 // inizialisieren der Karte
 int map[20][10];
-
+bool mappingpassed = false;
 
 
 
-int main(){
+int main()
+{
     printf("startup");
     startup();
-    wait(5);
-    
-    // Mapping Modus
-    printf("mapping");
-    mapping(map);
-    
-    
-    // Autodrive Modus
-    printf("Route wird berechnet");
-    route = RouteCalculation(map);
-    printf("Berechnung Abgeschlossen");
-    //wait(20);
-    //printf("strecke wird abgefahren");
-    //autoDrive(route);
-    
+    wait(10);
+
+    while(1) {
+        // Mapping Modus
+        if (ModeSwitch == 0) {               //Modus Schalter abfrage
+            wait(0.5);                       //Schalter entprellen
+            if (mappingpassed == false){     //Mapping kann nicht zwei mal nacheinander abgefahren werden, autoDrive muss dazwischen aufgerufen werden
+                printf("mapping");
+                mapping(map);
+                mappingpassed = true;
+            }
+        } else {                             //Modus berechnen und Abfahren 
+            wait(0.5);                       //Schalter entprellen
+            // Autodrive Modus
+            printf("Route wird berechnet");
+            //route = RouteCalculation(map);
+            printf("Berechnung Abgeschlossen");
+            mappingpassed = false; 
+            //wait(20);
+            //printf("strecke wird abgefahren");
+            //autoDrive(route);
+        }
+    }
 }