diff --git a/cereal b/cereal index d054cbc704..a0850ebef6 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit d054cbc70423036a09a9449f7b7b19c058921578 +Subproject commit a0850ebef69c5a3c43c875fb730528b049bad2e1 diff --git a/selfdrive/hardware/base.py b/selfdrive/hardware/base.py index f3b27be31a..a1b67cb38b 100644 --- a/selfdrive/hardware/base.py +++ b/selfdrive/hardware/base.py @@ -110,6 +110,10 @@ class HardwareBase: def set_screen_brightness(self, percentage): pass + @abstractmethod + def get_screen_brightness(self): + pass + @abstractmethod def set_power_save(self, powersave_enabled): pass diff --git a/selfdrive/hardware/eon/hardware.py b/selfdrive/hardware/eon/hardware.py index 14475eddbe..2296c26e6d 100644 --- a/selfdrive/hardware/eon/hardware.py +++ b/selfdrive/hardware/eon/hardware.py @@ -375,6 +375,13 @@ class Android(HardwareBase): with open("/sys/class/leds/lcd-backlight/brightness", "w") as f: f.write(str(int(percentage * 2.55))) + def get_screen_brightness(self): + try: + with open("/sys/class/leds/lcd-backlight/brightness") as f: + return int(float(f.read()) / 2.55) + except Exception: + return 0 + def set_power_save(self, powersave_enabled): pass diff --git a/selfdrive/hardware/pc/hardware.py b/selfdrive/hardware/pc/hardware.py index b1c340376b..b2be6ca91c 100644 --- a/selfdrive/hardware/pc/hardware.py +++ b/selfdrive/hardware/pc/hardware.py @@ -83,6 +83,9 @@ class Pc(HardwareBase): def set_screen_brightness(self, percentage): pass + def get_screen_brightness(self): + return 0 + def set_power_save(self, powersave_enabled): pass diff --git a/selfdrive/hardware/tici/hardware.py b/selfdrive/hardware/tici/hardware.py index 864d653d01..4ac69a443d 100644 --- a/selfdrive/hardware/tici/hardware.py +++ b/selfdrive/hardware/tici/hardware.py @@ -283,6 +283,13 @@ class Tici(HardwareBase): except Exception: pass + def get_screen_brightness(self): + try: + with open("/sys/class/backlight/panel0-backlight/brightness") as f: + return int(float(f.read()) / 10.23) + except Exception: + return 0 + def set_power_save(self, powersave_enabled): # amplifier, 100mW at idle self.amplifier.set_global_shutdown(amp_disabled=powersave_enabled) diff --git a/selfdrive/thermald/thermald.py b/selfdrive/thermald/thermald.py index 43e85149b0..b7e8bab9ad 100755 --- a/selfdrive/thermald/thermald.py +++ b/selfdrive/thermald/thermald.py @@ -290,6 +290,7 @@ def thermald_thread(): if modem_temps is not None: msg.deviceState.modemTempC = modem_temps + msg.deviceState.screenBrightnessPercent = HARDWARE.get_screen_brightness() msg.deviceState.batteryPercent = HARDWARE.get_battery_capacity() msg.deviceState.batteryCurrent = HARDWARE.get_battery_current() msg.deviceState.usbOnline = HARDWARE.get_usb_present()