Library for the EM-406 GPS module with time export support added
Fork of GPS by
Diff: GPS.cpp
- Revision:
- 1:bc118a161471
- Parent:
- 0:15611c7938a3
- Child:
- 2:0d0ce3b0052d
--- a/GPS.cpp Tue Jun 08 14:10:27 2010 +0000 +++ b/GPS.cpp Wed Feb 21 21:05:14 2018 +0000 @@ -1,5 +1,6 @@ -/* mbed EM-406 GPS Module Library +/* mbed EM-406 GPS Module Library with time return support * Copyright (c) 2008-2010, sford + * Copyright (c) 2018 WilliamO7 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -25,7 +26,8 @@ GPS::GPS(PinName tx, PinName rx) : _gps(tx, rx) { _gps.baud(4800); longitude = 0.0; - latitude = 0.0; + latitude = 0.0; + time_utc = 0.0; } int GPS::sample() { @@ -40,7 +42,8 @@ if(sscanf(msg, "GPGGA,%f,%f,%c,%f,%c,%d", &time, &latitude, &ns, &longitude, &ew, &lock) >= 1) { if(!lock) { longitude = 0.0; - latitude = 0.0; + latitude = 0.0; + time_utc = 0.0; return 0; } else { if(ns == 'S') { latitude *= -1.0; } @@ -51,6 +54,7 @@ degrees = trunc(longitude / 100.0f * 0.01f); minutes = longitude - (degrees * 100.0f); longitude = degrees + minutes / 60.0f; + time_utc = time; return 1; } }