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: Mapping.cpp
- Revision:
- 6:a1fd0f1374e6
- Parent:
- 0:4a0b987c5c94
- Child:
- 8:73c8188916dc
--- a/Mapping.cpp Sun Apr 29 11:48:33 2018 +0000
+++ b/Mapping.cpp Mon Apr 30 13:53:09 2018 +0000
@@ -4,6 +4,8 @@
#include "ReadFinalLine.h"
#include "ReadSensor.h"
#include "Mapping.h"
+#include "SDFileSystem.h"
+
//debug
//DigitalOut myled(LED2);
@@ -19,7 +21,7 @@
// int wait(int time); Systemfunktion für Pausen
-// SDFileSystem sd(PB_5, PB_4, PB_3, PB_10, "sd"); //mosi, miso, sclk, cs
+SDFileSystem sd(PB_5, PB_4, PB_3, PB_10, "sd"); //mosi, miso, sclk, cs
void mapping(void){ //------------------------------------------------------------------------------------------------------ Mapping
@@ -61,8 +63,6 @@
// Zustandsvariabel während Fahrt = 1 bei Ziel =0
int drive = 1;
-int targetReached = 0; // Wird auf 1 gesetzt bei überschrittener Ziellinie sonst 0
-
// Startinitialisierung, Bestimmen der Abfahrtsrichtung aus dem ersten Feld
if (readSensor(front) == false){ // Gegen vorne freie Fahrt (kein Hindernis -> 0)
@@ -101,7 +101,7 @@
// Farhralgorithmus
while (drive == 1){
-wait(pause);
+//wait(pause);
// Variabeln zurücksetzen
P_straight = 1;
P_rightTurn = 1;
@@ -330,7 +330,7 @@
}
// Bei Ueberfahren der Ziellinie
- if(targetReached == true){ // Prüft Linienüberfahrt
+ if(readFinalLine() == true){ // Prüft Linienüberfahrt
drive = 0; // Beendet Schlafendurchlauf
}
@@ -369,22 +369,22 @@
// Karte auf SD speichern-------------------------------------------------------------------------------------
- /*
+
//Mount the filesystem
sd.mount();
int i;
- int g;
+ int k;
//Perform a write test
printf("\nWriting to SD card...");
FILE *fp = fopen("/sd/map.csv", "w");
if (fp != NULL) {
for (i = 0; i < 9; i++){
- for (g = 0; g < 19; g++){
- fprintf(fp, "%d,",map[g,i]);
+ for (g = 0; k < 19; g++){
+ fprintf(fp, "%d,",map[k,i]);
}
- fprintf(fp,"\n\r")
+ fprintf(fp,"\n\r");
}
printf("Matrix has been sucessfully saved in map.csv\n\r");
} else {
@@ -393,7 +393,7 @@
//Unmount the filesystem
sd.unmount();
- */
+
}