gps

Dependents:   adafruit-gps BMC

Files at this revision

API Documentation at this revision

Comitter:
the_nabil
Date:
Thu Jan 23 22:25:47 2020 +0000
Parent:
1:42f840c832b6
Commit message:
GPS

Changed in this revision

MBed_Adafruit_GPS.cpp Show annotated file Show diff for this revision Revisions of this file
MBed_Adafruit_GPS.h Show annotated file Show diff for this revision Revisions of this file
--- a/MBed_Adafruit_GPS.cpp	Thu Jan 23 18:08:12 2020 +0000
+++ b/MBed_Adafruit_GPS.cpp	Thu Jan 23 22:25:47 2020 +0000
@@ -398,12 +398,14 @@
     return steps;
 }
 
-float Adafruit_GPS::getAvgSpeed(float distance, int t) {
+double Adafruit_GPS::getAvgSpeed(float distance, int t) {
     float avg_speed;
     
     t = (float) t;
     
-    avg_speed = (distance/1000)/(t/3600);
+    avg_speed = (double)(distance/t);
+    avg_speed = (avg_speed/1000)*3600;
+    //avg_speed = (double)(distance/1000)/(t/3600);
     
     return avg_speed;
 }
--- a/MBed_Adafruit_GPS.h	Thu Jan 23 18:08:12 2020 +0000
+++ b/MBed_Adafruit_GPS.h	Thu Jan 23 22:25:47 2020 +0000
@@ -110,7 +110,7 @@
   float coordToDegDec(float coord);
   float getDistance(float lat_1, float lon_1, float lat_2, float lon_2);
   float getSteps(float distance, float height);
-  float getAvgSpeed(float distance, int t);
+  double getAvgSpeed(float distance, int t);
   //float getCal(float 
  // float toRadians(float deg);
  private: