mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-03-02 21:53:53 +08:00
Merge branch 'min-feat/on-off-road' into full
This commit is contained in:
@@ -128,4 +128,5 @@ inline static std::unordered_map<std::string, uint32_t> keys = {
|
||||
{"dp_device_model_list", PERSISTENT},
|
||||
{"dp_lat_lca_speed", PERSISTENT},
|
||||
{"dp_lat_lca_auto_sec", PERSISTENT},
|
||||
{"dp_device_go_off_road", CLEAR_ON_MANAGER_START},
|
||||
};
|
||||
|
||||
@@ -92,6 +92,7 @@ private:
|
||||
QLabel *onroadLbl;
|
||||
LabelControl *versionLbl;
|
||||
ButtonControl *installBtn;
|
||||
ButtonControl *onOffRoadBtn;
|
||||
ButtonControl *downloadBtn;
|
||||
ButtonControl *targetBranchBtn;
|
||||
|
||||
|
||||
@@ -29,6 +29,16 @@ SoftwarePanel::SoftwarePanel(QWidget* parent) : ListWidget(parent) {
|
||||
versionLbl = new LabelControl(tr("Current Version"), "");
|
||||
addItem(versionLbl);
|
||||
|
||||
// on/off road mode switch
|
||||
onOffRoadBtn = new ButtonControl(tr("Onroad/Offroad Mode"), tr("Go Offroad"));
|
||||
connect(onOffRoadBtn, &ButtonControl::clicked, [&]() {
|
||||
if (ConfirmationDialog::confirm(tr("Are you sure you want to switch mode?"), tr("CONFIRM"), this)) {
|
||||
bool val = params.getBool("dp_device_go_off_road");
|
||||
params.putBool("dp_device_go_off_road", !val);
|
||||
}
|
||||
});
|
||||
addItem(onOffRoadBtn);
|
||||
|
||||
// download update btn
|
||||
downloadBtn = new ButtonControl(tr("Download"), tr("CHECK"));
|
||||
connect(downloadBtn, &ButtonControl::clicked, [=]() {
|
||||
@@ -111,6 +121,7 @@ void SoftwarePanel::updateLabels() {
|
||||
fs_watch->addParam("UpdateFailedCount");
|
||||
fs_watch->addParam("UpdaterState");
|
||||
fs_watch->addParam("UpdateAvailable");
|
||||
fs_watch->addParam("dp_device_go_off_road");
|
||||
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
@@ -120,6 +131,13 @@ void SoftwarePanel::updateLabels() {
|
||||
onroadLbl->setVisible(is_onroad);
|
||||
downloadBtn->setVisible(!is_onroad);
|
||||
|
||||
// on/off road text change
|
||||
if (params.getBool("dp_device_go_off_road")) {
|
||||
onOffRoadBtn->setText(tr("Go Onroad"));
|
||||
} else {
|
||||
onOffRoadBtn->setText(tr("Go Offroad"));
|
||||
}
|
||||
|
||||
// download update
|
||||
QString updater_state = QString::fromStdString(params.get("UpdaterState"));
|
||||
bool failed = std::atoi(params.get("UpdateFailedCount").c_str()) > 0;
|
||||
|
||||
@@ -204,6 +204,8 @@ def hardware_thread(end_event, hw_queue) -> None:
|
||||
|
||||
fan_controller = None
|
||||
|
||||
dp_device_go_off_road = False
|
||||
|
||||
while not end_event.is_set():
|
||||
sm.update(PANDA_STATES_TIMEOUT)
|
||||
|
||||
@@ -333,7 +335,9 @@ def hardware_thread(end_event, hw_queue) -> None:
|
||||
pass
|
||||
|
||||
# Handle offroad/onroad transition
|
||||
should_start = all(onroad_conditions.values())
|
||||
if count % 6 == 0:
|
||||
dp_device_go_off_road = params.get_bool("dp_device_go_off_road")
|
||||
should_start = not dp_device_go_off_road and all(onroad_conditions.values())
|
||||
if started_ts is None:
|
||||
should_start = should_start and all(startup_conditions.values())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user