RainbowTeam / Mbed 2 deprecated ProjectTheseus

Dependencies:   mbed

Revision:
12:811b1364679e
Parent:
6:a1fd0f1374e6
--- a/RouteCalculation.cpp	Sat May 12 12:19:26 2018 +0000
+++ b/RouteCalculation.cpp	Fri May 18 11:36:48 2018 +0000
@@ -7,7 +7,6 @@
 #include "AutoDrive.h"
 #include "RouteCalculation.h"
 #include "SDFileSystem.h"
-
 // Routenberechnung
 // rückgabe 2d-Array route
 
@@ -73,33 +72,31 @@
     actionIndex = 1;
     int i = 0;
     
-    int counterS = 0;
-    int counterZ = 0;
-    
-    char *str;
+    int counterY = 0;
+    int counterX = 0;
+    unsigned char a;
      
     //SD-Karte lesen
-    sd.mount();
-    printf("Reading from SD card...");
-    FILE *fp = fopen("/sd/map.csv", "r");
-    if (fp != NULL) {
-       fgets(str,500,fp);       // liesst gesammten Inhalt von map.csv ein
-       char *ptr = strtok(str, ",;");
-        for (counterZ; counterZ < 9; counterZ++) {
-            
-            for (counterS; counterS < 19; counterS++){
-                map[counterS][counterZ] = atoi(ptr);
-                ptr = strtok(NULL, ",;"); // zum  nächsten Element wechseln
+    FILE *fp = fopen("/sd/map.txt", "r");  // open the file in 'read' mode
+    while (!feof(fp)) {                       // while not end of file
+        a=fgetc(fp);                         // get a character/byte from the file
+
+        if(a == 10 || a == 13) {
+        //do nothing
+        } else {
+            map[counterX][counterY] = a;
+            counterX = counterX+1;
+            if(counterX == 20) {
+                counterX = 0;
+                counterY = counterY+1;
+                if(counterY == 10) {
+                    break;
                 }
+
             }
-               
-    fclose(fp);   
+        }
+
     }
-    else {
-        printf("Read-process failed!\nNo file available!\n\r");
-    }
-    sd.unmount();
-    
     //-----------------------------------------------------------------------
     
     if (map[X-1][ Y-1] == 0){