mici: night mode (#39134)

This commit is contained in:
Adeeb Shihadeh
2026-11-13 18:56:27 -08:00
committed by GitHub
parent 011b357814
commit 7b7bc80d5d
2 changed files with 15 additions and 2 deletions
+7 -2
View File
@@ -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
+8
View File
@@ -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