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

50 lines
2.0 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Native compact child card for supported audible levels."""
from __future__ import annotations
from typing import Protocol
from openpilot.starpilot.ui.feature_settings_state import FeatureSettingsRequest, FeatureSettingsState, row_change
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 SoundsSession(Protocol):
def sounds_snapshot(self) -> FeatureSettingsState: ...
def sounds_request(self, request: FeatureSettingsRequest) -> bool: ...
class SoundsCompact:
def __init__(self, session: SoundsSession):
self.session = session
def entry_button(self) -> BigButton:
button = BigButton("sounds & alerts", "installed packs & alert levels")
button.set_click_callback(self.open)
return button
def open(self) -> None:
page = NavScroller()
self._populate(page)
gui_app.push_widget(page)
def _populate(self, page: NavScroller) -> None:
state = self.session.sounds_snapshot()
cards = [GreyBigButton("sounds & alerts", "installed packs and alert levels; auto follows ambient sound")]
for row in state.rows:
value = row.value + (row.unit if row.value != "Auto" else "")
if not row.available:
cards.append(GreyBigButton(row.label.lower(), f"{value}. {row.reason}".lower()))
continue
for direction in ((1,) if row.repair_value else (-1, 1)):
label = row.label.lower() + (f" set {row.repair_value.lower()}" if row.repair_value else " −" if direction < 0 else " +")
button = BigButton(label, value.lower())
def clicked(source=row, step=direction) -> None:
request = row_change(source, step)
if request is not None and self.session.sounds_request(request):
self._populate(page)
button.set_click_callback(clicked)
cards.append(button)
page._scroller.items.clear()
page._scroller.add_widgets(cards)