[TIZI/TICI] ui: Rocket Fuel (#1337)
* rocket * raylib * extra --------- Co-authored-by: Jason Wen <haibin.wen3@gmail.com>
This commit is contained in:
@@ -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"}},
|
||||
|
||||
@@ -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)
|
||||
|
||||
45
selfdrive/ui/sunnypilot/onroad/rocket_fuel.py
Normal file
45
selfdrive/ui/sunnypilot/onroad/rocket_fuel.py
Normal 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)
|
||||
@@ -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")
|
||||
|
||||
@@ -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": ""
|
||||
|
||||
Reference in New Issue
Block a user