Changes Lat & Long Binary variable to be 32 bit integers representing micro-degrees.
Fork of lib_gps by
Diff: gps.cpp
- Revision:
- 5:f06be7a1f427
- Parent:
- 4:b8c049fa7db2
- Child:
- 6:1a45aa41ec15
--- a/gps.cpp Wed Oct 21 01:08:46 2015 +0000 +++ b/gps.cpp Mon Aug 15 22:52:52 2016 +0000 @@ -9,12 +9,6 @@ //const char NmeaDataTypeGPGSV[] = "GPGSV"; const char NmeaDataTypeGPRMC[] = "GPRMC"; -/* Value used for the conversion of the position from DMS to decimal */ -const int32_t MaxNorthPosition = 8388607; // 2^23 - 1 -const int32_t MaxSouthPosition = 8388608; // -2^23 -const int32_t MaxEastPosition = 8388607; // 2^23 - 1 -const int32_t MaxWestPosition = 8388608; // -2^23 - //InterruptIn pps_pin(PC_5); @@ -238,32 +232,12 @@ void GPS::ConvertPositionIntoBinary( ) { - long double temp; - - if( Latitude >= 0 ) // North - { - temp = Latitude * MaxNorthPosition; - LatitudeBinary = temp / 90; - } - else // South - { - temp = Latitude * MaxSouthPosition; - LatitudeBinary = temp / 90; - } + LatitudeBinary32 = (int)(Latitude * 1e6); - if( Longitude >= 0 ) // East - { - temp = Longitude * MaxEastPosition; - LongitudeBinary = temp / 180; - } - else // West - { - temp = Longitude * MaxWestPosition; - LongitudeBinary = temp / 180; - } + LongitudeBinary32 = (int)(Longitude * 1e6); - //printf("binary: %x %x\r\n", LatitudeBinary, LongitudeBinary); - if (LatitudeBinary == LAT_UNFIXED && LongitudeBinary == LONG_UNFIXED) + //printf("binary: %d %d\r\n", LatitudeBinary32, LongitudeBinary32); + if (LatitudeBinary32 == LAT_UNFIXED && LongitudeBinary32 == LONG_UNFIXED) // TODO JOE find correct values have_fix = false; else have_fix = true;