新增 `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 文件用于辅助密钥提取流程。
57 lines
1.4 KiB
Python
57 lines
1.4 KiB
Python
import io
|
|
import re
|
|
|
|
from PIL import Image, ImageDraw, ImageFont
|
|
import pyray as rl
|
|
|
|
from openpilot.system.ui.lib.application import FONT_DIR
|
|
|
|
_emoji_font: ImageFont.FreeTypeFont | None = None
|
|
_cache: dict[str, rl.Texture] = {}
|
|
|
|
EMOJI_REGEX = re.compile(
|
|
"""[\U0001F600-\U0001F64F
|
|
\U0001F300-\U0001F5FF
|
|
\U0001F680-\U0001F6FF
|
|
\U0001F1E0-\U0001F1FF
|
|
\U00002700-\U000027BF
|
|
\U0001F900-\U0001F9FF
|
|
\U00002600-\U000026FF
|
|
\U00002300-\U000023FF
|
|
\U00002B00-\U00002BFF
|
|
\U0001FA70-\U0001FAFF
|
|
\U0001F700-\U0001F77F
|
|
\u2640-\u2642
|
|
\u2600-\u2B55
|
|
\u200d
|
|
\u23cf
|
|
\u23e9
|
|
\u231a
|
|
\ufe0f
|
|
\u3030
|
|
]+""".replace("\n", ""),
|
|
flags=re.UNICODE
|
|
)
|
|
|
|
def _load_emoji_font() -> ImageFont.FreeTypeFont | None:
|
|
global _emoji_font
|
|
if _emoji_font is None:
|
|
_emoji_font = ImageFont.truetype(str(FONT_DIR.joinpath("NotoColorEmoji.ttf")), 109)
|
|
return _emoji_font
|
|
|
|
|
|
def find_emoji(text):
|
|
return [(m.start(), m.end(), m.group()) for m in EMOJI_REGEX.finditer(text)]
|
|
|
|
def emoji_tex(emoji):
|
|
if emoji not in _cache:
|
|
img = Image.new("RGBA", (128, 128), (0, 0, 0, 0))
|
|
draw = ImageDraw.Draw(img)
|
|
draw.text((0, 0), emoji, font=_load_emoji_font(), embedded_color=True)
|
|
with io.BytesIO() as buffer:
|
|
img.save(buffer, format="PNG")
|
|
l = buffer.tell()
|
|
buffer.seek(0)
|
|
_cache[emoji] = rl.load_texture_from_image(rl.load_image_from_memory(".png", buffer.getvalue(), l))
|
|
return _cache[emoji]
|