Library for the EM-406 GPS module with time export support added
Fork of GPS by
Revision 3:145bdf751843, committed 2018-03-04
- Comitter:
- WilliamO7
- Date:
- Sun Mar 04 22:37:29 2018 +0000
- Parent:
- 2:0d0ce3b0052d
- Child:
- 4:147f30d69bf6
- Commit message:
- remove straight time conversion
Changed in this revision
GPS.cpp | Show annotated file Show diff for this revision Revisions of this file |
GPS.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/GPS.cpp Sun Mar 04 18:47:05 2018 +0000 +++ b/GPS.cpp Sun Mar 04 22:37:29 2018 +0000 @@ -20,16 +20,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include <string> -#include <sstream> - #include "GPS.h" GPS::GPS(PinName tx, PinName rx) : _gps(tx, rx) { _gps.baud(4800); longitude = 0.0; latitude = 0.0; - time_utc = ""; + time_utc = 0.0; } int GPS::sample() { @@ -56,7 +53,7 @@ degrees = trunc(longitude / 100.0f * 0.01f); minutes = longitude - (degrees * 100.0f); longitude = degrees + minutes / 60.0f; - time_utc = timef_to_str(time); + time_utc = time; return 1; } } @@ -84,18 +81,4 @@ } } error("Overflowed message limit"); -} - -std::string GPS::timef_to_str(float time) { - // Convert time to string - // 234960.123 - std::stringstream stream; - stream << time; - std::string time_str = stream.str(); - - // Put into hh:mm:ss.sss format. - std::string new_time_str = time_str.substr(0, 2) // hh - + ":" + time_str.substr(2, 2) // mm - + ":" + time_str.substr(4, 2); // ss - return new_time_str; } \ No newline at end of file
--- a/GPS.h Sun Mar 04 18:47:05 2018 +0000 +++ b/GPS.h Sun Mar 04 22:37:29 2018 +0000 @@ -22,7 +22,6 @@ */ #include "mbed.h" -#include <string> #ifndef MBED_GPS_H #define MBED_GPS_H @@ -48,12 +47,11 @@ float latitude; /** The time in UTC float format (call sample() to set) */ - std::string time_utc; + float time_utc; private: float trunc(float v); void getline(); - std::string timef_to_str(float time); Serial _gps; char msg[256];