mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-08 13:33:42 +08:00
e4f3d6661c
Implement acceleration profiles, FollowJerk, force-stop and lead-departure owners. Keep selected acceleration limits and hazard arbitration explicit at their shared boundaries. Co-authored-by: whoisdomi <dcantu83@gmail.com>
27 lines
847 B
Python
27 lines
847 B
Python
"""Persistent, default-off lead takeoff preference; invalid bytes never activate it."""
|
|
from openpilot.starpilot.saved_source import read_saved
|
|
|
|
KEY = 'FasterLeadTakeoff'
|
|
|
|
|
|
class TakeoffPreferences:
|
|
def __init__(self, params):
|
|
self.params = params
|
|
self.enabled = False
|
|
self.next_ns = 0
|
|
self.last_ns = 0
|
|
|
|
def sample(self, now_ns):
|
|
if now_ns < self.last_ns:
|
|
self.next_ns = 0
|
|
self.last_ns = now_ns
|
|
if now_ns >= self.next_ns:
|
|
self.next_ns = now_ns + 1_000_000_000
|
|
try:
|
|
raw, readable = read_saved(self.params, KEY, 16)
|
|
safe, safe_readable = read_saved(self.params, 'SafeMode', 16)
|
|
self.enabled = readable and safe_readable and raw == b'1' and safe in (None, b'0')
|
|
except (OSError, RuntimeError, TypeError, ValueError):
|
|
self.enabled = False
|
|
return self.enabled
|