"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:
FrogAi
2024-02-27 16:34:47 -07:00
parent 506cbb87e8
commit 6907410750
9 changed files with 50 additions and 3 deletions

View File

@@ -26,6 +26,7 @@ public:
}
static void reboot() {}
static void soft_reboot() {}
static void poweroff() {}
static void set_brightness(int percent) {}
static void set_display_power(bool on) {}

View File

@@ -30,6 +30,10 @@ class HardwareBase(ABC):
def reboot(self, reason=None):
pass
@abstractmethod
def soft_reboot(self):
pass
@abstractmethod
def uninstall(self):
pass

View File

@@ -19,6 +19,9 @@ class Pc(HardwareBase):
def reboot(self, reason=None):
print("REBOOT!")
def soft_reboot(self):
print("SOFT REBOOT!")
def uninstall(self):
print("uninstall")

View File

@@ -50,6 +50,13 @@ public:
}
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 set_brightness(int percent) {
std::string max = util::read_file("/sys/class/backlight/panel0-backlight/max_brightness");

View File

@@ -134,6 +134,14 @@ class Tici(HardwareBase):
def reboot(self, reason=None):
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):
Path("/data/__system_reset__").touch()
os.sync()