Program to read data from sensors, write them to a file which can then be interpreted by software to help show the path of a bicycle as it travels around a field

Dependencies:   C12832_lcd FatFileSystemCpp MMA7660 CMPS03 GPS

Fork of MSCUsbHost by Igor Skochinsky

Program to link a compass and a GPS to an MBED to produce a CSV file which can be used to track a bicycle around a field

Results can be found here

Revision:
18:0ced1be44292
Parent:
17:c4ead6f1ebd9
Child:
19:3da2ac9aa081
--- a/main.cpp	Tue Mar 21 20:06:13 2017 +0000
+++ b/main.cpp	Thu Mar 23 15:36:38 2017 +0000
@@ -4,7 +4,6 @@
 #include "CMPS03.h" // Compass library
 #include "C12832_lcd.h" // LCD screen library
 #include "MSCFileSystem.h"
- 
 #define FSNAME "USB"
 #define LIM 300
  
@@ -14,7 +13,6 @@
 C12832_LCD lcd;
 Serial pc(USBTX, USBRX);
  
- 
 // Declarations
 float ax, ay, az;
 DigitalOut connectionLed(LED1);
@@ -22,11 +20,6 @@
  
 int main()
 {
-    /*
-    DIR *d;
-    struct dirent *p; // For printing externally (USB Stick)
-    d = opendir("/" FSNAME);
-    */
     if (MMA.testConnection())
         connectionLed = 1; // Checking MMA connected correctly
    
@@ -44,7 +37,7 @@
         ax=MMA.x();
         ay=MMA.y();
         az=MMA.z();
-        fprintf(Accel,"%f, %f, %f,\r\n",ax,ay,az);
+        fprintf(Accel,"%f, %f, %f, %.1f\r\n",ax,ay,az, gps.rtime);
         lcd.locate(1,21);
         lcd.printf("Accel: %.2f, %.2f, %.2f", ax, ay, az);
                 
@@ -52,7 +45,7 @@
         GPS = fopen("/USB/GPS.csv", "a");
         if (gps.sample())
         {
-            fprintf(GPS, "%f, %f, %.0f\r\n", gps.latitude, gps.longitude, gps.rtime);
+            fprintf(GPS, "%f, %f, %.1f\r\n", gps.latitude, gps.longitude, gps.rtime);
             lcd.locate(1,1);
             lcd.printf("GPS: %.4f, %.4f, %f", gps.latitude, gps.longitude, gps.rtime);
         }       
@@ -64,7 +57,6 @@
         }
         
         // Compass
-        //Offset = compass.readBearing();  // Initial definitions
         Comp = fopen("/USB/Compass.csv", "a");
         lcd.locate(1,11);
         bearing = (compass.readBearing()/10) - 150;
@@ -72,15 +64,12 @@
         {
             bearing = 360 + bearing;
         }
-        lcd.printf("Bearing: %.2f\n", bearing);
+        lcd.printf("Bearing: %.2f, %.1f\n", bearing, gps.rtime);
         fprintf(Comp, "%.2f\r\n", bearing);
         
-        //wait ();
-        
         i++;
         fclose(Accel);
         fclose(GPS);
         fclose(Comp);
     }
-    
 }  
\ No newline at end of file