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

45 lines
1.5 KiB
Python

"""Immutable, explicitly synthetic onroad visuals for private host replay."""
from dataclasses import dataclass
import math
FLAGS = frozenset(("cem", "csc"))
ORDER = ("cem", "csc")
CEM_REASONS = ("CURVE", "LEAD", "STOP LIGHT", "SPEED")
CSC_CURVATURE = (0.0, 0.008, 0.0115, 0.0200)
@dataclass(frozen=True)
class OnroadVisualPreview:
cem_reason: str | None = None
curve_curvature: float | None = None
label: str = "SYNTHETIC REPLAY PREVIEW"
# The Galaxy layout editor's sample: draw exactly as the car would, without the replay labels.
layout_sample: bool = False
def parse_flags(raw: str) -> frozenset[str]:
if raw == "":
return frozenset()
parts = raw.split(",")
if any(part not in FLAGS for part in parts) or len(parts) != len(set(parts)):
raise ValueError("Unknown or duplicate private onroad visual preview")
return frozenset(parts)
def encode_flags(flags: frozenset[str]) -> str:
if not flags <= FLAGS:
raise ValueError("Unknown private onroad visual preview")
return ",".join(flag for flag in ORDER if flag in flags)
def preview_at(flags: frozenset[str], elapsed_s: float) -> OnroadVisualPreview | None:
if not flags <= FLAGS or not math.isfinite(elapsed_s) or elapsed_s < 0:
raise ValueError("Invalid private onroad visual preview")
if not flags:
return None
phase = int(elapsed_s // 2) % 4
return OnroadVisualPreview(CEM_REASONS[phase] if "cem" in flags else None,
CSC_CURVATURE[phase] if "csc" in flags else None)