Fix live data refresh loop

This commit is contained in:
2026-06-05 12:31:30 -06:00
parent f448abe326
commit 3f24ee0c93

45
menu.py
View File

@@ -55,29 +55,40 @@ def live_data(connection):
pause() pause()
return return
commands = [ print("Live data running.")
("RPM", obd.commands.RPM), print("Press Ctrl+C to stop and return to menu.\n")
("Speed", obd.commands.SPEED),
("Coolant Temp", obd.commands.COOLANT_TEMP),
]
for name, command in commands: try:
response = connection.query(command) while True:
rpm = connection.query(obd.commands.RPM)
speed = connection.query(obd.commands.SPEED)
coolant = connection.query(obd.commands.COOLANT_TEMP)
if response.is_null(): print("\nLive Data")
print(name + ": Not supported") print("---------")
else:
value = response.value
if name == "Speed": if rpm.is_null():
value = value.to("mile_per_hour") print("RPM: Not supported")
else:
print("RPM:", rpm.value)
elif name == "Coolant Temp": if speed.is_null():
value = value.to("degF") print("Speed: Not supported")
else:
speed_mph = speed.value.to("mile_per_hour")
print("Speed:", speed_mph)
print(name + ":", value) if coolant.is_null():
print("Coolant Temp: Not supported")
else:
coolant_f = coolant.value.to("degF")
print("Coolant Temp:", coolant_f)
pause() time.sleep(1)
except KeyboardInterrupt:
print("\nStopped live data")
pause()
def vehicle_info(connection): def vehicle_info(connection):