mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-18 19:53:52 +08:00
Merge remote-tracking branch 'dev/min-feat/auto-shutdown' into full
This commit is contained in:
@@ -138,4 +138,5 @@ inline static std::unordered_map<std::string, uint32_t> keys = {
|
||||
{"dp_lon_aem", PERSISTENT},
|
||||
{"dp_device_audible_alert_mode", PERSISTENT},
|
||||
{"dp_lon_no_gas_gating", PERSISTENT},
|
||||
{"dp_device_auto_shutdown_in", PERSISTENT},
|
||||
};
|
||||
|
||||
@@ -293,6 +293,8 @@ void DPPanel::add_device_toggles() {
|
||||
"",
|
||||
audible_alert_mode_texts);
|
||||
|
||||
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;
|
||||
|
||||
@@ -301,6 +303,7 @@ void DPPanel::add_device_toggles() {
|
||||
if (param.isEmpty()) {
|
||||
label = new LabelControl(title, "");
|
||||
addItem(label);
|
||||
addItem(auto_shutdown_toggle);
|
||||
continue;
|
||||
}
|
||||
if ((param == "dp_device_is_rhd" || param == "dp_device_monitoring_disabled" || param == "dp_device_beep") && !disable_driver) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -60,6 +60,7 @@ def manager_init() -> None:
|
||||
("dp_lon_aem", "0"),
|
||||
("dp_device_audible_alert_mode", "0"),
|
||||
("dp_lon_no_gas_gating", "0"),
|
||||
("dp_device_auto_shutdown_in", "-5"),
|
||||
]
|
||||
|
||||
if params.get_bool("RecordFrontLock"):
|
||||
|
||||
Reference in New Issue
Block a user