add fan RPM

This commit is contained in:
barry 2026-02-23 12:34:44 +01:00
parent 28f725448d
commit cf8f8281fa

View File

@ -19,6 +19,22 @@ from spotiplayer_pi.api import Api
from spotiplayer_pi.cmap import cmap, cmap2 from spotiplayer_pi.cmap import cmap, cmap2
def get_fan_rpm():
try:
return int(
subprocess.run(
"cat /sys/devices/platform/cooling_fan/hwmon/*/fan1_input",
capture_output=True,
text=True,
check=True,
shell=True,
).stdout.strip()
)
except (subprocess.CalledProcessError, IndexError, ValueError) as e:
warnings.warn(f"Error getting fan RPM: {e}")
return None
def get_cpu_temp(): def get_cpu_temp():
try: try:
return float( return float(
@ -216,6 +232,11 @@ async def display_loop(api: Api, cfg: Dict):
draw.text((time_x, 30), time_text, font=Font3, fill=(255, 255, 255)) draw.text((time_x, 30), time_text, font=Font3, fill=(255, 255, 255))
draw.text((date_x, 78), date_text, font=Font2, fill=(255, 255, 255)) draw.text((date_x, 78), date_text, font=Font2, fill=(255, 255, 255))
# Draw fan speed
fan_rpms = get_fan_rpm()
fan_text = f"RPM: {fan_rpms}"
draw.text((1, 225), fan_text, font=Font0, fill=(255, 255, 255))
d.ShowImage(not_playing_img) d.ShowImage(not_playing_img)
if current_mode != 0: if current_mode != 0:
current_mode = 0 current_mode = 0