Audible Alert Mode Toggle

This commit is contained in:
Rick Lan
2024-07-13 18:15:49 +08:00
parent c5df9d7fb6
commit 9099efccd8
4 changed files with 19 additions and 4 deletions

View File

@@ -3,11 +3,12 @@ dragonpilot [latest]
* Up to comma.ai openpilot master branch commit 01c2174d5968266b87f1d1fecefce5affaeaa624 (2024-07-02)
* DP HIGHLIGHT:
* (TESTING) Tē-Tôo / Map Module
* Road Name Display (Online OpenStreetMap)
* Speed Camera Warning (Online OpenstreetMap: Untested)
* Dedicated Speed Camera Warning (Taiwan)
* Road Name Display (Online using OSM)
* Speed Camera Warning (Online using OSM: Untested)
* Speed Camera Warning (Taiwan, Offline)
* Dynamic End-to-End w/ Toggleable Road Condition Detection.
* Device Auto Shutdown Toggle.
* Device Audible Alert Mode Toggle.
dragonpilot [2024.07.01]
=======================

View File

@@ -245,6 +245,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"dp_long_de2e_road_condition", PERSISTENT},
{"dp_device_auto_shutdown", PERSISTENT},
{"dp_device_auto_shutdown_in", PERSISTENT},
{"dp_device_audible_alert_mode", PERSISTENT},
};
} // namespace

View File

@@ -12,6 +12,7 @@ from openpilot.common.retry import retry
from openpilot.common.swaglog import cloudlog
from openpilot.system import micd
from openpilot.common.params import Params
SAMPLE_RATE = 48000
SAMPLE_BUFFER = 4096 # (approx 100ms)
@@ -62,6 +63,10 @@ class Soundd:
self.spl_filter_weighted = FirstOrderFilter(0, 2.5, FILTER_DT, initialized=False)
params = Params()
self._dp_device_audible_alert_mode = int(params.get("dp_device_audible_alert_mode"))
def load_sounds(self):
self.loaded_sounds: dict[int, np.ndarray] = {}
@@ -82,6 +87,13 @@ class Soundd:
ret = np.zeros(frames, dtype=np.float32)
# dp - set vol to 0 instead
mute = False
if self._dp_device_audible_alert_mode == 2:
mute = True
elif self._dp_device_audible_alert_mode == 1 and self.current_alert in [AudibleAlert.engage, AudibleAlert.disengage]:
mute = True
if self.current_alert != AudibleAlert.none:
num_loops = sound_list[self.current_alert][1]
sound_data = self.loaded_sounds[self.current_alert]
@@ -97,7 +109,7 @@ class Soundd:
written_frames += frames_to_write
self.current_sound_frame += frames_to_write
return ret * self.current_volume
return ret * (self.current_volume if not mute else 0)
def callback(self, data_out: np.ndarray, frames: int, time, status) -> None:
if status:

View File

@@ -83,6 +83,7 @@ def manager_init() -> None:
("dp_long_de2e_road_condition", "1"), # on by default, depends on dp_long_de2e
("dp_device_auto_shutdown", "0"),
("dp_device_auto_shutdown_in", "30"),
("dp_device_audible_alert_mode", "0"),
]
if not PC:
default_params.append(("LastUpdateTime", datetime.datetime.now(datetime.UTC).replace(tzinfo=None).isoformat().encode('utf8')))