mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-09-23 08:03:50 +08:00
ui: Global Brightness Override (#1579)
* global brightness * initialize * keep stock * lint --------- Co-authored-by: Jason Wen <haibin.wen3@gmail.com>
This commit is contained in:
@@ -22,6 +22,8 @@ class UIStateSP:
|
|||||||
|
|
||||||
self.sunnylink_state = SunnylinkState()
|
self.sunnylink_state = SunnylinkState()
|
||||||
|
|
||||||
|
self.global_brightness_override: int = self.params.get("Brightness", return_default=True)
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
if self.sunnylink_enabled:
|
if self.sunnylink_enabled:
|
||||||
self.sunnylink_state.start()
|
self.sunnylink_state.start()
|
||||||
@@ -74,6 +76,7 @@ class UIStateSP:
|
|||||||
self.rainbow_path = self.params.get_bool("RainbowMode")
|
self.rainbow_path = self.params.get_bool("RainbowMode")
|
||||||
self.chevron_metrics = self.params.get("ChevronInfo")
|
self.chevron_metrics = self.params.get("ChevronInfo")
|
||||||
self.active_bundle = self.params.get("ModelManager_ActiveBundle")
|
self.active_bundle = self.params.get("ModelManager_ActiveBundle")
|
||||||
|
self.global_brightness_override = self.params.get("Brightness", return_default=True)
|
||||||
|
|
||||||
|
|
||||||
class DeviceSP:
|
class DeviceSP:
|
||||||
|
|||||||
@@ -255,9 +255,18 @@ class Device(DeviceSP):
|
|||||||
else:
|
else:
|
||||||
clipped_brightness = ((clipped_brightness + 16.0) / 116.0) ** 3.0
|
clipped_brightness = ((clipped_brightness + 16.0) / 116.0) ** 3.0
|
||||||
|
|
||||||
clipped_brightness = float(np.interp(clipped_brightness, [0, 1], [30, 100]))
|
if gui_app.sunnypilot_ui():
|
||||||
|
if ui_state.global_brightness_override <= 0:
|
||||||
|
min_global_brightness = 1 if ui_state.global_brightness_override < 0 else 30
|
||||||
|
clipped_brightness = float(np.interp(clipped_brightness, [0, 1], [min_global_brightness, 100]))
|
||||||
|
else:
|
||||||
|
clipped_brightness = float(np.interp(clipped_brightness, [0, 1], [30, 100]))
|
||||||
|
|
||||||
brightness = round(self._brightness_filter.update(clipped_brightness))
|
brightness = round(self._brightness_filter.update(clipped_brightness))
|
||||||
|
|
||||||
|
if gui_app.sunnypilot_ui() and ui_state.global_brightness_override > 0:
|
||||||
|
brightness = ui_state.global_brightness_override
|
||||||
|
|
||||||
if not self._awake:
|
if not self._awake:
|
||||||
brightness = 0
|
brightness = 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user