Files
firestar5683 a82935f326 User interfaces and Android Auto
Integrate onroad views, configurable widgets, local settings, steering-profile contracts, Bluetooth and Android Auto with their device and runtime services.

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Co-authored-by: Daniel Koepping <elkoled@gmail.com>
Co-authored-by: Danny <dannyirwin31@yahoo.com>
Co-authored-by: DimitriChrysafis <Dimitri.chrysafis@gmail.com>
Co-authored-by: Dom <168790843+firestar5683@users.noreply.github.com>
Co-authored-by: Harald Schäfer <harald.the.engineer@gmail.com>
Co-authored-by: Prabhaav Pillai <prabhaav@msu.edu>
Co-authored-by: Shane Smiskol <shane@smiskol.com>
Co-authored-by: dirwin31 <83434411+dirwin31@users.noreply.github.com>
Co-authored-by: firestarsdog <229254897+firestarsdog@users.noreply.github.com>
Co-authored-by: stef <19478336+stefpi@users.noreply.github.com>
Co-authored-by: whoisdomi <dcantu83@gmail.com>

Co-authored-by: Intelli <contact@intelli.software>
Co-authored-by: pharmacomaniac <blittle65@gmail.com>

Co-authored-by: prabhaavp <prabhaav@msu.edu>
2026-10-14 20:02:39 -05:00

65 lines
2.0 KiB
Python

"""Read-only offline-map status in the compact Software section."""
from collections.abc import Callable
import time
from typing import Protocol
from openpilot.starpilot.ui.feature_settings_state import FeatureSettingsState
from openpilot.system.ui.lib.application import gui_app
from openpilot.system.ui.widgets.scroller import NavScroller
from openpilot.selfdrive.ui.mici.widgets.button import BigButton, GreyBigButton
class MapSession(Protocol):
def map_snapshot(self) -> FeatureSettingsState: ...
class _MapsPage(NavScroller):
def __init__(self, owner: "MapsCompact"):
super().__init__()
self.owner = owner
self.current: FeatureSettingsState | None = None
self.next_refresh = 0.0
def render(self, rect=None):
self.owner.refresh_visible(self)
return super().render(rect)
class MapsCompact:
REFRESH_SECONDS = 0.5
def __init__(self, session: MapSession, clock: Callable[[], float] = time.monotonic):
self.session = session
self.clock = clock
def entry_button(self) -> BigButton:
button = BigButton("offline maps", "status and selected region")
button.set_click_callback(self.open)
return button
def open(self) -> None:
page = _MapsPage(self)
self._populate(page, self.session.map_snapshot())
page.next_refresh = self.clock() + self.REFRESH_SECONDS
gui_app.push_widget(page)
def refresh_visible(self, page: _MapsPage) -> None:
if gui_app.get_active_widget() is not page:
return
now = self.clock()
if now < page.next_refresh:
return
page.next_refresh = now + self.REFRESH_SECONDS
state = self.session.map_snapshot()
if state != page.current:
self._populate(page, state)
@staticmethod
def _populate(page: _MapsPage, state: FeatureSettingsState) -> None:
page.current = state
cards = [GreyBigButton(state.title.lower(), state.subtitle.lower())]
cards.extend(GreyBigButton(row.label.lower(), f"{row.value}. {row.reason}".lower()) for row in state.rows)
page._scroller.items.clear()
page._scroller.add_widgets(cards)