Alert volume control
Added toggles to customize the volume level for each individual sound.
This commit is contained in:
@@ -212,19 +212,27 @@ std::unordered_map<std::string, uint32_t> keys = {
|
|||||||
{"AccelerationPath", PERSISTENT},
|
{"AccelerationPath", PERSISTENT},
|
||||||
{"AccelerationProfile", PERSISTENT},
|
{"AccelerationProfile", PERSISTENT},
|
||||||
{"AggressiveAcceleration", PERSISTENT},
|
{"AggressiveAcceleration", PERSISTENT},
|
||||||
|
{"AlertVolumeControl", PERSISTENT},
|
||||||
{"ApiCache_DriveStats", PERSISTENT},
|
{"ApiCache_DriveStats", PERSISTENT},
|
||||||
{"CustomAlerts", PERSISTENT},
|
{"CustomAlerts", PERSISTENT},
|
||||||
{"CustomUI", PERSISTENT},
|
{"CustomUI", PERSISTENT},
|
||||||
{"DecelerationProfile", PERSISTENT},
|
{"DecelerationProfile", PERSISTENT},
|
||||||
|
{"DisengageVolume", PERSISTENT},
|
||||||
{"DriveStats", PERSISTENT},
|
{"DriveStats", PERSISTENT},
|
||||||
|
{"EngageVolume", PERSISTENT},
|
||||||
{"FrogPilotTogglesUpdated", PERSISTENT},
|
{"FrogPilotTogglesUpdated", PERSISTENT},
|
||||||
{"FrogsGoMoo", PERSISTENT},
|
{"FrogsGoMoo", PERSISTENT},
|
||||||
{"LateralTune", PERSISTENT},
|
{"LateralTune", PERSISTENT},
|
||||||
{"LongitudinalTune", PERSISTENT},
|
{"LongitudinalTune", PERSISTENT},
|
||||||
|
{"PromptVolume", PERSISTENT},
|
||||||
|
{"PromptDistractedVolume", PERSISTENT},
|
||||||
{"QOLControls", PERSISTENT},
|
{"QOLControls", PERSISTENT},
|
||||||
{"QOLVisuals", PERSISTENT},
|
{"QOLVisuals", PERSISTENT},
|
||||||
|
{"RefuseVolume", PERSISTENT},
|
||||||
{"SilentMode", PERSISTENT},
|
{"SilentMode", PERSISTENT},
|
||||||
{"StockTune", PERSISTENT},
|
{"StockTune", PERSISTENT},
|
||||||
|
{"WarningSoftVolume", PERSISTENT},
|
||||||
|
{"WarningImmediateVolume", PERSISTENT},
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
BIN
selfdrive/frogpilot/assets/toggle_icons/icon_mute.png
Normal file
BIN
selfdrive/frogpilot/assets/toggle_icons/icon_mute.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -2,6 +2,15 @@
|
|||||||
|
|
||||||
FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilotListWidget(parent) {
|
FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilotListWidget(parent) {
|
||||||
const std::vector<std::tuple<QString, QString, QString, QString>> visualToggles {
|
const std::vector<std::tuple<QString, QString, QString, QString>> visualToggles {
|
||||||
|
{"AlertVolumeControl", "Alert Volume Control", "Control the volume level for each individual sound in openpilot.", "../frogpilot/assets/toggle_icons/icon_mute.png"},
|
||||||
|
{"DisengageVolume", "Disengage Volume", "Related alerts:\n\nAdaptive Cruise Disabled\nParking Brake Engaged\nPedal Pressed\nSpeed too Low", ""},
|
||||||
|
{"EngageVolume", "Engage Volume", "Related alerts:\n\nNNFF Torque Controller loaded", ""},
|
||||||
|
{"PromptVolume", "Prompt Volume", "Related alerts:\n\nCar Detected in Blindspot\nLight turned green\nSpeed too Low\nSteer Unavailable Below 'X'\nTake Control, Turn Exceeds Steering Limit", ""},
|
||||||
|
{"PromptDistractedVolume", "Prompt Distracted Volume", "Related alerts:\n\nPay Attention, Driver Distracted\nTouch Steering Wheel, Driver Unresponsive", ""},
|
||||||
|
{"RefuseVolume", "Refuse Volume", "Related alerts:\n\nopenpilot Unavailable", ""},
|
||||||
|
{"WarningSoftVolume", "Warning Soft Volume", "Related alerts:\n\nBRAKE!, Risk of Collision\nTAKE CONTROL IMMEDIATELY", ""},
|
||||||
|
{"WarningImmediateVolume", "Warning Immediate Volume", "Related alerts:\n\nDISENGAGE IMMEDIATELY, Driver Distracted\nDISENGAGE IMMEDIATELY, Driver Unresponsive", ""},
|
||||||
|
|
||||||
{"CustomAlerts", "Custom Alerts", "Enable custom alerts for various logic or situational changes.", "../frogpilot/assets/toggle_icons/icon_green_light.png"},
|
{"CustomAlerts", "Custom Alerts", "Enable custom alerts for various logic or situational changes.", "../frogpilot/assets/toggle_icons/icon_green_light.png"},
|
||||||
|
|
||||||
{"CustomUI", "Custom Onroad UI", "Customize the Onroad UI with some additional visual functions.", "../assets/offroad/icon_road.png"},
|
{"CustomUI", "Custom Onroad UI", "Customize the Onroad UI with some additional visual functions.", "../assets/offroad/icon_road.png"},
|
||||||
@@ -14,7 +23,23 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot
|
|||||||
for (const auto &[param, title, desc, icon] : visualToggles) {
|
for (const auto &[param, title, desc, icon] : visualToggles) {
|
||||||
ParamControl *toggle;
|
ParamControl *toggle;
|
||||||
|
|
||||||
if (param == "CustomAlerts") {
|
if (param == "AlertVolumeControl") {
|
||||||
|
FrogPilotParamManageControl *alertVolumeControlToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||||
|
QObject::connect(alertVolumeControlToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||||
|
parentToggleClicked();
|
||||||
|
for (auto &[key, toggle] : toggles) {
|
||||||
|
toggle->setVisible(alertVolumeControlKeys.find(key.c_str()) != alertVolumeControlKeys.end());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
toggle = alertVolumeControlToggle;
|
||||||
|
} else if (alertVolumeControlKeys.find(param) != alertVolumeControlKeys.end()) {
|
||||||
|
if (param == "WarningImmediateVolume") {
|
||||||
|
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 25, 100, std::map<int, QString>(), this, false, "%");
|
||||||
|
} else {
|
||||||
|
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 100, std::map<int, QString>(), this, false, "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (param == "CustomAlerts") {
|
||||||
FrogPilotParamManageControl *customAlertsToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
FrogPilotParamManageControl *customAlertsToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
|
||||||
QObject::connect(customAlertsToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
QObject::connect(customAlertsToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {
|
||||||
parentToggleClicked();
|
parentToggleClicked();
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ private:
|
|||||||
void updateState(const UIState &s);
|
void updateState(const UIState &s);
|
||||||
void updateToggles();
|
void updateToggles();
|
||||||
|
|
||||||
std::set<QString> alertVolumeControlKeys = {};
|
std::set<QString> alertVolumeControlKeys = {"EngageVolume", "DisengageVolume", "RefuseVolume", "PromptVolume", "PromptDistractedVolume", "WarningSoftVolume", "WarningImmediateVolume"};
|
||||||
std::set<QString> customAlertsKeys = {};
|
std::set<QString> customAlertsKeys = {};
|
||||||
std::set<QString> customOnroadUIKeys = {"AccelerationPath"};
|
std::set<QString> customOnroadUIKeys = {"AccelerationPath"};
|
||||||
std::set<QString> customThemeKeys = {};
|
std::set<QString> customThemeKeys = {};
|
||||||
|
|||||||
@@ -153,10 +153,13 @@ class Soundd:
|
|||||||
while True:
|
while True:
|
||||||
sm.update(0)
|
sm.update(0)
|
||||||
|
|
||||||
if sm.updated['microphone'] and self.current_alert == AudibleAlert.none: # only update volume filter when not playing alert
|
if sm.updated['microphone'] and self.current_alert == AudibleAlert.none and not self.alert_volume_control: # only update volume filter when not playing alert
|
||||||
self.spl_filter_weighted.update(sm["microphone"].soundPressureWeightedDb)
|
self.spl_filter_weighted.update(sm["microphone"].soundPressureWeightedDb)
|
||||||
self.current_volume = self.calculate_volume(float(self.spl_filter_weighted.x))
|
self.current_volume = self.calculate_volume(float(self.spl_filter_weighted.x))
|
||||||
|
|
||||||
|
elif self.alert_volume_control and self.current_alert in self.volume_map:
|
||||||
|
self.current_volume = self.volume_map[self.current_alert] / 100.0
|
||||||
|
|
||||||
self.get_audible_alert(sm)
|
self.get_audible_alert(sm)
|
||||||
|
|
||||||
rk.keep_time()
|
rk.keep_time()
|
||||||
@@ -168,6 +171,22 @@ class Soundd:
|
|||||||
self.update_frogpilot_params()
|
self.update_frogpilot_params()
|
||||||
|
|
||||||
def update_frogpilot_params(self):
|
def update_frogpilot_params(self):
|
||||||
|
self.alert_volume_control = self.params.get_bool("AlertVolumeControl")
|
||||||
|
|
||||||
|
self.volume_map = {
|
||||||
|
AudibleAlert.engage: self.params.get_int("EngageVolume"),
|
||||||
|
AudibleAlert.disengage: self.params.get_int("DisengageVolume"),
|
||||||
|
AudibleAlert.refuse: self.params.get_int("RefuseVolume"),
|
||||||
|
|
||||||
|
AudibleAlert.prompt: self.params.get_int("PromptVolume"),
|
||||||
|
AudibleAlert.promptRepeat: self.params.get_int("PromptVolume"),
|
||||||
|
AudibleAlert.promptDistracted: self.params.get_int("PromptDistractedVolume"),
|
||||||
|
|
||||||
|
AudibleAlert.warningSoft: self.params.get_int("WarningSoftVolume"),
|
||||||
|
AudibleAlert.warningImmediate: self.params.get_int("WarningImmediateVolume")
|
||||||
|
}
|
||||||
|
|
||||||
|
self.load_sounds()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
s = Soundd()
|
s = Soundd()
|
||||||
|
|||||||
Reference in New Issue
Block a user