offroad only

This commit is contained in:
royjr
2025-07-30 23:55:40 -04:00
parent f26c39b754
commit 44b44a48a9
2 changed files with 12 additions and 2 deletions
@@ -16,6 +16,7 @@
#include "common/params.h"
#include "selfdrive/ui/qt/api.h"
#include "selfdrive/ui/qt/widgets/input.h"
#include "selfdrive/ui/sunnypilot/ui.h"
ExternalStorageControl::ExternalStorageControl() :
ButtonControl(tr("External Storage"), "", tr("Extend your comma device's storage by inserting a USB drive into the aux port.")) {
@@ -31,9 +32,17 @@ ExternalStorageControl::ExternalStorageControl() :
}
}
});
QObject::connect(uiState(), &UIState::offroadTransition, this, &ExternalStorageControl::updateState);
updateState(!uiState()->scene.started);
refresh();
}
void ExternalStorageControl::updateState(bool offroad) {
setEnabled(offroad);
}
void ExternalStorageControl::debouncedRefresh() {
if (refreshPending) return;
refreshPending = true;
@@ -85,7 +94,7 @@ void ExternalStorageControl::refresh() {
setValue("drive detected");
setText(tr("MOUNT"));
}
setEnabled(true);
updateState(!uiState()->scene.started);
}
}, Qt::QueuedConnection);
});
@@ -146,7 +155,7 @@ void ExternalStorageControl::formatStorage() {
mountStorage();
} else {
setValue(tr("needs format"));
setEnabled(true);
updateState(!uiState()->scene.started);
}
});
process->start("sh", QStringList() << "-c" << "sudo mkfs.ext4 -F /dev/sdg1");
@@ -25,6 +25,7 @@ private:
bool refreshPending = false;
bool formatting = false;
void updateState(bool offroad);
void refresh();
void debouncedRefresh();
void mountStorage();