Onroad/Offroad Button

Co-authored-by: 錢羅城
This commit is contained in:
Rick Lan
2024-06-29 11:30:38 +08:00
parent c040752793
commit 128a859fd1
4 changed files with 22 additions and 1 deletions
+1
View File
@@ -235,6 +235,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"dp_device_dm_unavailable", PERSISTENT},
{"dp_toyota_enhanced_bsm", PERSISTENT},
{"dp_toyota_auto_brake_hold", PERSISTENT},
{"dp_device_offroad", CLEAR_ON_MANAGER_START},
};
} // namespace
+2
View File
@@ -95,6 +95,8 @@ private:
ButtonControl *installBtn;
ButtonControl *downloadBtn;
ButtonControl *targetBranchBtn;
// dp
ButtonControl *onOffBtn;
Params params;
ParamWatcher *fs_watch;
@@ -29,6 +29,16 @@ SoftwarePanel::SoftwarePanel(QWidget* parent) : ListWidget(parent) {
versionLbl = new LabelControl(tr("Current Version"), "");
addItem(versionLbl);
// dp on/off btn
onOffBtn = new ButtonControl(tr("Onroad/Offroad Mode"), tr("Go Offroad"));
connect(onOffBtn, &ButtonControl::clicked, [&]() {
if (ConfirmationDialog::confirm(tr("Are you sure you want to switch driving mode?"), tr("CONFIRM"), this)) {
bool val = params.getBool("dp_device_offroad");
params.putBool("dp_device_offroad", !val);
}
});
addItem(onOffBtn);
// download update btn
downloadBtn = new ButtonControl(tr("Download"), tr("CHECK"));
connect(downloadBtn, &ButtonControl::clicked, [=]() {
@@ -109,11 +119,19 @@ void SoftwarePanel::updateLabels() {
fs_watch->addParam("UpdateFailedCount");
fs_watch->addParam("UpdaterState");
fs_watch->addParam("UpdateAvailable");
fs_watch->addParam("dp_device_offroad");
if (!isVisible()) {
return;
}
// dp on/off btn
if (params.getBool("dp_device_offroad")) {
onOffBtn->setText(tr("Go Onroad"));
} else {
onOffBtn->setText(tr("Go Offroad"));
}
// updater only runs offroad
onroadLbl->setVisible(is_onroad);
downloadBtn->setVisible(!is_onroad);
+1 -1
View File
@@ -338,7 +338,7 @@ def hardware_thread(end_event, hw_queue) -> None:
pass
# Handle offroad/onroad transition
should_start = all(onroad_conditions.values())
should_start = not params.get_bool("dp_device_offroad") and all(onroad_conditions.values())
if started_ts is None:
should_start = should_start and all(startup_conditions.values())