From bc875c32fe06e554d8a0065e4c6600308bbb3b49 Mon Sep 17 00:00:00 2001 From: Pierrick C Date: Sat, 25 Aug 2018 22:19:15 +0200 Subject: [PATCH] Do not wiat for fix to use date/time from GPS => use GPS RTC everytime! --- circuitpython/code/main.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/circuitpython/code/main.py b/circuitpython/code/main.py index 3075c2c..75f1e3a 100644 --- a/circuitpython/code/main.py +++ b/circuitpython/code/main.py @@ -112,6 +112,13 @@ class Data: if gps_enable_flag: self._gps_current_fix = int(time.monotonic()) + self.data['GPS']['time'] = TIME_FORMAT.format( + gps.timestamp_utc.tm_year, + gps.timestamp_utc.tm_mon, + gps.timestamp_utc.tm_mday, + gps.timestamp_utc.tm_hour, + gps.timestamp_utc.tm_min, + gps.timestamp_utc.tm_sec) if gps.has_fix: self._gps_last_fix = self._gps_current_fix self.data['GPS']['lat'] = gps.latitude @@ -283,7 +290,7 @@ def set_clock_from_gps(treshold=5.0): the RTC date time to GPS date-time if the difference is more or equal to threshold (in seconds)""" - if gps_enable_flag and gps.has_fix: + if gps_enable_flag: gps_datetime = time.struct_time((gps.timestamp_utc.tm_year, gps.timestamp_utc.tm_mon, gps.timestamp_utc.tm_mday, @@ -385,11 +392,11 @@ while True: if gps_enable_flag: gps.update() + set_clock_from_gps() current = time.monotonic() if current - last_update >= UPDATE_INTERVAL: last_update = current - set_clock_from_gps() data.update() if print_data_flag: data.show()