mirror of https://github.com/commaai/openpilot.git
Dev panel: disable long maneuver toggle for stock long (#34006)
* fix errors in developerPanel * clean up * clean up * need to keep track of offroad sadly --------- Co-authored-by: Shane Smiskol <shane@smiskol.com>
This commit is contained in:
parent
233dc24929
commit
87bc80d351
|
@ -3,6 +3,7 @@
|
|||
#include "selfdrive/ui/qt/offroad/developer_panel.h"
|
||||
#include "selfdrive/ui/qt/widgets/ssh_keys.h"
|
||||
#include "selfdrive/ui/qt/widgets/controls.h"
|
||||
#include "common/util.h"
|
||||
|
||||
DeveloperPanel::DeveloperPanel(SettingsWindow *parent) : ListWidget(parent) {
|
||||
// SSH keys
|
||||
|
@ -24,13 +25,32 @@ DeveloperPanel::DeveloperPanel(SettingsWindow *parent) : ListWidget(parent) {
|
|||
addItem(longManeuverToggle);
|
||||
|
||||
// Joystick and longitudinal maneuvers should be hidden on release branches
|
||||
// also the toggles should be not available to change in onroad state
|
||||
const bool is_release = params.getBool("IsReleaseBranch");
|
||||
QObject::connect(uiState(), &UIState::offroadTransition, [=](bool offroad) {
|
||||
for (auto btn : findChildren<ParamControl *>()) {
|
||||
btn->setVisible(!is_release);
|
||||
btn->setEnabled(offroad);
|
||||
}
|
||||
});
|
||||
is_release = params.getBool("IsReleaseBranch");
|
||||
|
||||
// Toggles should be not available to change in onroad state
|
||||
QObject::connect(uiState(), &UIState::offroadTransition, this, &DeveloperPanel::updateToggles);
|
||||
}
|
||||
|
||||
void DeveloperPanel::updateToggles(bool _offroad) {
|
||||
for (auto btn : findChildren<ParamControl *>()) {
|
||||
btn->setVisible(!is_release);
|
||||
btn->setEnabled(_offroad);
|
||||
}
|
||||
|
||||
// longManeuverToggle should not be toggleable if the car don't have longitudinal control
|
||||
auto cp_bytes = params.get("CarParamsPersistent");
|
||||
if (!cp_bytes.empty()) {
|
||||
AlignedBuffer aligned_buf;
|
||||
capnp::FlatArrayMessageReader cmsg(aligned_buf.align(cp_bytes.data(), cp_bytes.size()));
|
||||
cereal::CarParams::Reader CP = cmsg.getRoot<cereal::CarParams>();
|
||||
longManeuverToggle->setEnabled(hasLongitudinalControl(CP) && _offroad);
|
||||
} else {
|
||||
longManeuverToggle->setEnabled(false);
|
||||
}
|
||||
|
||||
offroad = _offroad;
|
||||
}
|
||||
|
||||
void DeveloperPanel::showEvent(QShowEvent *event) {
|
||||
updateToggles(offroad);
|
||||
}
|
||||
|
|
|
@ -6,9 +6,15 @@ class DeveloperPanel : public ListWidget {
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit DeveloperPanel(SettingsWindow *parent);
|
||||
void showEvent(QShowEvent *event) override;
|
||||
|
||||
private:
|
||||
Params params;
|
||||
ParamControl* joystickToggle;
|
||||
ParamControl* longManeuverToggle;
|
||||
bool is_release;
|
||||
bool offroad;
|
||||
|
||||
private slots:
|
||||
void updateToggles(bool _offroad);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue