A system to help you ride your bike better than you do right now.

Dependencies:   4DGL-uLCD-SE SDFileSystem mbed LSM9DS1_Library_cal

Revision:
1:9d3f2e86392e
Parent:
0:134f49df01f8
Child:
2:d08643ff3c62
--- a/main.cpp	Fri Dec 02 22:15:09 2016 +0000
+++ b/main.cpp	Fri Dec 02 22:37:58 2016 +0000
@@ -14,7 +14,7 @@
 int main() {
     
     // open the file for reading and appending records
-    FILE *fp = fopen("/sd/records/best-of.txt", "a+");
+    
     
     // recall last trip
     recall_trip(&fp);
@@ -39,7 +39,10 @@
 }
 
 void store_trip(FILE * fp) {
-    // write trip results to the SD card 
+    // write trip results to the SD card
+    if (fp == NULL) {
+        
+    }
 }
 
 void recall_trip(FILE * fp) {
@@ -47,10 +50,24 @@
     // display the most impressive trip (longest distance, best speed, least time)
     
     int lineCount;
-    std::ifstream file("/sd/records/best-of.txt");
     char str[12];
     char split;
     
+    // read out the most recent trip
+    FILE *fp = fopen("/sd/records/recent.txt", "r");
+    
+    if (fp == NULL) {
+        lcd.locate(0, 1);
+        lcd.printf("Could not open file for write\n");
+    } else {
+        std::getline(file, str);
+        lcd.locate(0, 1);
+        lcd.printf("Most recent trip\n%s", str);
+    }
+    
+    // read out the most impressive trip so far
+    FILE *fp = fopen("/sd/records/best_of.txt", "r");
+
     if(fp == NULL) {
         lcd.locate(0, 1);
         lcd.printf("Could not open file for write\n");