adafruit / Adafruit_CircuitPython_GPS

GPS parsing module for CircuitPython. Meant to parse NMEA data from serial GPS modules.
MIT License
75 stars 58 forks source link

Usage of float causes timestamp_utc to be imprecise #75

Closed mrdalgaard closed 2 years ago

mrdalgaard commented 2 years ago

NMEA timestamp is written as HHMMSS.sss, which is stored as float in the module.

Later it is converted to int which is inaccurate: See example:

>> int(184105.000)
184104

This is then math'ed into the fields in time_struct.

Propose storing the NMEA sentence as string instead, and grabbing the sections of the sting directly.

tannewt commented 2 years ago

Note that it isn't the int conversion that is the problem. Storing it as a float is the issue. Try printing the float version back. My guess is that you'll get:

>> 184105.000
184104.0
mrdalgaard commented 2 years ago

Note that it isn't the int conversion that is the problem. Storing it as a float is the issue. Try printing the float version back. My guess is that you'll get:

>> 184105.000
184104.0

I actually don't:

>>> 184105.000
184105.0
>>> int(184105.000)
184104
>>> int(184105.0)
184105
tannewt commented 2 years ago

:exploding_head: