device auto shutdown toggle

This commit is contained in:
Rick Lan
2024-07-13 17:58:45 +08:00
parent c6405f75a7
commit e7f90ef2c0
4 changed files with 13 additions and 1 deletions
+2 -1
View File
@@ -2,11 +2,12 @@ dragonpilot [latest]
=======================
* Up to comma.ai openpilot master branch commit 01c2174d5968266b87f1d1fecefce5affaeaa624 (2024-07-02)
* DP HIGHLIGHT:
* (TESTING )Tē-Tôo / Map Module
* (TESTING) Tē-Tôo / Map Module
* Road Name Display (Online OpenStreetMap)
* Speed Camera Warning (Online OpenstreetMap: Untested)
* Dedicated Speed Camera Warning (Taiwan)
* Dynamic End-to-End w/ Toggleable Road Condition Detection.
* Device Auto Shutdown Toggle.
dragonpilot [2024.07.01]
=======================
+2
View File
@@ -243,6 +243,8 @@ std::unordered_map<std::string, uint32_t> keys = {
{"dp_tetoo_speed_camera_taiwan", PERSISTENT},
{"dp_tetoo_speed_camera_threshold", PERSISTENT},
{"dp_long_de2e_road_condition", PERSISTENT},
{"dp_device_auto_shutdown", PERSISTENT},
{"dp_device_auto_shutdown_in", PERSISTENT},
};
} // namespace
+7
View File
@@ -36,6 +36,9 @@ class PowerMonitoring:
# Reset capacity if it's low
self.car_battery_capacity_uWh = max((CAR_BATTERY_CAPACITY_uWh / 10), int(car_battery_capacity_uWh))
self.dp_device_auto_shutdown = self.params.get_bool("dp_device_auto_shutdown")
self.dp_device_auto_shutdown_in = int(self.params.get("dp_device_auto_shutdown_in")) * 60
# Calculation tick
def calculate(self, voltage: int | None, ignition: bool):
try:
@@ -114,6 +117,10 @@ 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
+2
View File
@@ -81,6 +81,8 @@ def manager_init() -> None:
("dp_tetoo_speed_camera_taiwan", "0"),
("dp_tetoo_speed_camera_threshold", "0"),
("dp_long_de2e_road_condition", "1"), # on by default, depends on dp_long_de2e
("dp_device_auto_shutdown", "0"),
("dp_device_auto_shutdown_in", "30"),
]
if not PC:
default_params.append(("LastUpdateTime", datetime.datetime.now(datetime.UTC).replace(tzinfo=None).isoformat().encode('utf8')))