Fix pps clock when not connected to gps

This commit is contained in:
2026-08-02 14:25:21 -06:00
parent ca817909a7
commit cedb2cfaa1
4 changed files with 126 additions and 79 deletions
+13 -17
View File
@@ -6,7 +6,8 @@ import adafruit_gps
import digitalio
from car_os.network_handler import NetworkHandler
import math
from car_os.pps import PPS
from car_os.pps_clock import PPSClock
from car_os.system_clock import SystemClock
from car_os.gps import GPS
from car_os.imu import IMU
from car_os.timer import Timer
@@ -27,40 +28,35 @@ def main():
network = NetworkHandler(SensorClass.VEHICLE, 256, 0.1, 5000, 0.001, 5001)
network.initialize()
network_timer = Timer(1)
network_reset_timer = Timer(600)
prind(board.__dict__)
pps = PPS(board.GP22)
pps_clock = PPSClock(board.GP22)
imu = IMU(board.GP21, board.GP20, 0x0C, (44, 66, -109), (-1, 3, -1), (-7, -16, -39))
gps = GPS(board.GP27, board.GP26, 0x42)
while True:
delta = pps.update()
delta = pps_clock.update()
if delta > 60:
continue
heartbeat_timer.update(delta)
network_timer.update(delta)
network_reset_timer.update(delta)
gps.update(pps.utc)
imu.update(pps.utc)
gps.update(pps_clock.utc_time)
imu.update(pps_clock.utc_time)
if network_timer.check_timer():
network.update(pps.utc, network_reset_timer)
network.update()
if not gps.has_fix:
print(time.time())
print("waiting for gps fix")
print()
pps_clock.update_gps_fixed(gps.has_fix)
continue
if gps.time_updated:
pps.update_from_gps(gps)
pps_clock.update_utc_from_gps(gps)
#if heartbeat_timer.check_timer():
# message = bytearray(b'\xd4\x53\x6e\x4e\x00\x00\x00')
# message[4] = pps.utc[0]
# message[5] = pps.utc[1]
# message[6] = pps.utc[2]
# message[4] = pps_clock.utc[0]
# message[5] = pps_clock.utc[1]
# message[6] = pps_clock.utc[2]
# message += b'\x00\x00'
# network.send(message)