[TIZI/TICI] ui: Rocket Fuel (#1337)

* rocket

* raylib

* extra

---------

Co-authored-by: Jason Wen <haibin.wen3@gmail.com>
This commit is contained in:
Kumar
2026-01-23 21:27:12 -07:00
committed by GitHub
parent 2e788ae54d
commit 8c36739ebd
5 changed files with 56 additions and 0 deletions

View File

@@ -173,6 +173,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
{"QuickBootToggle", {PERSISTENT | BACKUP, BOOL, "0"}},
{"QuietMode", {PERSISTENT | BACKUP, BOOL, "0"}},
{"RainbowMode", {PERSISTENT | BACKUP, BOOL, "0"}},
{"RocketFuel", {PERSISTENT | BACKUP, BOOL, "0"}},
{"ShowAdvancedControls", {PERSISTENT | BACKUP, BOOL, "0"}},
{"ShowTurnSignals", {PERSISTENT | BACKUP, BOOL, "0"}},
{"StandstillTimer", {PERSISTENT | BACKUP, BOOL, "0"}},

View File

@@ -6,15 +6,20 @@ See the LICENSE.md file in the root directory for more details.
"""
import pyray as rl
from openpilot.selfdrive.ui.ui_state import ui_state
from openpilot.selfdrive.ui.onroad.hud_renderer import HudRenderer
from openpilot.selfdrive.ui.sunnypilot.onroad.developer_ui import DeveloperUiRenderer
from openpilot.selfdrive.ui.sunnypilot.onroad.rocket_fuel import RocketFuel
class HudRendererSP(HudRenderer):
def __init__(self):
super().__init__()
self.developer_ui = DeveloperUiRenderer()
self.rocket_fuel = RocketFuel()
def _render(self, rect: rl.Rectangle) -> None:
super()._render(rect)
self.developer_ui.render(rect)
if ui_state.rocket_fuel:
self.rocket_fuel.render(rect, ui_state.sm)

View File

@@ -0,0 +1,45 @@
"""
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 pyray as rl
class RocketFuel:
def __init__(self):
self.vc_accel = 0.0
def render(self, rect: rl.Rectangle, sm) -> None:
vc_accel0 = sm['carState'].aEgo
# Smooth the acceleration
self.vc_accel = self.vc_accel + (vc_accel0 - self.vc_accel) / 5.0
hha = 0.0
color = rl.Color(0, 0, 0, 0) # Transparent by default
if self.vc_accel > 0:
hha = 0.85 - 0.1 / self.vc_accel # only extend up to 85%
color = rl.Color(0, 245, 0, 200)
elif self.vc_accel < 0:
hha = 0.85 + 0.1 / self.vc_accel # only extend up to 85%
color = rl.Color(245, 0, 0, 200)
if hha < 0:
hha = 0.0
hha = hha * rect.height
wp = 28.0
# Draw
rect_h = rect.height
if self.vc_accel > 0:
ra_y = rect_h / 2.0 - hha / 2.0
else:
ra_y = rect_h / 2.0
if hha > 0:
rl.draw_rectangle(int(rect.x), int(rect.y + ra_y), int(wp), int(hha / 2.0), color)

View File

@@ -122,6 +122,7 @@ class UIStateSP:
self.CP_SP = messaging.log_from_bytes(CP_SP_bytes, custom.CarParamsSP)
self.sunnylink_enabled = self.params.get_bool("SunnylinkEnabled")
self.developer_ui = self.params.get("DevUIInfo")
self.rocket_fuel = self.params.get_bool("RocketFuel")
self.rainbow_path = self.params.get_bool("RainbowMode")
self.chevron_metrics = self.params.get("ChevronInfo")
self.active_bundle = self.params.get("ModelManager_ActiveBundle")

View File

@@ -1082,6 +1082,10 @@
"title": "Display Road Name",
"description": ""
},
"RocketFuel": {
"title": "Display Rocket Fuel Bar",
"description": "Show an indicator on the left side of the screen to display real-time vehicle acceleration and deceleration."
},
"RouteCount": {
"title": "Route Count",
"description": ""