diff --git a/openpilot/selfdrive/ui/mici/onroad/augmented_road_view.py b/openpilot/selfdrive/ui/mici/onroad/augmented_road_view.py index 499ad40544..b850425a04 100644 --- a/openpilot/selfdrive/ui/mici/onroad/augmented_road_view.py +++ b/openpilot/selfdrive/ui/mici/onroad/augmented_road_view.py @@ -304,6 +304,7 @@ class AugmentedRoadView(CameraView): def _update_state(self): super()._update_state() + def render_offroad(self, rect: rl.Rectangle) -> None: if ui_state.panda_type == log.PandaState.PandaType.unknown: title, detail = "StarPilot starting", "system booting" elif ui_state.ignition and not ui_state.started: @@ -312,6 +313,19 @@ class AugmentedRoadView(CameraView): title, detail = "start the car", "to use StarPilot" self._offroad_label.set_text(title) self._offroad_sublabel.set_text(detail) + rl.draw_rectangle_rec(rect, rl.BLACK) + text = rl.Rectangle(rect.x + 8, rect.y + 8, rect.width - 76, rect.height - 16) + height = self._offroad_label.get_content_height(int(text.width)) + self._offroad_label.render(rl.Rectangle(text.x, text.y, text.width, height)) + self._offroad_sublabel.render(rl.Rectangle(text.x, text.y + height + 8, text.width, text.height - height - 8)) + for asset, width, height, y in ( + ("onroad/driver_monitoring/dm_person.png", 42, 42, 48), + ("longitudinal/speed_dial.png", 48, 41, 120), + ("wheel.png", 43, 43, 192), + ): + texture = gui_app.texture(f"icons_mici/{asset}", width, height) + pos = rl.Vector2(rect.x + rect.width - 30 - width / 2, rect.y + y - height / 2) + rl.draw_texture_ex(texture, pos, 0.0, 1.0, rl.Color(255, 255, 255, 82)) def _handle_mouse_release(self, mouse_pos: MousePos): # Don't trigger click callback if bookmark was triggered @@ -322,13 +336,8 @@ class AugmentedRoadView(CameraView): if not paint: super()._render(rect, paint=False, poll_camera=poll_camera) return - # Draw text if not onroad if not ui_state.started: - rl.draw_rectangle_rec(self.rect, rl.BLACK) - text = rl.Rectangle(self._rect.x + 8, self._rect.y + 8, self._rect.width - 16, self._rect.height - 16) - height = self._offroad_label.get_content_height(int(text.width)) - self._offroad_label.render(rl.Rectangle(text.x, text.y, text.width, height)) - self._offroad_sublabel.render(rl.Rectangle(text.x, text.y + height + 8, text.width, text.height - height - 8)) + self.render_offroad(rect) return self._switch_stream_if_needed(ui_state.sm) diff --git a/openpilot/starpilot/ui/runtime_app.py b/openpilot/starpilot/ui/runtime_app.py index fe6e5138e2..e40495c0e4 100644 --- a/openpilot/starpilot/ui/runtime_app.py +++ b/openpilot/starpilot/ui/runtime_app.py @@ -1550,7 +1550,13 @@ class StarShellSession(TeslaSpeedActions): if pane and self.profile == Profile.LARGE: getattr(self.view, pane[0]).pressed_action = getattr(self.input, pane[2]).pressed_action drag_x = getattr(self.input, pane[2]).drag_x if pane else 0.0 - self.view.render(replace(snapshot, selected=Destination.NETWORK) if external else snapshot, drag_x=drag_x) + offroad_compact = (mode == ShellMode.ONROAD and self.profile == Profile.COMPACT and + not ui_state.started and getattr(ui_state, 'replay_clock', None) is None) + if offroad_compact: + if self.camera_paint: + self.camera_owner.render_offroad(rl.Rectangle(0, 0, rect.width, rect.height)) + else: + self.view.render(replace(snapshot, selected=Destination.NETWORK) if external else snapshot, drag_x=drag_x) self._pip_signals_cache = None if mode == ShellMode.ONROAD and self.profile == Profile.COMPACT: self.favorites.render(time.monotonic()) diff --git a/openpilot/starpilot/ui/tests/test_covered_camera.py b/openpilot/starpilot/ui/tests/test_covered_camera.py index 0aabb9087d..934ce49f58 100644 --- a/openpilot/starpilot/ui/tests/test_covered_camera.py +++ b/openpilot/starpilot/ui/tests/test_covered_camera.py @@ -306,3 +306,22 @@ def test_large_shell_forwards_the_saved_camera_and_temporary_reverse(monkeypatch def test_side_camera_shape_follows_device_profile(lifecycle, monkeypatch, request, profile, shape): make_session(monkeypatch, request, profile, Mock()) runtime_app.PiPRenderer.assert_called_once_with(shape) + + +def test_compact_offroad_panel_only_draws_dim_static_icons(monkeypatch): + from openpilot.cereal import log + + view = Mock(spec=native.AugmentedRoadView) + view._offroad_label = Mock(get_content_height=Mock(return_value=48)) + view._offroad_sublabel = Mock() + view._switch_stream_if_needed = Mock() + icons = Mock() + monkeypatch.setattr(native.rl, 'draw_texture_ex', icons) + monkeypatch.setattr(native.rl, 'draw_rectangle_rec', Mock()) + monkeypatch.setattr(native.gui_app, 'texture', Mock()) + monkeypatch.setattr(native, 'ui_state', NS(ignition=False, panda_type=log.PandaState.PandaType.unknown)) + native.AugmentedRoadView.render_offroad(view, native.rl.Rectangle(0, 0, 536, 240)) + assert [call.args[-1].a for call in icons.call_args_list] == [82, 82, 82] + view._offroad_label.set_text.assert_called_once_with('StarPilot starting') + view._offroad_sublabel.set_text.assert_called_once_with('system booting') + view._switch_stream_if_needed.assert_not_called()