Adafruit GPS , distance and count footsteps

Dependencies:   mbed SDFileSystem MBed_Adafruit-GPS-Library USBDevice

Revision:
7:3d99469695da
Parent:
6:f1b3ee4199b7
Child:
8:eee9069df8bb
--- a/main.cpp	Thu Jan 23 18:09:56 2020 +0000
+++ b/main.cpp	Thu Jan 23 22:26:02 2020 +0000
@@ -21,7 +21,7 @@
 //float distance2 = 0; 
 float sum_distance = 0; 
 float steps = 0;
-float avg_speed = 0;
+double avg_speed = 0;
 float cal = 0;
 
 int main() {
@@ -71,12 +71,12 @@
        //note if refresh_Time is too low or pc.baud is too low, GPS data may be lost during printing
        if (refresh_Timer.read_ms() >= refresh_Time) {
            refresh_Timer.reset();
-           fprintf(fp,"Time: %d:%d:%d.%u\n", myGPS.hour, myGPS.minute, myGPS.seconds, myGPS.milliseconds);
+           fprintf(fp,"Time: %d:%d:%d.%u\n", myGPS.hour+1, myGPS.minute, myGPS.seconds, myGPS.milliseconds);
            fprintf(fp,"Date: %d/%d/20%d\n", myGPS.day, myGPS.month, myGPS.year);
            fprintf(fp,"Fix: %d\n", (int) myGPS.fix);
            fprintf(fp,"Quality: %d\n\n", (int) myGPS.fixquality);
            
-           pc.printf("Time: %d:%d:%d.%u\n", myGPS.hour, myGPS.minute, myGPS.seconds, myGPS.milliseconds);
+           pc.printf("Time: %d:%d:%d.%u\n", myGPS.hour+1, myGPS.minute, myGPS.seconds, myGPS.milliseconds);
            pc.printf("Date: %d/%d/20%d\n", myGPS.day, myGPS.month, myGPS.year);
            pc.printf("Fix: %d\n", (int) myGPS.fix);
            pc.printf("Quality: %d\n\n", (int) myGPS.fixquality);
@@ -119,7 +119,7 @@
                 }
                 
                 ::distance =  myGPS.getDistance(lat_1, lon_1, lat_2, lon_2);
-                ::sum_distance = ::sum_distance + ::distance;                
+                ::sum_distance += ::distance;                
                 ::steps = myGPS.getSteps(::sum_distance, height);
                 
                 if (i != 0) {
@@ -127,30 +127,30 @@
                 }
                 
                                    
-                fprintf(fp,"t: %d\n", i);
-                fprintf(fp,"Location (°) : %5.5f%c, %5.5f%c\n", lat_dd, myGPS.lat, lon_dd, myGPS.lon);
-                fprintf(fp,"Location1 (°) : %5.5f, %5.5f\n", lat_1, lon_1);
-                fprintf(fp,"Location2 (°) : %5.5f, %5.5f\n", lat_2, lon_2);
+                //fprintf(fp,"t: %d\n", i);
+                fprintf(fp,"Satellites : %d\n", myGPS.satellites);
+                fprintf(fp,"Location (deg) : %5.5f%c, %5.5f%c\n", lat_dd, myGPS.lat, lon_dd, myGPS.lon);
+                //fprintf(fp,"Location1 (°) : %5.5f, %5.5f\n", lat_1, lon_1);
+                //fprintf(fp,"Location2 (°) : %5.5f, %5.5f\n", lat_2, lon_2);
                 //fprintf(fp,"Speed: %5.2f knots\n", myGPS.speed);
                 //fprintf(fp,"Angle: %5.2f\n", myGPS.angle);
                 fprintf(fp,"Altitude (m) : %5.2f\n", myGPS.altitude);
-                fprintf(fp,"Satellites : %d\n", myGPS.satellites);
                 fprintf(fp,"Distance (m) : %5.2f\n", ::sum_distance); 
-                fprintf(fp,"Steps taken : %5.2f\n", ::steps);
+                fprintf(fp,"Steps taken : %5.0f\n", ::steps);
                 fprintf(fp,"Average speed (km/h) : %5.2f\n\n\n", ::avg_speed);
                
-                pc.printf("t: %d\n", i);
-                pc.printf("Location (°) : %5.5f%c, %5.5f%c\n", lat_dd, myGPS.lat, lon_dd, myGPS.lon);
+                //pc.printf("t: %d\n", i);
+                pc.printf("Satellites : %d\n", myGPS.satellites);
+                pc.printf("Location (deg) : %5.5f%c, %5.5f%c\n", lat_dd, myGPS.lat, lon_dd, myGPS.lon);
                 //pc.printf("Location (°) : %5.5f%c, %5.5f%c\n", lat_dd, myGPS.lat, lon_dd, myGPS.lon);
-                pc.printf("Location1 (°) : %5.5f, %5.5f\n", lat_1, lon_1);
-                pc.printf("Location2 (°) : %5.5f, %5.5f\n", lat_2, lon_2);
+                //pc.printf("Location1 (°) : %5.5f, %5.5f\n", lat_1, lon_1);
+                //pc.printf("Location2 (°) : %5.5f, %5.5f\n", lat_2, lon_2);
                 //pc.printf("Speed: %5.2f knots\n", myGPS.speed);
                 //pc.printf("Angle: %5.2f\n", myGPS.angle);
                 pc.printf("Altitude (m) : %5.2f\n", myGPS.altitude);
-                pc.printf("Satellites : %d\n", myGPS.satellites);
                 pc.printf("Distance (m) : %5.2f\n", ::sum_distance);
-                pc.printf("Steps taken : %5.2f\n", ::steps);
-                pc.printf("Average speed (km/h) : %5.10f\n\n\n", ::avg_speed);
+                pc.printf("Steps taken : %5.0f\n", ::steps);
+                pc.printf("Average speed (km/h) : %5.5f\n\n\n", ::avg_speed);