mirror of
https://jihulab.com/mr-one/openpilot.git
synced 2026-10-27 21:13:42 +08:00
hardware: suppress boot-time temperature spike
This commit is contained in:
@@ -103,6 +103,7 @@ else:
|
||||
|
||||
# Override to highest thermal band when offroad and above this temp
|
||||
OFFROAD_DANGER_TEMP = 85 if HARDWARE.get_device_type() == "mici" else 75
|
||||
STARTUP_TEMP_GRACE_S = 20.0
|
||||
|
||||
prev_offroad_states: dict[str, tuple[bool, str | None]] = {}
|
||||
|
||||
@@ -243,6 +244,7 @@ def hardware_thread(end_event, hw_queue) -> None:
|
||||
thermal_config = HARDWARE.get_thermal_config()
|
||||
|
||||
fan_controller = FanController(int(1./DT_HW))
|
||||
startup_ts = time.monotonic()
|
||||
chestnut = Chestnut()
|
||||
chestnut_status = ChestnutStatus()
|
||||
branch = get_short_branch()
|
||||
@@ -312,23 +314,36 @@ def hardware_thread(end_event, hw_queue) -> None:
|
||||
chestnut_status.update(started_ts is None, branch, last_hw_state.usb_state, chestnut.failed,
|
||||
params.get_bool("ChestnutLoading"), params.get("ChestnutActive"),
|
||||
chestnut_state if chestnut_valid else None, set_offroad_alert_if_changed)
|
||||
|
||||
# Suppress the boot-time CPU temperature spike in the UI and fan control.
|
||||
startup_temp_grace = time.monotonic() - startup_ts < STARTUP_TEMP_GRACE_S
|
||||
# this subset is only used for offroad
|
||||
temp_sources = [
|
||||
msg.deviceState.memoryTempC,
|
||||
max(msg.deviceState.cpuTempC, default=0.),
|
||||
max(msg.deviceState.gpuTempC, default=0.),
|
||||
]
|
||||
offroad_comp_temp = offroad_temp_filter.update(max(temp_sources))
|
||||
offroad_raw_temp = max(temp_sources)
|
||||
if startup_temp_grace:
|
||||
offroad_raw_temp = min(offroad_raw_temp, 70.0)
|
||||
offroad_comp_temp = offroad_temp_filter.update(offroad_raw_temp)
|
||||
|
||||
# this drives the thermal status while onroad
|
||||
temp_sources.append(max(msg.deviceState.pmicTempC, default=0.))
|
||||
all_comp_temp = all_temp_filter.update(max(temp_sources))
|
||||
all_raw_temp = max(temp_sources)
|
||||
if startup_temp_grace:
|
||||
all_raw_temp = min(all_raw_temp, 70.0)
|
||||
all_comp_temp = all_temp_filter.update(all_raw_temp)
|
||||
|
||||
msg.deviceState.maxTempC = all_comp_temp
|
||||
|
||||
msg.deviceState.fanSpeedPercentDesired = fan_controller.update(all_comp_temp, onroad_conditions["ignition"])
|
||||
fan_speed = fan_controller.update(all_comp_temp, onroad_conditions["ignition"])
|
||||
msg.deviceState.fanSpeedPercentDesired = min(fan_speed, 30) if startup_temp_grace else fan_speed
|
||||
|
||||
is_offroad_for_5_min = (started_ts is None) and ((not started_seen) or (off_ts is None) or (time.monotonic() - off_ts > 60 * 5))
|
||||
if is_offroad_for_5_min and offroad_comp_temp > OFFROAD_DANGER_TEMP:
|
||||
if startup_temp_grace:
|
||||
thermal_status = ThermalStatus.ok
|
||||
elif is_offroad_for_5_min and offroad_comp_temp > OFFROAD_DANGER_TEMP:
|
||||
# if device is offroad and already hot without the extra onroad load,
|
||||
# we want to cool down first before increasing load
|
||||
thermal_status = ThermalStatus.critical
|
||||
@@ -377,7 +392,7 @@ def hardware_thread(end_event, hw_queue) -> None:
|
||||
# if the temperature enters the danger zone, go offroad to cool down
|
||||
onroad_conditions["device_temp_good"] = thermal_status < ThermalStatus.critical
|
||||
extra_text = f"{offroad_comp_temp:.1f}C"
|
||||
show_alert = (not onroad_conditions["device_temp_good"] or not startup_conditions["device_temp_engageable"]) and onroad_conditions["ignition"]
|
||||
show_alert = (not onroad_conditions["device_temp_good"] or not startup_conditions["device_temp_engageable"]) and onroad_conditions["ignition"] and not startup_temp_grace
|
||||
set_offroad_alert_if_changed("Offroad_TemperatureTooHigh", show_alert, extra_text=extra_text)
|
||||
|
||||
if show_alert:
|
||||
|
||||
Reference in New Issue
Block a user