From 4ea034ce030f0e6b4ccd1549ac230744e8d26e7a Mon Sep 17 00:00:00 2001 From: Cameron Clough Date: Thu, 24 Apr 2025 15:45:10 +0100 Subject: [PATCH] add set_display_power to hardware.py --- system/hardware/base.py | 4 ++++ system/hardware/pc/hardware.py | 3 +++ system/hardware/tici/hardware.py | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/system/hardware/base.py b/system/hardware/base.py index c7c765f20a..f2c627d339 100644 --- a/system/hardware/base.py +++ b/system/hardware/base.py @@ -130,6 +130,10 @@ class HardwareBase(ABC): def get_thermal_config(self): return ThermalConfig() + @abstractmethod + def set_display_power(self, on: bool): + pass + @abstractmethod def set_screen_brightness(self, percentage): pass diff --git a/system/hardware/pc/hardware.py b/system/hardware/pc/hardware.py index 017a449c90..091f6a9b25 100644 --- a/system/hardware/pc/hardware.py +++ b/system/hardware/pc/hardware.py @@ -53,6 +53,9 @@ class Pc(HardwareBase): def shutdown(self): print("SHUTDOWN!") + def set_display_power(self, on): + pass + def set_screen_brightness(self, percentage): pass diff --git a/system/hardware/tici/hardware.py b/system/hardware/tici/hardware.py index 15480bab50..ffa852403f 100644 --- a/system/hardware/tici/hardware.py +++ b/system/hardware/tici/hardware.py @@ -341,6 +341,13 @@ class Tici(HardwareBase): exhaust=exhaust, case=case) + def set_display_power(self, on): + try: + with open("/sys/class/backlight/panel0-backlight/bl_power", "w") as f: + f.write("0" if on else "4") + except Exception: + pass + def set_screen_brightness(self, percentage): try: with open("/sys/class/backlight/panel0-backlight/max_brightness") as f: