From 10d5832da6218fc83888886c82f09af49c0374aa Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 27 May 2025 16:38:23 -0700 Subject: [PATCH] disable while engaged --- selfdrive/ui/qt/offroad/settings.cc | 4 ++++ selfdrive/ui/ui.cc | 5 +++++ selfdrive/ui/ui.h | 2 ++ 3 files changed, 11 insertions(+) diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index 3cd7a25291..e2a707b9de 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -86,6 +86,10 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) { auto toggle = new ParamControl(param, title, desc, icon, this); if (needs_restart) { + QObject::connect(uiState(), &UIState::engagedChanged, [toggle](bool engaged) { + toggle.setEnabled(!engaged); + }); + QObject::connect(toggle, &ParamControl::toggleFlipped, [=](bool state) { qDebug() << "put OnroadCycleRequested bool"; params.putBool("OnroadCycleRequested", true); diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index ec3d40961d..f048a9698d 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -78,6 +78,11 @@ void UIState::updateStatus() { } } + if (scene.engaged() != engaged_prev) { + engaged_prev = scene.engaged(); + emit engagedChanged(scene.engaged()); + } + // Handle onroad/offroad transition if (scene.started != started_prev || sm->frame == 1) { if (scene.started) { diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 6ff67cacde..fd2aee771e 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -81,6 +81,7 @@ public: signals: void uiUpdate(const UIState &s); void offroadTransition(bool offroad); + void engagedChanged(bool engaged); private slots: void update(); @@ -88,6 +89,7 @@ private slots: private: QTimer *timer; bool started_prev = false; + bool engaged_prev = false; }; UIState *uiState();