Do not wiat for fix to use date/time from GPS => use GPS RTC everytime!
This commit is contained in:
parent
c64f463ef0
commit
bc875c32fe
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user