Skip to content

Commit

Permalink
Limit comma two fan speed to 30% when car is not running
Browse files Browse the repository at this point in the history
  • Loading branch information
pd0wm authored and otaku committed Jan 24, 2020
1 parent 60f1c7f commit 8449f10
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions selfdrive/thermald.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def set_eon_fan(val):
_BAT_TEMP_THERSHOLD = 45.


def handle_fan_eon(max_cpu_temp, bat_temp, fan_speed):
def handle_fan_eon(max_cpu_temp, bat_temp, fan_speed, ignition):
new_speed_h = next(speed for speed, temp_h in zip(_FAN_SPEEDS, _TEMP_THRS_H) if temp_h > max_cpu_temp)
new_speed_l = next(speed for speed, temp_l in zip(_FAN_SPEEDS, _TEMP_THRS_L) if temp_l > max_cpu_temp)

Expand All @@ -126,9 +126,15 @@ def handle_fan_eon(max_cpu_temp, bat_temp, fan_speed):

return fan_speed

def handle_fan_uno(max_cpu_temp, bat_temp, fan_speed):
# TODO: implement better fan control
return int(interp(max_cpu_temp, [40.0, 80.0], [0, 100]))

def handle_fan_uno(max_cpu_temp, bat_temp, fan_speed, ignition):
new_speed = int(interp(max_cpu_temp, [40.0, 80.0], [0, 100]))

if not ignition:
new_speed = min(30, new_speed)

return new_speed


def thermald_thread():
# prevent LEECO from undervoltage
Expand All @@ -141,6 +147,7 @@ def thermald_thread():
health_sock = messaging.sub_sock('health', timeout=health_timeout)
location_sock = messaging.sub_sock('gpsLocation')

ignition = False
fan_speed = 0
count = 0

Expand Down Expand Up @@ -213,7 +220,7 @@ def thermald_thread():
max_comp_temp = max(max_cpu_temp, msg.thermal.mem / 10., msg.thermal.gpu / 10.)
bat_temp = msg.thermal.bat/1000.

fan_speed = handle_fan(max_cpu_temp, bat_temp, fan_speed)
fan_speed = handle_fan(max_cpu_temp, bat_temp, fan_speed, ignition)
msg.thermal.fanSpeed = fan_speed

# thermal logic with hysterisis
Expand Down

0 comments on commit 8449f10

Please sign in to comment.