mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-10-28 00:53:45 +08:00
a82935f326
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>
33 lines
1021 B
Python
33 lines
1021 B
Python
"""Drive-scoped reverse camera choice from bounded display evidence."""
|
|
|
|
from dataclasses import dataclass
|
|
|
|
|
|
REVERSE_DWELL_NS = 500_000_000
|
|
|
|
|
|
@dataclass
|
|
class ReverseDriverCamera:
|
|
drive_key: tuple[int, int] | None = None
|
|
reverse_since_ns: int | None = None
|
|
last_ns: int | None = None
|
|
|
|
def step(self, *, now_ns: int, drive_key: tuple[int, int] | None, enabled: bool,
|
|
car_fresh: bool, reverse: bool) -> bool:
|
|
if drive_key is None or (self.last_ns is not None and now_ns < self.last_ns):
|
|
self.drive_key = None
|
|
self.reverse_since_ns = None
|
|
if drive_key is None:
|
|
self.last_ns = None
|
|
return False
|
|
self.last_ns = now_ns
|
|
if drive_key != self.drive_key:
|
|
self.drive_key = drive_key
|
|
self.reverse_since_ns = None
|
|
if not enabled or not car_fresh or not reverse:
|
|
self.reverse_since_ns = None
|
|
return False
|
|
if self.reverse_since_ns is None:
|
|
self.reverse_since_ns = now_ns
|
|
return now_ns - self.reverse_since_ns >= REVERSE_DWELL_NS
|