|
|
|
@ -14,7 +14,7 @@ from openpilot.common.swaglog import cloudlog |
|
|
|
|
from openpilot.system.hardware import HARDWARE, PC, TICI |
|
|
|
|
from openpilot.common.realtime import Ratekeeper |
|
|
|
|
|
|
|
|
|
DEFAULT_FPS = int(os.getenv("FPS", 20 if TICI else 60)) |
|
|
|
|
_DEFAULT_FPS = int(os.getenv("FPS", 20 if TICI else 60)) |
|
|
|
|
FPS_LOG_INTERVAL = 5 # Seconds between logging FPS drops |
|
|
|
|
FPS_DROP_THRESHOLD = 0.9 # FPS drop threshold for triggering a warning |
|
|
|
|
FPS_CRITICAL_THRESHOLD = 0.5 # Critical threshold for triggering strict actions |
|
|
|
@ -130,7 +130,7 @@ class GuiApplication: |
|
|
|
|
self._scaled_height = int(self._height * self._scale) |
|
|
|
|
self._render_texture: rl.RenderTexture | None = None |
|
|
|
|
self._textures: dict[str, rl.Texture] = {} |
|
|
|
|
self._target_fps: int = DEFAULT_FPS |
|
|
|
|
self._target_fps: int = _DEFAULT_FPS |
|
|
|
|
self._last_fps_log_time: float = time.monotonic() |
|
|
|
|
self._window_close_requested = False |
|
|
|
|
self._trace_log_callback = None |
|
|
|
@ -142,10 +142,14 @@ class GuiApplication: |
|
|
|
|
# Debug variables |
|
|
|
|
self._mouse_history: deque[MousePos] = deque(maxlen=MOUSE_THREAD_RATE) |
|
|
|
|
|
|
|
|
|
@property |
|
|
|
|
def target_fps(self): |
|
|
|
|
return self._target_fps |
|
|
|
|
|
|
|
|
|
def request_close(self): |
|
|
|
|
self._window_close_requested = True |
|
|
|
|
|
|
|
|
|
def init_window(self, title: str, fps: int = DEFAULT_FPS): |
|
|
|
|
def init_window(self, title: str, fps: int = _DEFAULT_FPS): |
|
|
|
|
atexit.register(self.close) # Automatically call close() on exit |
|
|
|
|
|
|
|
|
|
HARDWARE.set_display_power(True) |
|
|
|
|