"Soft" reboot button
Add function to perform a "soft" reboot for quicker reboots. Co-Authored-By: CHaucke89 <132518562+chaucke89@users.noreply.github.com>
This commit is contained in:
@@ -258,6 +258,7 @@ std::unordered_map<std::string, uint32_t> keys = {
|
|||||||
{"DisableOnroadUploads", PERSISTENT},
|
{"DisableOnroadUploads", PERSISTENT},
|
||||||
{"DisableOpenpilotLongitudinal", PERSISTENT},
|
{"DisableOpenpilotLongitudinal", PERSISTENT},
|
||||||
{"DisengageVolume", PERSISTENT},
|
{"DisengageVolume", PERSISTENT},
|
||||||
|
{"DoSoftReboot", CLEAR_ON_MANAGER_START},
|
||||||
{"DragonPilotTune", PERSISTENT},
|
{"DragonPilotTune", PERSISTENT},
|
||||||
{"DriverCamera", PERSISTENT},
|
{"DriverCamera", PERSISTENT},
|
||||||
{"DriveStats", PERSISTENT},
|
{"DriveStats", PERSISTENT},
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ def manager_thread() -> None:
|
|||||||
|
|
||||||
# Exit main loop when uninstall/shutdown/reboot is needed
|
# Exit main loop when uninstall/shutdown/reboot is needed
|
||||||
shutdown = False
|
shutdown = False
|
||||||
for param in ("DoUninstall", "DoShutdown", "DoReboot"):
|
for param in ("DoUninstall", "DoShutdown", "DoReboot", "DoSoftReboot"):
|
||||||
if params.get_bool(param):
|
if params.get_bool(param):
|
||||||
shutdown = True
|
shutdown = True
|
||||||
params.put("LastManagerExitReason", f"{param} {datetime.datetime.now()}")
|
params.put("LastManagerExitReason", f"{param} {datetime.datetime.now()}")
|
||||||
@@ -491,6 +491,9 @@ def main() -> None:
|
|||||||
if params.get_bool("DoUninstall"):
|
if params.get_bool("DoUninstall"):
|
||||||
cloudlog.warning("uninstalling")
|
cloudlog.warning("uninstalling")
|
||||||
HARDWARE.uninstall()
|
HARDWARE.uninstall()
|
||||||
|
elif params.get_bool("DoSoftReboot"):
|
||||||
|
cloudlog.warning("softreboot")
|
||||||
|
HARDWARE.soft_reboot()
|
||||||
elif params.get_bool("DoReboot"):
|
elif params.get_bool("DoReboot"):
|
||||||
cloudlog.warning("reboot")
|
cloudlog.warning("reboot")
|
||||||
HARDWARE.reboot()
|
HARDWARE.reboot()
|
||||||
|
|||||||
@@ -507,6 +507,11 @@ DevicePanel::DevicePanel(SettingsWindow *parent) : ListWidget(parent) {
|
|||||||
power_layout->addWidget(reboot_btn);
|
power_layout->addWidget(reboot_btn);
|
||||||
QObject::connect(reboot_btn, &QPushButton::clicked, this, &DevicePanel::reboot);
|
QObject::connect(reboot_btn, &QPushButton::clicked, this, &DevicePanel::reboot);
|
||||||
|
|
||||||
|
QPushButton *softreboot_btn = new QPushButton(tr("Soft Reboot"));
|
||||||
|
softreboot_btn->setObjectName("softreboot_btn");
|
||||||
|
power_layout->addWidget(softreboot_btn);
|
||||||
|
QObject::connect(softreboot_btn, &QPushButton::clicked, this, &DevicePanel::softreboot);
|
||||||
|
|
||||||
QPushButton *poweroff_btn = new QPushButton(tr("Power Off"));
|
QPushButton *poweroff_btn = new QPushButton(tr("Power Off"));
|
||||||
poweroff_btn->setObjectName("poweroff_btn");
|
poweroff_btn->setObjectName("poweroff_btn");
|
||||||
power_layout->addWidget(poweroff_btn);
|
power_layout->addWidget(poweroff_btn);
|
||||||
@@ -517,8 +522,10 @@ DevicePanel::DevicePanel(SettingsWindow *parent) : ListWidget(parent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setStyleSheet(R"(
|
setStyleSheet(R"(
|
||||||
#reboot_btn { height: 120px; border-radius: 15px; background-color: #393939; }
|
#softreboot_btn { height: 120px; border-radius: 15px; background-color: #e2e22c; }
|
||||||
#reboot_btn:pressed { background-color: #4a4a4a; }
|
#softreboot_btn:pressed { background-color: #ffe224; }
|
||||||
|
#reboot_btn { height: 120px; border-radius: 15px; background-color: #e2872c; }
|
||||||
|
#reboot_btn:pressed { background-color: #ff9724; }
|
||||||
#poweroff_btn { height: 120px; border-radius: 15px; background-color: #E22C2C; }
|
#poweroff_btn { height: 120px; border-radius: 15px; background-color: #E22C2C; }
|
||||||
#poweroff_btn:pressed { background-color: #FF2424; }
|
#poweroff_btn:pressed { background-color: #FF2424; }
|
||||||
)");
|
)");
|
||||||
@@ -562,6 +569,18 @@ void DevicePanel::reboot() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DevicePanel::softreboot() {
|
||||||
|
if (!uiState()->engaged()) {
|
||||||
|
if (ConfirmationDialog::confirm(tr("Are you sure you want to soft reboot?"), tr("Soft Reboot"), this)) {
|
||||||
|
if (!uiState()->engaged()) {
|
||||||
|
params.putBool("DoSoftReboot", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ConfirmationDialog::alert(tr("Disengage to Soft Reboot"), this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DevicePanel::poweroff() {
|
void DevicePanel::poweroff() {
|
||||||
if (!uiState()->engaged()) {
|
if (!uiState()->engaged()) {
|
||||||
if (ConfirmationDialog::confirm(tr("Are you sure you want to power off?"), tr("Power Off"), this)) {
|
if (ConfirmationDialog::confirm(tr("Are you sure you want to power off?"), tr("Power Off"), this)) {
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ signals:
|
|||||||
private slots:
|
private slots:
|
||||||
void poweroff();
|
void poweroff();
|
||||||
void reboot();
|
void reboot();
|
||||||
|
void softreboot();
|
||||||
void updateCalibDescription();
|
void updateCalibDescription();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void reboot() {}
|
static void reboot() {}
|
||||||
|
static void soft_reboot() {}
|
||||||
static void poweroff() {}
|
static void poweroff() {}
|
||||||
static void set_brightness(int percent) {}
|
static void set_brightness(int percent) {}
|
||||||
static void set_display_power(bool on) {}
|
static void set_display_power(bool on) {}
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ class HardwareBase(ABC):
|
|||||||
def reboot(self, reason=None):
|
def reboot(self, reason=None):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def soft_reboot(self):
|
||||||
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def uninstall(self):
|
def uninstall(self):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ class Pc(HardwareBase):
|
|||||||
def reboot(self, reason=None):
|
def reboot(self, reason=None):
|
||||||
print("REBOOT!")
|
print("REBOOT!")
|
||||||
|
|
||||||
|
def soft_reboot(self):
|
||||||
|
print("SOFT REBOOT!")
|
||||||
|
|
||||||
def uninstall(self):
|
def uninstall(self):
|
||||||
print("uninstall")
|
print("uninstall")
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void reboot() { std::system("sudo reboot"); }
|
static void reboot() { std::system("sudo reboot"); }
|
||||||
|
static void soft_reboot() {
|
||||||
|
std::system("echo 894000.i2c | sudo tee /sys/bus/platform/drivers/i2c_geni/unbind");
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
|
std::system("echo 894000.i2c | sudo tee /sys/bus/platform/drivers/i2c_geni/bind");
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
|
std::system("sudo systemctl restart comma");
|
||||||
|
}
|
||||||
static void poweroff() { std::system("sudo poweroff"); }
|
static void poweroff() { std::system("sudo poweroff"); }
|
||||||
static void set_brightness(int percent) {
|
static void set_brightness(int percent) {
|
||||||
std::string max = util::read_file("/sys/class/backlight/panel0-backlight/max_brightness");
|
std::string max = util::read_file("/sys/class/backlight/panel0-backlight/max_brightness");
|
||||||
|
|||||||
@@ -134,6 +134,14 @@ class Tici(HardwareBase):
|
|||||||
def reboot(self, reason=None):
|
def reboot(self, reason=None):
|
||||||
subprocess.check_output(["sudo", "reboot"])
|
subprocess.check_output(["sudo", "reboot"])
|
||||||
|
|
||||||
|
def soft_reboot(self):
|
||||||
|
# Reload the touchscreen driver to reset touch_count and avoid triggering a system reset prompt
|
||||||
|
sudo_write("894000.i2c", "/sys/bus/platform/drivers/i2c_geni/unbind")
|
||||||
|
time.sleep(0.5)
|
||||||
|
sudo_write("894000.i2c", "/sys/bus/platform/drivers/i2c_geni/bind")
|
||||||
|
time.sleep(0.5)
|
||||||
|
os.system("sudo systemctl restart comma")
|
||||||
|
|
||||||
def uninstall(self):
|
def uninstall(self):
|
||||||
Path("/data/__system_reset__").touch()
|
Path("/data/__system_reset__").touch()
|
||||||
os.sync()
|
os.sync()
|
||||||
|
|||||||
Reference in New Issue
Block a user