mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-26 16:32:06 +08:00
cy: patch no_offroad_fix for autoshutdown
Signed-off-by: Comma Device <device@comma.ai>
This commit is contained in:
@@ -125,6 +125,7 @@ confs = [
|
||||
{'name': 'dp_nav_amap_key_2', 'default': '', 'type': 'Text', 'conf_type': ['param']},
|
||||
{'name': 'dp_nav_style_day', 'default': 'mapbox://styles/rav4kumar/ckv7dtfba6oik15r0w8dh1c1q', 'type': 'Text', 'conf_type': ['param']},
|
||||
{'name': 'dp_nav_style_night', 'default': 'mapbox://styles/rav4kumar/ckvsf3f4u0zb414tcz9vof5jc', 'type': 'Text', 'conf_type': ['param']},
|
||||
{'name': 'dp_no_offroad_fix', 'default': False, 'type': 'Bool', 'conf_type': ['param']},
|
||||
]
|
||||
|
||||
# from 0.8.9 to 0.8.10
|
||||
|
||||
@@ -299,6 +299,7 @@ std::unordered_map<std::string, uint32_t> keys = {
|
||||
{"dp_nav_amap_key_2", PERSISTENT},
|
||||
{"dp_nav_style_day", PERSISTENT},
|
||||
{"dp_nav_style_night", PERSISTENT},
|
||||
{"dp_no_offroad_fix", PERSISTENT},
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -251,6 +251,7 @@ def thermald_thread():
|
||||
params.put_bool("BootedOnroad", True)
|
||||
|
||||
# dp
|
||||
peripheralStateLast = None
|
||||
dp_no_batt = params.get_bool("dp_no_batt")
|
||||
dp_temp_monitor = True
|
||||
dp_last_modified_temp_monitor = None
|
||||
@@ -268,6 +269,7 @@ def thermald_thread():
|
||||
last_modified = None
|
||||
last_modified_check = None
|
||||
|
||||
dp_no_offroad_fix = params.get_bool('dp_no_offroad_fix')
|
||||
if JETSON:
|
||||
handle_fan = handle_fan_jetson
|
||||
|
||||
@@ -469,6 +471,9 @@ def thermald_thread():
|
||||
|
||||
# Handle offroad/onroad transition
|
||||
should_start = all(startup_conditions.values())
|
||||
# dp - check usb_present to fix not going offroad on "EON/LEON + battery - Comma Power"
|
||||
if dp_no_offroad_fix:
|
||||
should_start = should_start and HARDWARE.get_usb_present()
|
||||
if should_start != should_start_prev or (count == 0):
|
||||
params.put_bool("IsOnroad", should_start)
|
||||
params.put_bool("IsOffroad", not should_start)
|
||||
@@ -496,6 +501,14 @@ def thermald_thread():
|
||||
# Check if we need to disable charging (handled by boardd)
|
||||
msg.deviceState.chargingDisabled = power_monitor.should_disable_charging(startup_conditions["ignition"], in_car, off_ts, dp_auto_shutdown, dp_auto_shutdown_in)
|
||||
|
||||
# dp - for battery powered device
|
||||
# when peripheralState is not changing (panda offline), and usb is not present (not charging)
|
||||
if dp_no_offroad_fix and (peripheralStateLast == peripheralState) and not msg.deviceState.usbOnline:
|
||||
if (sec_since_boot() - off_ts) > dp_auto_shutdown_in * 60:
|
||||
time.sleep(10)
|
||||
HARDWARE.shutdown()
|
||||
peripheralStateLast = peripheralState
|
||||
|
||||
# Check if we need to shut down
|
||||
if power_monitor.should_shutdown(peripheralState, startup_conditions["ignition"], in_car, off_ts, started_seen, LEON, dp_auto_shutdown, dp_auto_shutdown_in):
|
||||
cloudlog.info(f"shutting device down, offroad since {off_ts}")
|
||||
|
||||
Reference in New Issue
Block a user