mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-12-02 07:33:45 +08:00
mici: night mode (#39134)
This commit is contained in:
@@ -18,6 +18,9 @@ from openpilot.selfdrive.modeld.helpers import chestnut_compiled
|
||||
from openpilot.selfdrive.selfdrived.alertmanager import OFFROAD_ALERTS
|
||||
|
||||
BACKLIGHT_OFFROAD = 65 if HARDWARE.get_device_type() == "mici" else 50
|
||||
BACKLIGHT_MIN = 30 # the lowest backlight the display shows properly
|
||||
# auto brightness goes below the backlight's floor by dimming the UI, down to 40% black
|
||||
BRIGHTNESS_MIN = BACKLIGHT_MIN * 0.6 if HARDWARE.get_device_type() == "mici" else BACKLIGHT_MIN
|
||||
PARAM_UPDATE_TIME = 1 / 5.0
|
||||
|
||||
|
||||
@@ -357,9 +360,11 @@ class Device:
|
||||
else:
|
||||
clipped_brightness = ((clipped_brightness + 16.0) / 116.0) ** 3.0
|
||||
|
||||
clipped_brightness = float(np.interp(clipped_brightness, [0, 1], [30, 100]))
|
||||
clipped_brightness = float(np.interp(clipped_brightness, [0, 1], [BRIGHTNESS_MIN, 100]))
|
||||
|
||||
brightness = round(self._brightness_filter.update(clipped_brightness))
|
||||
brightness = self._brightness_filter.update(clipped_brightness)
|
||||
gui_app.set_dim(1 - brightness / BACKLIGHT_MIN)
|
||||
brightness = round(max(brightness, BACKLIGHT_MIN))
|
||||
if not self._awake:
|
||||
brightness = 0
|
||||
|
||||
|
||||
@@ -233,6 +233,7 @@ class GuiApplication:
|
||||
self._mouse_history: deque[MousePosWithTime] = deque(maxlen=MOUSE_THREAD_RATE)
|
||||
self._show_touches = SHOW_TOUCHES
|
||||
self._show_fps = SHOW_FPS
|
||||
self._dim_color = rl.BLANK
|
||||
self._grid_size = GRID_SIZE
|
||||
self._profile_render_frames = PROFILE_RENDER
|
||||
self._render_profiler = None
|
||||
@@ -248,6 +249,10 @@ class GuiApplication:
|
||||
def set_show_fps(self, show: bool):
|
||||
self._show_fps = show
|
||||
|
||||
def set_dim(self, dim: float):
|
||||
"""darken the whole screen, from 0 to 1"""
|
||||
self._dim_color = rl.Color(0, 0, 0, round(255 * min(max(dim, 0.0), 1.0)))
|
||||
|
||||
@property
|
||||
def show_touches(self) -> bool:
|
||||
return self._show_touches
|
||||
@@ -614,6 +619,9 @@ class GuiApplication:
|
||||
if self._scale != 1.0:
|
||||
rl.rl_pop_matrix()
|
||||
|
||||
if self._dim_color.a > 0:
|
||||
rl.draw_rectangle(0, 0, self._scaled_width, self._scaled_height, self._dim_color)
|
||||
|
||||
if RECORD:
|
||||
self._ffmpeg_queue.put(rl.cpu.screen().tobytes()) # Async write via background thread
|
||||
|
||||
|
||||
Reference in New Issue
Block a user