Slightly modified version of the SerialGPS library (https://os.mbed.com/teams/components/code/SerialGPS/) to support the BufferedSerial class
Diff: SerialGPS.h
- Revision:
- 4:2c76f1ec13a9
- Parent:
- 3:ebd79e3acf14
- Child:
- 5:cc8f9d7f9bdb
diff -r ebd79e3acf14 -r 2c76f1ec13a9 SerialGPS.h --- a/SerialGPS.h Tue Mar 02 18:27:46 2021 +0100 +++ b/SerialGPS.h Thu Apr 01 21:18:48 2021 +0200 @@ -25,6 +25,7 @@ #define MBED_GPS_H #include "mbed.h" +#include <cstring> #include "BufferedSerial.h" #define MAX_LINELENGTH 255 @@ -37,7 +38,7 @@ SerialGPS(BufferedSerial* serial); /** - * Sample the incoming GPS data + * Read the incoming GPS data */ void read(); @@ -55,22 +56,40 @@ */ bool fix(); + /** + * Helper function for converting from Decimal Minutes Seconds (DMS) to Decimal Degrees (DD) + * + * @param dms float containing the DMS value + * @return dd the converted value + */ + inline float convert(float dms) + { + float degmin, sec; + sec = modf(dms, °min); + + float deg = (int) degmin / 100; + float min = (int) degmin % 100; + + float dd = deg + (min / 60.0) + (sec / 60); + + return dd; + }; + /** - * The longitude (call sample() to set) + * The longitude (call read() to set) * * @return _lat the latitude component */ float get_lon(); /** - * The latitude (call sample() to set) + * The latitude (call read() to set) * * @return _lon the longitude component */ float get_lat(); private: - float trunc(float v); void getline(); void set_vals(); char read_char();