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:
14:d70e165ddf30
Parent:
13:0dd713c97cd1
Child:
15:b5b2ca683d64
--- a/main.cpp	Mon Mar 20 12:51:10 2017 +0000
+++ b/main.cpp	Tue Mar 21 15:39:17 2017 +0000
@@ -6,7 +6,7 @@
 #include "MSCFileSystem.h"
  
 #define FSNAME "USB"
-#define LIM 200
+#define LIM 300
  
 GPS gps(p9, p10); // GPS Connection
 CMPS03 compass(p28, p27, CMPS03_DEFAULT_I2C_ADDRESS); // Compass connection
@@ -35,7 +35,7 @@
     FILE *Comp = fopen("/USB/Compass.csv", "w"); // Opens text file for Compass   
     
     int i;
-    
+    float bearing;
     
     while(i < LIM)
     {
@@ -54,7 +54,7 @@
         {
             fprintf(GPS, "\n%f, %f\r\n", gps.latitude, gps.longitude);
             lcd.locate(1,1);
-            lcd.printf("%.4f, %.4f", gps.latitude, gps.longitude);
+            lcd.printf("GPS: %.4f, %.4f", gps.latitude, gps.longitude);
         }       
         else // For no signal
         {
@@ -67,27 +67,15 @@
         //Offset = compass.readBearing();  // Initial definitions
         Comp = fopen("/USB/Compass.csv", "a");
         lcd.locate(1,11);
-        lcd.printf("Bearing: %.2f\n", compass.readBearing()/10.0);
-        fprintf(Comp, "%.2f\r\n", compass.readBearing()/10.0);
-        /*
-            Comp = fopen("/USB/Compass.txt", "a");
-            fprintf(Comp, "%f\r\n", compass.readBearing());
-            lcd.locate(1,11);
-            // lcd.printf("Offset: %f, CMP: %f", Offset, compass.readBearing());
-            lcd.printf("Bearing:%f\n", compass.readBearing() / 10.0);
-          */                  
-              
-                           /* GenBearing = compass.readBearing()/10;  
-                            Comp = fopen("/USB/Compass.txt", "a");
-                            if (GenBearing < 0)
-                            {
-                                GenBearing = 0 - GenBearing;
-                            }
-                            fprintf(Comp, "%f\r\n", GenBearing);
-                            lcd.locate(1,11);
-                            lcd.printf("CMP: %.2f", Offset/10.0, GenBearing);
-                            */
-        wait (0.5);
+        bearing = (compass.readBearing()/10) - 150;
+        if (bearing < 0)
+        {
+            bearing = 360 + bearing;
+        }
+        lcd.printf("Bearing: %.2f\n", bearing);
+        fprintf(Comp, "%.2f\r\n", bearing);
+        
+        //wait ();
         
         i++;
         fclose(Accel);