mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-22 07:23:53 +08:00
46596218ba
(cherry picked from commit 0a212734c1)
21 lines
716 B
Python
21 lines
716 B
Python
"""Optional notification state; never supersedes driving alerts or starts inference."""
|
|
|
|
|
|
class GpuModelReadyChime:
|
|
def __init__(self):
|
|
self.ready = None
|
|
self.pending_until = None
|
|
|
|
def update(self, *, active, loading, onroad, enabled, now):
|
|
ready = bool(onroad and active and not loading)
|
|
# A soundd restart with an already-loaded model is not a loading event.
|
|
if self.ready is False and ready and enabled:
|
|
self.pending_until = now + 5.0
|
|
self.ready = ready
|
|
if not enabled or not ready or (self.pending_until is not None and now >= self.pending_until):
|
|
self.pending_until = None
|
|
return self.pending_until is not None
|
|
|
|
def consume(self):
|
|
self.pending_until = None
|