diff --git a/spotiplayer_pi/main.py b/spotiplayer_pi/main.py index a00e7e5..6613926 100644 --- a/spotiplayer_pi/main.py +++ b/spotiplayer_pi/main.py @@ -19,6 +19,22 @@ from spotiplayer_pi.api import Api 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(): try: 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((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) if current_mode != 0: current_mode = 0