Add trip history and route replay

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
Mathieu Moran
2026-08-09 19:48:06 -04:00
co-authored by Copilot
parent 3a981f5c6d
commit d3bc313e7f
13 changed files with 1158 additions and 25 deletions
+9 -1
View File
@@ -14,6 +14,7 @@ SENSOR_POLL_INTERVAL = 5
status = None
speed = 0
speed_updated_at = None
rpm = None
coolant_temp = None
fuel_level = None
@@ -233,6 +234,12 @@ def get_speedtime():
return [time_now, speed]
def get_fresh_speed(max_age=5):
if speed_updated_at is None or time.monotonic() - speed_updated_at > max_age:
return None
return speed
def obd_connection():
"""Emit current state for a newly connected browser and ensure OBD is running."""
start_obd()
@@ -245,7 +252,7 @@ def obd_connection():
def obd_speed():
global speed
global speed, speed_updated_at
with obd_speed_lock:
while not stop_speed.is_set() and _is_car_connected():
response = _query(obd.commands.SPEED)
@@ -256,6 +263,7 @@ def obd_speed():
print(app_gps.get_gps())
else:
speed = round(response.value.to("kph").magnitude, 1)
speed_updated_at = time.monotonic()
print("Speed:", speed, "kph")
app_events.socketio.emit("obd_speed", get_speedtime())