Compare commits

...

7 Commits

Author SHA1 Message Date
Jason Wen 58d57f7e1a max global brightness 2026-01-11 01:10:57 -05:00
Jason Wen 9cbc91d129 read 2026-01-11 00:57:47 -05:00
Jason Wen 764ff0db6a update immediately 2026-01-11 00:55:08 -05:00
Jason Wen 8faedaa062 lint 2026-01-11 00:32:22 -05:00
Jason Wen 4cc43ae6f5 override properly and clip to 30% minimum 2026-01-11 00:10:30 -05:00
Jason Wen 578e80855a do not touch light sensor logic 2026-01-10 23:49:17 -05:00
DevTekVE 66c335113e Reapply "ui: Global Brightness Override (#1579)"
This reverts commit a0c10be1ff.
2026-01-10 21:25:33 +01:00
2 changed files with 25 additions and 0 deletions
+21
View File
@@ -23,6 +23,7 @@ class UIStateSP:
self.sunnylink_state = SunnylinkState()
self.custom_interactive_timeout: int = self.params.get("InteractivityTimeout", return_default=True)
self.global_brightness_override: int = self.params.get("Brightness", return_default=True)
def update(self) -> None:
if self.sunnylink_enabled:
@@ -77,6 +78,7 @@ class UIStateSP:
self.chevron_metrics = self.params.get("ChevronInfo")
self.active_bundle = self.params.get("ModelManager_ActiveBundle")
self.custom_interactive_timeout = self.params.get("InteractivityTimeout", return_default=True)
self.global_brightness_override = self.params.get("Brightness", return_default=True)
class DeviceSP:
@@ -86,3 +88,22 @@ class DeviceSP:
def _set_awake(self, on: bool):
if on and self._params.get("DeviceBootMode", return_default=True) == 1:
self._params.put_bool("OffroadMode", True)
@staticmethod
def update_max_global_brightness(brightness_override: int) -> float:
"""
Updates the max global brightness by constraining the value to a predefined range.
The method takes an integer `brightness` value, adjusts it to ensure it is within the
range of 30 to 100, inclusive, and returns the adjusted value as a float.
This method only runs if 0 (Auto) is not selected.
:param brightness_override: The desired brightness level. It is constrained between
a minimum of 30 and a maximum of 100.
:type brightness_override: int
:return: The brightness value adjusted to fit within the allowable range,
converted to a float.
:rtype: float
"""
return float(min(max(brightness_override, 30), 100))
+4
View File
@@ -261,6 +261,10 @@ class Device(DeviceSP):
clipped_brightness = float(np.interp(clipped_brightness, [0, 1], [30, 100]))
brightness = round(self._brightness_filter.update(clipped_brightness))
if gui_app.sunnypilot_ui() and ui_state.global_brightness_override != 0:
brightness = DeviceSP.update_max_global_brightness(ui_state.global_brightness_override)
if not self._awake:
brightness = 0