Audiable Alert Mode - 2025-05-28

This commit is contained in:
Rick Lan
2025-04-16 22:51:14 +08:00
parent c85f3eab3f
commit 8c14380a25
4 changed files with 21 additions and 0 deletions
+1
View File
@@ -122,4 +122,5 @@ inline static std::unordered_map<std::string, uint32_t> keys = {
{"Version", PERSISTENT},
{"dp_device_last_log", CLEAR_ON_ONROAD_TRANSITION},
{"dp_device_reset_conf", CLEAR_ON_MANAGER_START},
{"dp_device_audible_alert_mode", PERSISTENT},
};
+9
View File
@@ -206,6 +206,11 @@ void DPPanel::add_device_toggles() {
"",
},
};
std::vector<QString> audible_alert_mode_texts{tr("Std."), tr("Warning"), tr("Off")};
ButtonParamControl* audible_alert_mode_setting = new ButtonParamControl("dp_device_audible_alert_mode", tr("Audible Alert Mode"),
tr("Warning - Only emits sound when there is a warning.\nOff - Does not emit any sound at all."),
"",
audible_alert_mode_texts);
QWidget *label = nullptr;
bool has_toggle = false;
@@ -224,6 +229,10 @@ void DPPanel::add_device_toggles() {
addItem(toggle);
toggles[param.toStdString()] = toggle;
}
if (!getenv("DISABLE_DRIVER")) { // lite check
addItem(audible_alert_mode_setting);
has_toggle = true;
}
// If no toggles were added, hide the label
if (!has_toggle && label) {
+10
View File
@@ -10,6 +10,7 @@ from openpilot.common.filter_simple import FirstOrderFilter
from openpilot.common.realtime import Ratekeeper
from openpilot.common.retry import retry
from openpilot.common.swaglog import cloudlog
from openpilot.common.params import Params
from openpilot.system import micd
@@ -62,6 +63,11 @@ class Soundd:
self.spl_filter_weighted = FirstOrderFilter(0, 2.5, FILTER_DT, initialized=False)
try:
self._dp_device_audible_alert_mode = int(Params().get("dp_device_audible_alert_mode"))
except:
self._dp_device_audible_alert_mode = 0
def load_sounds(self):
self.loaded_sounds: dict[int, np.ndarray] = {}
@@ -96,6 +102,10 @@ class Soundd:
written_frames += frames_to_write
self.current_sound_frame += frames_to_write
# dp - set vol to 0 instead
if self._dp_device_audible_alert_mode == 2 or (self._dp_device_audible_alert_mode == 1 and self.current_alert in [AudibleAlert.engage, AudibleAlert.disengage]):
self.current_volume = 0
return ret * self.current_volume
def callback(self, data_out: np.ndarray, frames: int, time, status) -> None:
+1
View File
@@ -40,6 +40,7 @@ def manager_init() -> None:
("OpenpilotEnabledToggle", "1"),
("LongitudinalPersonality", str(log.LongitudinalPersonality.standard)),
("DisableLogging", "0"),
("dp_device_audible_alert_mode", "0"),
]
if params.get_bool("RecordFrontLock"):