From bfb02ca7f91e0374c5374b181ddb2657d20daf63 Mon Sep 17 00:00:00 2001 From: DevTekVE Date: Sat, 2 Dec 2023 13:13:40 +0100 Subject: [PATCH] Add connection to ExperimentalMode toggle This change introduces a connection to the "ExperimentalMode" toggle in the settings.cc file. Whenever the toggle state is flipped, the `updateToggles()` function will be called, maintaining the consistency of toggle update behavior across different settings. Update dec_toggle enablement criteria The changes in the code modified the condition for enabling the dec_toggle. Instead of relying on the status of custom_stock_long_planner, dec_toggle will now depend on the toggle status of experimental_mode_toggle. This will ensure the dec_toggle is only enabled when the experimental mode is active. Enable dec_toggle based on custom_stock_long_planner status The dec_toggle in the selfdrive user interface now mirrors the enabled status of the custom_stock_long_planner. Whenever the stock long planner toggle is switched, it will automatically enable or disable the dec_toggle. update also experiemental to disable if no custom stock with planner speed Update CustomStockLongPlanner settings interface The interface for the CustomStockLongPlanner function has been updated to improve usability. A new connection to "toggleFlipped" signal was added, allowing real-time settings update. The planner is also now enabled when the long_personality_setting is toggled on. Additionally, the refresh function call for the planner has been added to ensure correct display of current settings. However, the removal of "ExperimentalMode" is now conditional, taking place only if the planner is not toggled on. --- selfdrive/ui/qt/offroad/settings.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index ad9685a65e..7c821c8d28 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -157,7 +157,13 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) { connect(toggles["CustomStockLong"], &ToggleControl::toggleFlipped, [=]() { updateToggles(); }); - + connect(toggles["CustomStockLongPlanner"], &ToggleControl::toggleFlipped, [=]() { + updateToggles(); + }); + connect(toggles["ExperimentalMode"], &ToggleControl::toggleFlipped, [=]() { + updateToggles(); + }); + param_watcher = new ParamWatcher(this); QObject::connect(param_watcher, &ParamWatcher::paramChanged, [=](const QString ¶m_name, const QString ¶m_value) { @@ -234,12 +240,15 @@ void TogglesPanel::updateToggles() { dec_toggle->setEnabled(true); } else if (custom_stock_long_toggle->isToggled()) { op_long_toggle->setEnabled(false); - experimental_mode_toggle->setEnabled(true); + experimental_mode_toggle->setEnabled(custom_stock_long_planner->isToggled()); experimental_mode_toggle->setDescription(e2e_description); - long_personality_setting->setEnabled(false); custom_stock_long_planner->setEnabled(true); + long_personality_setting->setEnabled(custom_stock_long_planner->isToggled()); + dec_toggle->setEnabled(experimental_mode_toggle->isToggled()); + if(!custom_stock_long_planner->isToggled()) { + params.remove("ExperimentalMode"); + } params.remove("ExperimentalLongitudinalEnabled"); - params.remove("ExperimentalMode"); } else { // no long for now experimental_mode_toggle->setEnabled(false); @@ -269,6 +278,7 @@ void TogglesPanel::updateToggles() { experimental_mode_toggle->refresh(); op_long_toggle->refresh(); custom_stock_long_toggle->refresh(); + custom_stock_long_planner->refresh(); dec_toggle->refresh(); } else { experimental_mode_toggle->setDescription(e2e_description);