ui: GuiApplicationExt (#1501)

* ui: `GuiApplicationExt`

* add to readme
This commit is contained in:
Jason Wen
2025-11-21 22:28:51 -05:00
committed by GitHub
parent 4f13a0f775
commit d92d2cb683
3 changed files with 19 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ Quick start:
* set `BURN_IN=1` to get a burn-in heatmap version of the UI
* set `GRID=50` to show a 50-pixel alignment grid overlay
* set `MAGIC_DEBUG=1` to show every dropped frames (only on device)
* set `SUNNYPILOT_UI=0` to run the stock UI instead of the sunnypilot UI
* https://www.raylib.com/cheatsheet/cheatsheet.html
* https://electronstudio.github.io/raylib-python-cffi/README.html#quickstart

View File

@@ -19,6 +19,8 @@ from openpilot.system.hardware import HARDWARE, PC
from openpilot.system.ui.lib.multilang import multilang
from openpilot.common.realtime import Ratekeeper
from openpilot.system.ui.sunnypilot.lib.application import GuiApplicationExt
_DEFAULT_FPS = int(os.getenv("FPS", {'tizi': 20}.get(HARDWARE.get_device_type(), 60)))
FPS_LOG_INTERVAL = 5 # Seconds between logging FPS drops
FPS_DROP_THRESHOLD = 0.9 # FPS drop threshold for triggering a warning
@@ -186,7 +188,7 @@ class MouseState:
self._prev_mouse_event[slot] = ev
class GuiApplication:
class GuiApplication(GuiApplicationExt):
def __init__(self, width: int | None = None, height: int | None = None):
self._fonts: dict[FontWeight, rl.Font] = {}
self._width = width if width is not None else GuiApplication._default_width()

View File

@@ -0,0 +1,15 @@
"""
Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
This file is part of sunnypilot and is licensed under the MIT License.
See the LICENSE.md file in the root directory for more details.
"""
import os
SUNNYPILOT_UI = os.getenv("SUNNYPILOT_UI", "1") == "1"
class GuiApplicationExt:
@staticmethod
def sunnypilot_ui() -> bool:
return SUNNYPILOT_UI