Auto Shutdown - 2025/05/15

This commit is contained in:
Rick Lan
2025-04-30 09:55:04 +08:00
parent c7b91221ff
commit df4614e585
4 changed files with 9 additions and 0 deletions
+1
View File
@@ -119,4 +119,5 @@ inline static std::unordered_map<std::string, uint32_t> keys = {
{"Version", PERSISTENT},
{"dp_device_last_log", CLEAR_ON_MANAGER_START},
{"dp_device_reset_conf", CLEAR_ON_MANAGER_START},
{"dp_device_auto_shutdown_in", PERSISTENT},
};
+3
View File
@@ -207,6 +207,8 @@ void DPPanel::add_device_toggles() {
},
};
auto auto_shutdown_toggle = new ParamSpinBoxControl("dp_device_auto_shutdown_in", tr("Auto Shutdown In:"), tr("0 mins = Immediately"), "", -5, 300, 5, tr(" mins"), tr("Off"));
QWidget *label = nullptr;
bool has_toggle = false;
@@ -214,6 +216,7 @@ void DPPanel::add_device_toggles() {
if (param.isEmpty()) {
label = new LabelControl(title, "");
addItem(label);
addItem(auto_shutdown_toggle);
continue;
}
+4
View File
@@ -28,6 +28,8 @@ class PowerMonitoring:
self.car_voltage_mV = 12e3 # Low-passed version of peripheralState voltage
self.car_voltage_instant_mV = 12e3 # Last value of peripheralState voltage
self.integration_lock = threading.Lock()
self.dp_device_auto_shutdown_in = int(self.params.get("dp_device_auto_shutdown_in") or -5) * 60
self.dp_device_auto_shutdown = self.dp_device_auto_shutdown_in >= 0
car_battery_capacity_uWh = self.params.get("CarBatteryCapacity")
if car_battery_capacity_uWh is None:
@@ -114,6 +116,8 @@ class PowerMonitoring:
now = time.monotonic()
should_shutdown = False
offroad_time = (now - offroad_timestamp)
if started_seen and self.dp_device_auto_shutdown and offroad_time > self.dp_device_auto_shutdown_in:
return True
low_voltage_shutdown = (self.car_voltage_mV < (VBATT_PAUSE_CHARGING * 1e3) and
offroad_time > VOLTAGE_SHUTDOWN_MIN_OFFROAD_TIME_S)
should_shutdown |= offroad_time > MAX_TIME_OFFROAD_S
+1
View File
@@ -41,6 +41,7 @@ def manager_init() -> None:
("OpenpilotEnabledToggle", "1"),
("LongitudinalPersonality", str(log.LongitudinalPersonality.standard)),
("DisableLogging", "0"),
("dp_device_auto_shutdown_in", "-5"),
]
if params.get_bool("RecordFrontLock"):