FrogPilot features - Reset toggles to default

This commit is contained in:
FrogAi 2024-07-31 19:53:23 -07:00
parent 0feeb09ced
commit cec2a9fe1f
2 changed files with 23 additions and 1 deletions

View File

@ -498,6 +498,26 @@ DevicePanel::DevicePanel(SettingsWindow *parent) : ListWidget(parent) {
});
addItem(flashPandaBtn);
// Reset toggles to default
ButtonControl *resetTogglesBtn = new ButtonControl(tr("Reset Toggles To Default"), tr("RESET"), tr("Reset your toggle settings back to their default settings."));
connect(resetTogglesBtn, &ButtonControl::clicked, [=]() {
if (ConfirmationDialog::confirm(tr("Are you sure you want to completely reset all of your toggle settings?"), tr("Reset"), this)) {
std::thread([&] {
resetTogglesBtn->setEnabled(false);
resetTogglesBtn->setValue(tr("Resetting toggles..."));
params.putBool("DoToggleReset", true);
resetTogglesBtn->setValue(tr("Reset!"));
std::this_thread::sleep_for(std::chrono::seconds(2));
resetTogglesBtn->setValue(tr("Rebooting..."));
std::this_thread::sleep_for(std::chrono::seconds(2));
Hardware::reboot();
}).detach();
}
});
addItem(resetTogglesBtn);
// Force offroad/onroad
std::vector<QString> forceStartedOptions{tr("OFFROAD"), tr("ONROAD"), tr("OFF")};
forceStartedBtn = new FrogPilotButtonsControl(tr("Force Started State"), tr("Force openpilot either offroad or onroad."), "", forceStartedOptions, true);

View File

@ -356,9 +356,11 @@ def manager_init() -> None:
# set unset params
for k, v in default_params:
if params.get(k) is None:
if params.get(k) is None or params.get_bool("DoToggleReset"):
params.put(k, v)
params.put_bool_nonblocking("DoToggleReset", False)
# Create folders needed for msgq
try:
os.mkdir("/dev/shm")