diff --git a/design/main_controller.c4d b/design/main_controller.c4d index 1ef39ee..e905408 100644 Binary files a/design/main_controller.c4d and b/design/main_controller.c4d differ diff --git a/design/main_controller.stl b/design/main_controller.stl index c267003..6d25f58 100644 Binary files a/design/main_controller.stl and b/design/main_controller.stl differ diff --git a/leads_gpio/__init__.py b/leads_gpio/__init__.py index 5d1c760..c977b6a 100644 --- a/leads_gpio/__init__.py +++ b/leads_gpio/__init__.py @@ -7,6 +7,7 @@ if not _find_spec("serial"): raise ImportError("Please install `pyserial` to run this module\n>>>pip install pyserial") +from leads_gpio.cpu_monitor import * from leads_gpio.gps_receiver import * from leads_gpio.led import * from leads_gpio.led_group import * diff --git a/leads_gpio/cpu_monitor.py b/leads_gpio/cpu_monitor.py new file mode 100644 index 0000000..255846a --- /dev/null +++ b/leads_gpio/cpu_monitor.py @@ -0,0 +1,15 @@ +from typing import override as _override + +from gpiozero import CPUTemperature as _CPUTemperature + +from leads import Device as _Device + + +class CPUMonitor(_Device): + def __init__(self) -> None: + super().__init__() + self._cpu_temp: _CPUTemperature = _CPUTemperature() + + @_override + def read(self) -> dict[str, float]: + return {"temp": self._cpu_temp.temperature} diff --git a/leads_vec/cli.py b/leads_vec/cli.py index b4b1389..b3eb291 100644 --- a/leads_vec/cli.py +++ b/leads_vec/cli.py @@ -262,9 +262,10 @@ def switch_esc_mode(mode: str) -> None: class IdleUpdate(FrequencyGenerator): @_override def do(self) -> None: + cpu_temp = get_device("cpu").read()["temp"] if has_device("cpu") else "?" var_info.set(f"VeC {__version__.upper()}\n\n" f"{_datetime.now().strftime("%Y-%m-%d %H:%M:%S")}\n" - f"{format_duration(duration := _time() - w.runtime_data().start_time)}\n" + f"{format_duration(duration := _time() - w.runtime_data().start_time)} {cpu_temp} °C\n" f"{(m := ctx.data().mileage):.1f} KM - {m * 3600 / duration:.1f} KM / H\n\n" f"{cfg.refresh_rate} - {w.frame_rate():.2f} FPS - {w.net_delay() * 1000:.1f} MS\n" f"{(["NOT FOUND"] + my_ip_addresses())[-1]}:{w.runtime_data().comm.port()}") diff --git a/leads_vec/devices.py b/leads_vec/devices.py index 68198d8..c55129a 100644 --- a/leads_vec/devices.py +++ b/leads_vec/devices.py @@ -7,7 +7,7 @@ SFT, read_device_marker, has_controller, POWER_CONTROLLER, WHEEL_SPEED_CONTROLLER, ACCELEROMETER from leads_arduino import ArduinoMicro, WheelSpeedSensor, VoltageSensor, Accelerometer, Acceleration from leads_comm_serial import SOBD -from leads_gpio import NMEAGPSReceiver, LEDGroup, LED, LEDGroupCommand, LEDCommand, Entire, Transition +from leads_gpio import NMEAGPSReceiver, LEDGroup, LED, LEDGroupCommand, LEDCommand, Entire, Transition, CPUMonitor from leads_vec.config import Config from leads_video import Base64Camera, get_camera @@ -174,6 +174,11 @@ def initialize(self, *parent_tags: str) -> None: super().initialize(*parent_tags) +@device("cpu", MAIN_CONTROLLER) +class CPU(CPUMonitor): + pass + + class Indicator(LEDGroup): @override def initialize(self, *parent_tags: str) -> None: