ui: add alert beeper toggle to visual settings

This commit is contained in:
1okko
2026-09-27 22:52:15 +08:00
parent a8b5c5b4d7
commit 33ff042425
6 changed files with 24 additions and 0 deletions
Binary file not shown.
+1
View File
@@ -9,6 +9,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
{"AccessToken", {CLEAR_ON_MANAGER_START | DONT_LOG, STRING}},
{"AdbEnabled", {PERSISTENT | BACKUP, BOOL}},
{"AlwaysOnDM", {PERSISTENT | BACKUP, BOOL}},
{"BeepEnabled", {PERSISTENT | BACKUP, BOOL, "1"}},
{"ApiCache_Device", {PERSISTENT, STRING}},
{"ApiCache_FirehoseStats", {PERSISTENT, JSON}},
{"AssistNowToken", {PERSISTENT, STRING}},
+4
View File
@@ -5,6 +5,7 @@ import threading
import openpilot.cereal.messaging as messaging
from opendbc.car.structs import car
from openpilot.common.params import Params
from openpilot.common.realtime import Ratekeeper
AudibleAlert = car.CarControl.HUDControl.AudibleAlert
@@ -12,6 +13,7 @@ AudibleAlert = car.CarControl.HUDControl.AudibleAlert
class Beepd:
def __init__(self):
self.current_alert = AudibleAlert.none
self.params = Params()
self.enable_gpio()
#self.startup_beep()
@@ -32,6 +34,8 @@ class Beepd:
encoding='utf8')
def _beep(self, on):
if on and not self.params.get_bool("BeepEnabled"):
return
val = "1" if on else "0"
subprocess.run(f"echo \"{val}\" | sudo tee /sys/class/gpio/gpio42/value",
shell=True,
@@ -28,6 +28,11 @@ class VisualsLayout(Widget):
def _initialize_items(self):
self._toggle_defs = {
"BeepEnabled": (
lambda: tr("Alert Beeper"),
tr("Play engage, disengage, and warning beeps using the hardware beeper."),
None,
),
"BlindSpot": (
lambda: tr("Show Blind Spot Warnings"),
tr("Enabling this will display warnings when a vehicle is detected in your " +
@@ -2804,3 +2804,10 @@ msgstr ""
msgid "Reverse"
msgstr ""
#: openpilot/selfdrive/ui/sunnypilot/layouts/settings/visuals.py
msgid "Alert Beeper"
msgstr ""
#: openpilot/selfdrive/ui/sunnypilot/layouts/settings/visuals.py
msgid "Play engage, disengage, and warning beeps using the hardware beeper."
msgstr ""
@@ -2891,3 +2891,10 @@ msgstr "准备中"
msgid "unavailable"
msgstr "不可用"
#: openpilot/selfdrive/ui/sunnypilot/layouts/settings/visuals.py
msgid "Alert Beeper"
msgstr "提示音"
#: openpilot/selfdrive/ui/sunnypilot/layouts/settings/visuals.py
msgid "Play engage, disengage, and warning beeps using the hardware beeper."
msgstr "使用硬件蜂鸣器播放接管、退出和警告提示音。"