From eb75090b3733c2410ef80f7478bf3896f5065858 Mon Sep 17 00:00:00 2001 From: = <=> Date: Tue, 24 Sep 2024 00:54:06 -0400 Subject: [PATCH] improved multi-gpu screen brightness measurement --- led_system_monitor.py | 4 ++-- monitors.py | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/led_system_monitor.py b/led_system_monitor.py index 7788d8e..a69fad2 100644 --- a/led_system_monitor.py +++ b/led_system_monitor.py @@ -15,9 +15,9 @@ if __name__ == "__main__": # Right LED Matrix location: "1-3.3" # Set up monitors and serial for left LED Matrix - min_background_brightness = 8 + min_background_brightness = 12 max_background_brightness = 35 - min_foreground_brightness = 30 + min_foreground_brightness = 24 max_foreground_brightness = 160 cpu_monitor = CPUMonitor() diff --git a/monitors.py b/monitors.py index bfaff81..d5f93fa 100644 --- a/monitors.py +++ b/monitors.py @@ -129,6 +129,12 @@ def get_monitor_brightness(): if os.name == 'nt': return wmi.WMI(namespace='wmi').WmiMonitorBrightness()[0].CurrentBrightness / 100.0 else: - return int(open('/sys/class/backlight/amdgpu_bl1/brightness', 'r').read()) / 255.0 + try: # First try the dGPU brightness + return int(open('/sys/class/backlight/amdgpu_bl2/brightness', 'r').read()) / 255.0 + except: # If that doesn't work, try the iGPU brightness + return int(open('/sys/class/backlight/amdgpu_bl1/brightness', 'r').read()) / 255.0 except Exception as e: return 1.0 + +if __name__ == "__main__": + print(get_monitor_brightness()) \ No newline at end of file