From 7ab75c4d1ad2df606e74429068aaaabd6f61a534 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 27 May 2025 16:10:47 -0700 Subject: [PATCH] notify param --- common/params_keys.h | 1 + selfdrive/ui/qt/offroad/settings.cc | 17 ++++++++++++++--- selfdrive/ui/qt/widgets/controls.h | 5 +++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/common/params_keys.h b/common/params_keys.h index ca779a5b5c..0afc57c5c6 100644 --- a/common/params_keys.h +++ b/common/params_keys.h @@ -106,6 +106,7 @@ inline static std::unordered_map keys = { {"SshEnabled", PERSISTENT}, {"TermsVersion", PERSISTENT}, {"TrainingVersion", PERSISTENT}, + {"ToggleRestart", CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION | CLEAR_ON_ONROAD_TRANSITION}, {"UbloxAvailable", PERSISTENT}, {"UpdateAvailable", CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION}, {"UpdateFailedCount", CLEAR_ON_MANAGER_START}, diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index ed06734f0f..52e1087f3f 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -17,49 +17,56 @@ #include "selfdrive/ui/qt/offroad/firehose.h" TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) { - // param, title, desc, icon - std::vector> toggle_defs{ + // param, title, desc, icon, restart needed + std::vector> toggle_defs{ { "OpenpilotEnabledToggle", 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."), "../assets/icons/chffr_wheel.png", + true, }, { "ExperimentalMode", tr("Experimental Mode"), "", "../assets/icons/experimental_white.svg", + false, }, { "DisengageOnAccelerator", tr("Disengage on Accelerator Pedal"), tr("When enabled, pressing the accelerator pedal will disengage openpilot."), "../assets/icons/disengage_on_accelerator.svg", + false, }, { "IsLdwEnabled", 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)."), "../assets/icons/warning.png", + true, // TODO: it should read live! }, { "AlwaysOnDM", tr("Always-On Driver Monitoring"), tr("Enable driver monitoring even when openpilot is not engaged."), "../assets/icons/monitoring.png", + false, }, { "RecordFront", tr("Record and Upload Driver Camera"), tr("Upload data from the driver facing camera and help improve the driver monitoring algorithm."), "../assets/icons/monitoring.png", + true, }, { "IsMetric", tr("Use Metric System"), tr("Display speed in km/h instead of mph."), "../assets/icons/metric.png", + false, }, }; @@ -75,9 +82,13 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) { // set up uiState update for personality setting 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); + if (needs_restart) { + toggle->setNotifyParam("ToggleRestart"); + } + bool locked = params.getBool((param + "Lock").toStdString()); toggle->setEnabled(!locked); diff --git a/selfdrive/ui/qt/widgets/controls.h b/selfdrive/ui/qt/widgets/controls.h index 3342de5324..d88ea4e5b6 100644 --- a/selfdrive/ui/qt/widgets/controls.h +++ b/selfdrive/ui/qt/widgets/controls.h @@ -150,6 +150,10 @@ public: store_confirm = _store_confirm; } + void setNotifyParam(const QString &_notify_param) { + notify_param = _notify_param; + } + void setActiveIcon(const QString &icon) { active_icon_pixmap = QPixmap(icon).scaledToWidth(80, Qt::SmoothTransformation); } @@ -181,6 +185,7 @@ private: QPixmap active_icon_pixmap; bool confirm = false; bool store_confirm = false; + QString notify_param; }; class MultiButtonControl : public AbstractControl {