gps
Revision 2:90f2232bbdfd, committed 2020-01-23
- 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 |
diff -r 42f840c832b6 -r 90f2232bbdfd MBed_Adafruit_GPS.cpp --- 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; }
diff -r 42f840c832b6 -r 90f2232bbdfd MBed_Adafruit_GPS.h --- 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: