sunnypilot v2026.002.000
version: sunnypilot v2026.002.000 (staging) date: 2026-07-21T07:44:02 master commit: 2c334ede443d7391d27575af8c854a095ba702a8
This commit is contained in:
commit
de77c89cf6
3995 files changed
+1260688
No files matched your search
@@ -0,0 +1,94 @@
|
||||
"""
|
||||
Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
|
||||
|
||||
This file is part of sunnypilot and is licensed under the MIT License.
|
||||
See the LICENSE.md file in the root directory for more details.
|
||||
"""
|
||||
from enum import IntEnum
|
||||
|
||||
from openpilot.system.ui.widgets import Widget
|
||||
from openpilot.system.ui.lib.multilang import tr
|
||||
from openpilot.system.ui.widgets.scroller_tici import Scroller
|
||||
from openpilot.system.ui.sunnypilot.widgets.list_view import option_item_sp
|
||||
from openpilot.sunnypilot.system.params_migration import ONROAD_BRIGHTNESS_TIMER_VALUES
|
||||
|
||||
|
||||
class OnroadBrightness(IntEnum):
|
||||
AUTO = 0
|
||||
AUTO_DARK = 1
|
||||
SCREEN_OFF = 2
|
||||
|
||||
|
||||
class DisplayLayout(Widget):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
items = self._initialize_items()
|
||||
self._scroller = Scroller(items, line_separator=True, spacing=0)
|
||||
|
||||
def _initialize_items(self):
|
||||
self._onroad_brightness = option_item_sp(
|
||||
param="OnroadScreenOffBrightness",
|
||||
title=lambda: tr("Onroad Brightness"),
|
||||
description="",
|
||||
min_value=0,
|
||||
max_value=22,
|
||||
value_change_step=1,
|
||||
label_callback=lambda value: self.update_onroad_brightness(value),
|
||||
inline=True
|
||||
)
|
||||
self._onroad_brightness_timer = option_item_sp(
|
||||
param="OnroadScreenOffTimer",
|
||||
title=lambda: tr("Onroad Brightness Delay"),
|
||||
description="",
|
||||
min_value=0,
|
||||
max_value=15,
|
||||
value_change_step=1,
|
||||
value_map=ONROAD_BRIGHTNESS_TIMER_VALUES,
|
||||
label_callback=lambda value: f"{value} s" if value < 60 else f"{int(value/60)} m",
|
||||
inline=True
|
||||
)
|
||||
self._interactivity_timeout = option_item_sp(
|
||||
param="InteractivityTimeout",
|
||||
title=lambda: tr("Interactivity Timeout"),
|
||||
description=lambda: tr("Apply a custom timeout for settings UI." +
|
||||
"<br>This is the time after which settings UI closes automatically " +
|
||||
"if user is not interacting with the screen."),
|
||||
min_value=0,
|
||||
max_value=120,
|
||||
value_change_step=10,
|
||||
label_callback=lambda value: (tr("Default") if not value or value == 0 else
|
||||
f"{value} s" if value < 60 else f"{int(value/60)} m"),
|
||||
inline=True
|
||||
)
|
||||
items = [
|
||||
self._onroad_brightness,
|
||||
self._onroad_brightness_timer,
|
||||
self._interactivity_timeout,
|
||||
]
|
||||
return items
|
||||
|
||||
@staticmethod
|
||||
def update_onroad_brightness(val):
|
||||
if val == OnroadBrightness.AUTO:
|
||||
return tr("Auto (Default)")
|
||||
|
||||
if val == OnroadBrightness.AUTO_DARK:
|
||||
return tr("Auto (Dark)")
|
||||
|
||||
if val == OnroadBrightness.SCREEN_OFF:
|
||||
return tr("Screen Off")
|
||||
|
||||
return f"{(val - 2) * 5} %"
|
||||
|
||||
def _update_state(self):
|
||||
super()._update_state()
|
||||
|
||||
brightness_val = self._onroad_brightness.action_item.current_value
|
||||
self._onroad_brightness_timer.action_item.set_enabled(brightness_val not in (OnroadBrightness.AUTO, OnroadBrightness.AUTO_DARK))
|
||||
|
||||
def _render(self, rect):
|
||||
self._scroller.render(rect)
|
||||
|
||||
def show_event(self):
|
||||
self._scroller.show_event()
|
||||
Reference in new issue
Block a user