Skip to content

Commit

Permalink
Support for HDOP in its true decimal form: ddd.xx
Browse files Browse the repository at this point in the history
  • Loading branch information
mikalhart-intel committed Feb 4, 2018
1 parent f63678c commit b4c8e29
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
10 changes: 5 additions & 5 deletions examples/FullExample/FullExample.ino
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ void setup()
Serial.print(F("Testing TinyGPS++ library v. ")); Serial.println(TinyGPSPlus::libraryVersion());
Serial.println(F("by Mikal Hart"));
Serial.println();
Serial.println(F("Sats HDOP Latitude Longitude Fix Date Time Date Alt Course Speed Card Distance Course Card Chars Sentences Checksum"));
Serial.println(F(" (deg) (deg) Age Age (m) --- from GPS ---- ---- to London ---- RX RX Fail"));
Serial.println(F("---------------------------------------------------------------------------------------------------------------------------------------"));
Serial.println(F("Sats HDOP Latitude Longitude Fix Date Time Date Alt Course Speed Card Distance Course Card Chars Sentences Checksum"));
Serial.println(F(" (deg) (deg) Age Age (m) --- from GPS ---- ---- to London ---- RX RX Fail"));
Serial.println(F("----------------------------------------------------------------------------------------------------------------------------------------"));
}

void loop()
{
static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;

printInt(gps.satellites.value(), gps.satellites.isValid(), 5);
printInt(gps.hdop.value(), gps.hdop.isValid(), 5);
printFloat(gps.hdop.hdop(), gps.hdop.isValid(), 6, 1);
printFloat(gps.location.lat(), gps.location.isValid(), 11, 6);
printFloat(gps.location.lng(), gps.location.isValid(), 12, 6);
printInt(gps.location.age(), gps.location.isValid(), 5);
Expand Down Expand Up @@ -156,4 +156,4 @@ static void printStr(const char *str, int len)
for (int i=0; i<len; ++i)
Serial.print(i<slen ? str[i] : ' ');
smartDelay(0);
}
}
6 changes: 4 additions & 2 deletions examples/KitchenSink/KitchenSink.ino
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ void loop()
{
Serial.print(F("HDOP Fix Age="));
Serial.print(gps.hdop.age());
Serial.print(F("ms Value="));
Serial.println(gps.hdop.value());
Serial.print(F("ms raw="));
Serial.print(gps.hdop.value());
Serial.print(F(" hdop="));
Serial.println(gps.hdop.hdop());
}

else if (millis() - last > 5000)
Expand Down
2 changes: 1 addition & 1 deletion examples/UsingCustomFields/UsingCustomFields.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
This sample demonstrates TinyGPS++'s capacity for extracting custom
fields from any NMEA sentence. TinyGPS++ has built-in facilities for
extracting latitude, longitude, altitude, etc., from the $GPGLL and
extracting latitude, longitude, altitude, etc., from the $GPGGA and
$GPRMC sentences. But with the TinyGPSCustom type, you can extract
other NMEA fields, even from non-standard NMEA sentences.

Expand Down
9 changes: 7 additions & 2 deletions src/TinyGPS++.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#endif
#include <limits.h>

#define _GPS_VERSION "1.0.1" // software version of this library
#define _GPS_VERSION "1.0.2" // software version of this library
#define _GPS_MPH_PER_KNOT 1.15077945
#define _GPS_MPS_PER_KNOT 0.51444444
#define _GPS_KMPH_PER_KNOT 1.852
Expand Down Expand Up @@ -184,6 +184,11 @@ struct TinyGPSAltitude : TinyGPSDecimal
double feet() { return _GPS_FEET_PER_METER * value() / 100.0; }
};

struct TinyGPSHDOP : TinyGPSDecimal
{
double hdop() { return value() / 100.0; }
};

class TinyGPSPlus;
class TinyGPSCustom
{
Expand Down Expand Up @@ -225,7 +230,7 @@ class TinyGPSPlus
TinyGPSCourse course;
TinyGPSAltitude altitude;
TinyGPSInteger satellites;
TinyGPSDecimal hdop;
TinyGPSHDOP hdop;

static const char *libraryVersion() { return _GPS_VERSION; }

Expand Down

0 comments on commit b4c8e29

Please sign in to comment.