Library for the EM-406 GPS module with time export support added
Fork of GPS by
Diff: GPS.cpp
- Revision:
- 3:145bdf751843
- Parent:
- 2:0d0ce3b0052d
- Child:
- 4:147f30d69bf6
--- 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