From cf0c41af965dec3ef390ef420f56bc6be4b31a88 Mon Sep 17 00:00:00 2001 From: royjr Date: Sun, 30 Aug 2026 21:29:28 -0400 Subject: [PATCH] AuxPowerSave --- openpilot/common/params_keys.h | 1 + openpilot/sunnypilot/sunnylink/settings_ui.json | 6 ++++++ .../sunnylink/settings_ui_src/pages/device.yaml | 4 ++++ openpilot/system/hardware/hardwared.py | 8 +++++++- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/openpilot/common/params_keys.h b/openpilot/common/params_keys.h index 3c5f30ab3d..6b6328df58 100644 --- a/openpilot/common/params_keys.h +++ b/openpilot/common/params_keys.h @@ -132,6 +132,7 @@ inline static std::unordered_map keys = { {"UptimeOnroad", {PERSISTENT, FLOAT, "0.0"}}, {"ChestnutActive", {CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION | CLEAR_ON_IGNITION_ON, BOOL}}, {"ChestnutLoading", {CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION | CLEAR_ON_IGNITION_ON, BOOL}}, + {"AuxPowerSave", {PERSISTENT | BACKUP, BOOL}}, {"Version", {PERSISTENT, STRING}}, // --- sunnypilot params --- // diff --git a/openpilot/sunnypilot/sunnylink/settings_ui.json b/openpilot/sunnypilot/sunnylink/settings_ui.json index 63bf342fcb..f0cbc07837 100644 --- a/openpilot/sunnypilot/sunnylink/settings_ui.json +++ b/openpilot/sunnypilot/sunnylink/settings_ui.json @@ -1675,6 +1675,12 @@ "widget": "toggle", "title": "Onroad Uploads" }, + { + "key": "AuxPowerSave", + "widget": "toggle", + "title": "Disable Aux Port When Offroad", + "description": "Power off the aux USB-C port while offroad to save power. It powers back on automatically when you go onroad." + }, { "key": "MaxTimeOffroad", "widget": "option", diff --git a/openpilot/sunnypilot/sunnylink/settings_ui_src/pages/device.yaml b/openpilot/sunnypilot/sunnylink/settings_ui_src/pages/device.yaml index bf5f7883ab..d519a1f9b9 100644 --- a/openpilot/sunnypilot/sunnylink/settings_ui_src/pages/device.yaml +++ b/openpilot/sunnypilot/sunnylink/settings_ui_src/pages/device.yaml @@ -30,6 +30,10 @@ sections: - key: OnroadUploads widget: toggle title: Onroad Uploads + - key: AuxPowerSave + widget: toggle + title: Disable Aux Port When Offroad + description: Power off the aux USB-C port while offroad to save power. It powers back on automatically when you go onroad. - key: MaxTimeOffroad widget: option title: Max Time Offroad diff --git a/openpilot/system/hardware/hardwared.py b/openpilot/system/hardware/hardwared.py index 0b293941c8..e6e8486a1e 100755 --- a/openpilot/system/hardware/hardwared.py +++ b/openpilot/system/hardware/hardwared.py @@ -51,6 +51,9 @@ class Chestnut: self.last_attempt = 0. self.flashed = False self.vbus_on = None + self.params = Params() + self.powersave = False + self.last_offroad = None def flash(self) -> None: ret = subprocess.run(["sudo", sys.executable, os.path.join(BASEDIR, "openpilot/system/hardware/chestnut/flash.py"), CHESTNUT_FW_VERSION], @@ -67,7 +70,10 @@ class Chestnut: def update(self, offroad: bool, usb_state: list[dict]) -> None: mismatch = any((d["vendorId"], d["productId"]) in CHESTNUT_USB_IDS + CHESTNUT_ROM_USB_IDS and d["product"] != f"custom {CHESTNUT_FW_VERSION}-CLEAN" for d in usb_state) - self.set_vbus(not offroad or mismatch) + if offroad != self.last_offroad: + self.powersave = self.params.get_bool("AuxPowerSave") + self.last_offroad = offroad + self.set_vbus((not offroad or mismatch) or not self.powersave) if not mismatch: self.flashed = False return