新增 `DistractionDetectionLevel` 参数以控制驾驶员分心检测的灵敏度等级,并在 `dmonitoringd.py` 和 `helpers.py` 中实现不同等级对应的时间阈值配置。同时更新了相关逻辑以支持动态调整该参数。 fix(toyota): 支持 Toyota Wildlander PHEV 车型接入与控制 增加对 Toyota Wildlander PHEV 的指纹识别、车辆规格定义及接口适配,确保其在 TSS2 平台下的正常运行,并修正部分雷达ACC判断条件。 feat(ui): 优化 Dragonpilot 设置界面选项显示语言一致性 将 Dragonpilot 设置页面中的多个下拉选项文本进行国际化处理,统一使用翻译函数包裹,提升多语言兼容性。 chore(config): 更新 launch 脚本 API 地址并切换 shell 解释器 修改 `launch_openpilot.sh` 使用 `/usr/bin/bash` 作为解释器,并设置自定义 API 与 Athena 服务地址。 refactor(key): 实现 ECU 秘钥提取脚本并写入参数存储 创建 `key.py` 脚本用于通过 UDS 协议从 ECU 提取 SecOC 密钥,并将其保存至系统参数中供后续使用。 docs(vscode): 移除不再使用的终端配置项 清理 `.vscode/settings.json` 文件中过时的 terminal 配置内容。 feat(fonts): 新增中文字体资源文件 添加 `china.ttf` 字体文件以增强 UI 在中文环境下的渲染效果。 build(payload): 添加二进制负载文件 引入新的二进制 payload 文件用于辅助密钥提取流程。
109 lines
3.6 KiB
Python
Executable File
109 lines
3.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import pyray as rl
|
|
import select
|
|
import sys
|
|
|
|
from openpilot.system.ui.lib.application import gui_app
|
|
from openpilot.system.ui.lib.text_measure import measure_text_cached
|
|
from openpilot.system.ui.text import wrap_text
|
|
from openpilot.system.ui.widgets import Widget
|
|
|
|
# Constants
|
|
PROGRESS_BAR_WIDTH = 1000
|
|
PROGRESS_BAR_HEIGHT = 20
|
|
DEGREES_PER_SECOND = 360.0 # one full rotation per second
|
|
MARGIN_H = 100
|
|
TEXTURE_SIZE = 360
|
|
FONT_SIZE = 96
|
|
LINE_HEIGHT = 104
|
|
DARKGRAY = (55, 55, 55, 255)
|
|
|
|
|
|
def clamp(value, min_value, max_value):
|
|
return max(min(value, max_value), min_value)
|
|
|
|
|
|
class Spinner(Widget):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self._comma_texture = gui_app.texture("images/spinner_comma.png", TEXTURE_SIZE, TEXTURE_SIZE)
|
|
self._spinner_texture = gui_app.texture("images/spinner_track.png", TEXTURE_SIZE, TEXTURE_SIZE, alpha_premultiply=True)
|
|
self._rotation = 0.0
|
|
self._progress: int | None = None
|
|
self._wrapped_lines: list[str] = []
|
|
|
|
def set_text(self, text: str) -> None:
|
|
if text.isdigit():
|
|
self._progress = clamp(int(text), 0, 100)
|
|
self._wrapped_lines = []
|
|
else:
|
|
self._progress = None
|
|
self._wrapped_lines = wrap_text(text, FONT_SIZE, gui_app.width - MARGIN_H)
|
|
|
|
def _render(self, rect: rl.Rectangle):
|
|
if self._wrapped_lines:
|
|
# Calculate total height required for spinner and text
|
|
spacing = 50
|
|
total_height = TEXTURE_SIZE + spacing + len(self._wrapped_lines) * LINE_HEIGHT
|
|
center_y = (rect.height - total_height) / 2.0 + TEXTURE_SIZE / 2.0
|
|
else:
|
|
# Center spinner vertically
|
|
spacing = 150
|
|
center_y = rect.height / 2.0
|
|
y_pos = center_y + TEXTURE_SIZE / 2.0 + spacing
|
|
|
|
center = rl.Vector2(rect.width / 2.0, center_y)
|
|
spinner_origin = rl.Vector2(TEXTURE_SIZE / 2.0, TEXTURE_SIZE / 2.0)
|
|
comma_position = rl.Vector2(center.x - TEXTURE_SIZE / 2.0, center.y - TEXTURE_SIZE / 2.0)
|
|
|
|
delta_time = rl.get_frame_time()
|
|
self._rotation = (self._rotation + DEGREES_PER_SECOND * delta_time) % 360.0
|
|
|
|
# Draw rotating spinner and static comma logo
|
|
rl.draw_texture_pro(self._spinner_texture, rl.Rectangle(0, 0, TEXTURE_SIZE, TEXTURE_SIZE),
|
|
rl.Rectangle(center.x, center.y, TEXTURE_SIZE, TEXTURE_SIZE),
|
|
spinner_origin, self._rotation, rl.WHITE)
|
|
rl.draw_texture_v(self._comma_texture, comma_position, rl.WHITE)
|
|
|
|
# Display the progress bar or text based on user input
|
|
if self._progress is not None:
|
|
bar = rl.Rectangle(center.x - PROGRESS_BAR_WIDTH / 2.0, y_pos, PROGRESS_BAR_WIDTH, PROGRESS_BAR_HEIGHT)
|
|
rl.draw_rectangle_rounded(bar, 1, 10, DARKGRAY)
|
|
|
|
bar.width *= self._progress / 100.0
|
|
rl.draw_rectangle_rounded(bar, 1, 10, rl.WHITE)
|
|
elif self._wrapped_lines:
|
|
for i, line in enumerate(self._wrapped_lines):
|
|
text_size = measure_text_cached(gui_app.font(), line, FONT_SIZE)
|
|
rl.draw_text_ex(gui_app.font(), line, rl.Vector2(center.x - text_size.x / 2, y_pos + i * LINE_HEIGHT),
|
|
FONT_SIZE, 0.0, rl.WHITE)
|
|
|
|
|
|
def _read_stdin():
|
|
"""Non-blocking read of available lines from stdin."""
|
|
lines = []
|
|
while True:
|
|
rlist, _, _ = select.select([sys.stdin], [], [], 0.0)
|
|
if not rlist:
|
|
break
|
|
line = sys.stdin.readline().strip()
|
|
if line == "":
|
|
break
|
|
lines.append(line)
|
|
return lines
|
|
|
|
|
|
def main():
|
|
gui_app.init_window("Spinner")
|
|
spinner = Spinner()
|
|
for _ in gui_app.render():
|
|
text_list = _read_stdin()
|
|
if text_list:
|
|
spinner.set_text(text_list[-1])
|
|
|
|
spinner.render(rl.Rectangle(0, 0, gui_app.width, gui_app.height))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|