change from float to nmea_float_t

Not sure whether to make it float or double by default

/*************************************************************************
  doubles and floats are identical on AVR processors like the UNO where space
  is tight. doubles avoid the roundoff errors that led to the fixed point mods
  in https://github.com/adafruit/Adafruit-GPS-Library/pull/13, provided the
  processor supports actual doubles like the SAMD series with more storage. The
  total penalty for going all double is under a few hundred bytes / instance or
  0 bytes / instance on an UNO. This typedef allows a switch to lower precision
  to save some storage if needed. A float carries 23 bits of fractional
  resolution, giving a resolution of at least 9 significant digits, thus 6
  significant digits in the decimal place of an angular value like latitude, and
  thus a resolution on earth of at least 110 mm. That's closer than GPS will
  hit, and closer than needed for navigation, so floats can be used to save a
  little storage.
 **************************************************************************/
typedef double
    nmea_float_t; ///< the type of variables to use for floating point
This commit is contained in:
Rick Sellens 2020-01-19 08:14:02 -05:00
parent 8739f08ca6
commit 0051f37600
2 changed files with 22 additions and 22 deletions

View File

@ -320,28 +320,28 @@ boolean Adafruit_GPS::parseFix(char *p) {
/*!
@brief Time in seconds since the last position fix was obtained. Will
fail by rolling over to zero after one millis() cycle, about 6-1/2 weeks.
@return float value in seconds since last fix.
@return nmea_float_t value in seconds since last fix.
*/
/**************************************************************************/
float Adafruit_GPS::secondsSinceFix() { return (millis() - lastFix) / 1000.; }
nmea_float_t Adafruit_GPS::secondsSinceFix() { return (millis() - lastFix) / 1000.; }
/**************************************************************************/
/*!
@brief Time in seconds since the last GPS time was obtained. Will fail
by rolling over to zero after one millis() cycle, about 6-1/2 weeks.
@return float value in seconds since last GPS time.
@return nmea_float_t value in seconds since last GPS time.
*/
/**************************************************************************/
float Adafruit_GPS::secondsSinceTime() { return (millis() - lastTime) / 1000.; }
nmea_float_t Adafruit_GPS::secondsSinceTime() { return (millis() - lastTime) / 1000.; }
/**************************************************************************/
/*!
@brief Time in seconds since the last GPS date was obtained. Will fail
by rolling over to zero after one millis() cycle, about 6-1/2 weeks.
@return float value in seconds since last GPS date.
@return nmea_float_t value in seconds since last GPS date.
*/
/**************************************************************************/
float Adafruit_GPS::secondsSinceDate() { return (millis() - lastDate) / 1000.; }
nmea_float_t Adafruit_GPS::secondsSinceDate() { return (millis() - lastDate) / 1000.; }
/**************************************************************************/
/*!
@ -598,7 +598,7 @@ void Adafruit_GPS::common_init(void) {
fix = false; // boolean
milliseconds = 0; // uint16_t
latitude = longitude = geoidheight = altitude = speed = angle = magvariation =
HDOP = VDOP = PDOP = 0.0; // float
HDOP = VDOP = PDOP = 0.0; // nmea_float_t
}
/**************************************************************************/

View File

@ -101,9 +101,9 @@ public:
boolean check(char *nmea);
boolean parse(char *);
void addChecksum(char *buff);
float secondsSinceFix();
float secondsSinceTime();
float secondsSinceDate();
nmea_float_t secondsSinceFix();
nmea_float_t secondsSinceTime();
nmea_float_t secondsSinceDate();
void resetSentTime();
boolean wakeup(void);
@ -129,9 +129,9 @@ public:
uint8_t month; ///< GMT month
uint8_t day; ///< GMT day
float latitude; ///< Floating point latitude value in degrees/minutes as
nmea_float_t latitude; ///< Floating point latitude value in degrees/minutes as
///< received from the GPS (DDMM.MMMM)
float longitude; ///< Floating point longitude value in degrees/minutes as
nmea_float_t longitude; ///< Floating point longitude value in degrees/minutes as
///< received from the GPS (DDDMM.MMMM)
/** Fixed point latitude and longitude value with degrees stored in units of
@ -141,18 +141,18 @@ public:
int32_t latitude_fixed; ///< Fixed point latitude in decimal degrees
int32_t longitude_fixed; ///< Fixed point longitude in decimal degrees
float latitudeDegrees; ///< Latitude in decimal degrees
float longitudeDegrees; ///< Longitude in decimal degrees
float geoidheight; ///< Diff between geoid height and WGS84 height
float altitude; ///< Altitude in meters above MSL
float speed; ///< Current speed over ground in knots
float angle; ///< Course in degrees from true north
float magvariation; ///< Magnetic variation in degrees (vs. true north)
float HDOP; ///< Horizontal Dilution of Precision - relative accuracy of
nmea_float_t latitudeDegrees; ///< Latitude in decimal degrees
nmea_float_t longitudeDegrees; ///< Longitude in decimal degrees
nmea_float_t geoidheight; ///< Diff between geoid height and WGS84 height
nmea_float_t altitude; ///< Altitude in meters above MSL
nmea_float_t speed; ///< Current speed over ground in knots
nmea_float_t angle; ///< Course in degrees from true north
nmea_float_t magvariation; ///< Magnetic variation in degrees (vs. true north)
nmea_float_t HDOP; ///< Horizontal Dilution of Precision - relative accuracy of
///< horizontal position
float VDOP; ///< Vertical Dilution of Precision - relative accuracy of
nmea_float_t VDOP; ///< Vertical Dilution of Precision - relative accuracy of
///< vertical position
float PDOP; ///< Position Dilution of Precision - Complex maths derives a
nmea_float_t PDOP; ///< Position Dilution of Precision - Complex maths derives a
///< simple, single number for each kind of DOP
char lat = 'X'; ///< N/S
char lon = 'X'; ///< E/W