By calling atof() on p, we're converting the entire time string (101520.123 for 10:15:20am and 123 milliseconds) to a float, then multiplying by 1000 to get ms. This results in a value that overflows and exhibits all sorts of strange behavior as seconds and minutes turn over. It's clearly not what was intended. From the if statement wrapping the conversion, it is clear that the author intended to make the atof() conversion on the dec pointer, instead. Making this change actually does fix the parsing so that Adafruit_GPS' milliseconds property correctly matches the value in the NMEA sentence.
You guys do great work. Thanks for everything!
millis() returns an unsigned long integer, and C++ guarantees that
arithmetics on this type work modulo (ULONG_MAX+1). This behavior
ensures that computing a delay as
millis() - previousMillis
yields the correct result across millis() rollover events, as long as
the time actually elapsed is less than about 49.7 days.
move other parsing functions in NMEA_parse.cpp
fix parseTime to be insensitive to number of decimal places and return bool.
add isEmpty() checks where needed.
reorder some declarations.
We want to avoid using doubles where unnessesary since many embedded
targets have only a single precision FPU or no FPU at all.
Passing doubles is unavoidable with the printf family of functions,
so use an explicit cast to silence the warning.
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