Skip to content

Commit

Permalink
Quiet Drive (#2)
Browse files Browse the repository at this point in the history
* Add silent toggle

* add semi colons and remove wav files

* rename method

* update icon and description for quietdrive
  • Loading branch information
dri94 authored and sunnyhaibin committed Sep 18, 2021
1 parent c5002b0 commit b18649e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
Binary file added selfdrive/assets/offroad/icon_mute.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions selfdrive/common/params.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"CurrentRoute", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON},
{"DisableRadar", PERSISTENT}, // WARNING: THIS DISABLES AEB
{"EndToEndToggle", PERSISTENT},
{"QuietDrive", PERSISTENT},
{"CompletedTrainingVersion", PERSISTENT},
{"DisablePowerDown", PERSISTENT},
{"DisableUpdates", PERSISTENT},
Expand Down
5 changes: 5 additions & 0 deletions selfdrive/ui/qt/offroad/settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ TogglesPanel::TogglesPanel(QWidget *parent) : QWidget(parent) {
"In this mode openpilot will ignore lanelines and just drive how it thinks a human would.",
"../assets/offroad/icon_road.png",
this));
toggles.append(new ParamControl("QuietDrive",
"Quiet Drive 🤫",
"In this mode openpilot will display alerts but only play the most important warning sounds. ",
"../assets/offroad/icon_mute.png",
this));

#ifdef ENABLE_MAPS
toggles.append(new ParamControl("NavSettingTime24h",
Expand Down
9 changes: 8 additions & 1 deletion selfdrive/ui/soundd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <QString>
#include <QSoundEffect>

#include "selfdrive/common/params.h"
#include "cereal/messaging/messaging.h"
#include "selfdrive/common/util.h"
#include "selfdrive/hardware/hw.h"
Expand Down Expand Up @@ -83,7 +84,7 @@ private slots:
}

// play sound
if (alert.sound != AudibleAlert::NONE) {
if (shouldPlaySound(a)) {
auto &[s, loops] = sounds[alert.sound];
s->setLoopCount(loops);
s->setVolume(volume);
Expand All @@ -92,6 +93,12 @@ private slots:
}
}

bool shouldPlaySound(Alert a) {
bool isQuietDrive = Params().getBool("QuietDrive");
return (a.sound == AudibleAlert::CHIME_WARNING2_REPEAT || a.sound == AudibleAlert::CHIME_WARNING_REPEAT) ||
(!isQuietDrive && a.sound != AudibleAlert::NONE);
}

private:
Alert alert;
float volume = Hardware::MIN_VOLUME;
Expand Down

0 comments on commit b18649e

Please sign in to comment.