notify param

pull/35361/head
Shane Smiskol 3 months ago
parent f9570b95de
commit 7ab75c4d1a
  1. 1
      common/params_keys.h
  2. 17
      selfdrive/ui/qt/offroad/settings.cc
  3. 5
      selfdrive/ui/qt/widgets/controls.h

@ -106,6 +106,7 @@ inline static std::unordered_map<std::string, uint32_t> keys = {
{"SshEnabled", PERSISTENT}, {"SshEnabled", PERSISTENT},
{"TermsVersion", PERSISTENT}, {"TermsVersion", PERSISTENT},
{"TrainingVersion", PERSISTENT}, {"TrainingVersion", PERSISTENT},
{"ToggleRestart", CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION | CLEAR_ON_ONROAD_TRANSITION},
{"UbloxAvailable", PERSISTENT}, {"UbloxAvailable", PERSISTENT},
{"UpdateAvailable", CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION}, {"UpdateAvailable", CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION},
{"UpdateFailedCount", CLEAR_ON_MANAGER_START}, {"UpdateFailedCount", CLEAR_ON_MANAGER_START},

@ -17,49 +17,56 @@
#include "selfdrive/ui/qt/offroad/firehose.h" #include "selfdrive/ui/qt/offroad/firehose.h"
TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) { TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) {
// param, title, desc, icon // param, title, desc, icon, restart needed
std::vector<std::tuple<QString, QString, QString, QString>> toggle_defs{ std::vector<std::tuple<QString, QString, QString, QString, bool>> toggle_defs{
{ {
"OpenpilotEnabledToggle", "OpenpilotEnabledToggle",
tr("Enable openpilot"), tr("Enable openpilot"),
tr("Use the openpilot system for adaptive cruise control and lane keep driver assistance. Your attention is required at all times to use this feature. Changing this setting takes effect when the car is powered off."), tr("Use the openpilot system for adaptive cruise control and lane keep driver assistance. Your attention is required at all times to use this feature. Changing this setting takes effect when the car is powered off."),
"../assets/icons/chffr_wheel.png", "../assets/icons/chffr_wheel.png",
true,
}, },
{ {
"ExperimentalMode", "ExperimentalMode",
tr("Experimental Mode"), tr("Experimental Mode"),
"", "",
"../assets/icons/experimental_white.svg", "../assets/icons/experimental_white.svg",
false,
}, },
{ {
"DisengageOnAccelerator", "DisengageOnAccelerator",
tr("Disengage on Accelerator Pedal"), tr("Disengage on Accelerator Pedal"),
tr("When enabled, pressing the accelerator pedal will disengage openpilot."), tr("When enabled, pressing the accelerator pedal will disengage openpilot."),
"../assets/icons/disengage_on_accelerator.svg", "../assets/icons/disengage_on_accelerator.svg",
false,
}, },
{ {
"IsLdwEnabled", "IsLdwEnabled",
tr("Enable Lane Departure Warnings"), tr("Enable Lane Departure Warnings"),
tr("Receive alerts to steer back into the lane when your vehicle drifts over a detected lane line without a turn signal activated while driving over 31 mph (50 km/h)."), tr("Receive alerts to steer back into the lane when your vehicle drifts over a detected lane line without a turn signal activated while driving over 31 mph (50 km/h)."),
"../assets/icons/warning.png", "../assets/icons/warning.png",
true, // TODO: it should read live!
}, },
{ {
"AlwaysOnDM", "AlwaysOnDM",
tr("Always-On Driver Monitoring"), tr("Always-On Driver Monitoring"),
tr("Enable driver monitoring even when openpilot is not engaged."), tr("Enable driver monitoring even when openpilot is not engaged."),
"../assets/icons/monitoring.png", "../assets/icons/monitoring.png",
false,
}, },
{ {
"RecordFront", "RecordFront",
tr("Record and Upload Driver Camera"), tr("Record and Upload Driver Camera"),
tr("Upload data from the driver facing camera and help improve the driver monitoring algorithm."), tr("Upload data from the driver facing camera and help improve the driver monitoring algorithm."),
"../assets/icons/monitoring.png", "../assets/icons/monitoring.png",
true,
}, },
{ {
"IsMetric", "IsMetric",
tr("Use Metric System"), tr("Use Metric System"),
tr("Display speed in km/h instead of mph."), tr("Display speed in km/h instead of mph."),
"../assets/icons/metric.png", "../assets/icons/metric.png",
false,
}, },
}; };
@ -75,9 +82,13 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) {
// set up uiState update for personality setting // set up uiState update for personality setting
QObject::connect(uiState(), &UIState::uiUpdate, this, &TogglesPanel::updateState); QObject::connect(uiState(), &UIState::uiUpdate, this, &TogglesPanel::updateState);
for (auto &[param, title, desc, icon] : toggle_defs) { for (auto &[param, title, desc, icon, needs_restart] : toggle_defs) {
auto toggle = new ParamControl(param, title, desc, icon, this); auto toggle = new ParamControl(param, title, desc, icon, this);
if (needs_restart) {
toggle->setNotifyParam("ToggleRestart");
}
bool locked = params.getBool((param + "Lock").toStdString()); bool locked = params.getBool((param + "Lock").toStdString());
toggle->setEnabled(!locked); toggle->setEnabled(!locked);

@ -150,6 +150,10 @@ public:
store_confirm = _store_confirm; store_confirm = _store_confirm;
} }
void setNotifyParam(const QString &_notify_param) {
notify_param = _notify_param;
}
void setActiveIcon(const QString &icon) { void setActiveIcon(const QString &icon) {
active_icon_pixmap = QPixmap(icon).scaledToWidth(80, Qt::SmoothTransformation); active_icon_pixmap = QPixmap(icon).scaledToWidth(80, Qt::SmoothTransformation);
} }
@ -181,6 +185,7 @@ private:
QPixmap active_icon_pixmap; QPixmap active_icon_pixmap;
bool confirm = false; bool confirm = false;
bool store_confirm = false; bool store_confirm = false;
QString notify_param;
}; };
class MultiButtonControl : public AbstractControl { class MultiButtonControl : public AbstractControl {

Loading…
Cancel
Save