aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/fan.py
diff options
context:
space:
mode:
authordalegaard <dalegaard@users.noreply.github.com>2022-09-03 18:23:55 +0200
committerGitHub <noreply@github.com>2022-09-03 12:23:55 -0400
commit9f8f3cd77d97339bd825053b064ae4d08d5d6902 (patch)
tree472679e93f591a379447ed761830cca9324ec630 /klippy/extras/fan.py
parent6ba02429009df34ba348abe80023ce3a3530bc58 (diff)
downloadkutter-9f8f3cd77d97339bd825053b064ae4d08d5d6902.tar.gz
kutter-9f8f3cd77d97339bd825053b064ae4d08d5d6902.tar.xz
kutter-9f8f3cd77d97339bd825053b064ae4d08d5d6902.zip
fan: add enable_pin option (#5732)
Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
Diffstat (limited to 'klippy/extras/fan.py')
-rw-r--r--klippy/extras/fan.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/klippy/extras/fan.py b/klippy/extras/fan.py
index 77fdef8a..d6e68721 100644
--- a/klippy/extras/fan.py
+++ b/klippy/extras/fan.py
@@ -30,6 +30,12 @@ class Fan:
shutdown_power = max(0., min(self.max_power, shutdown_speed))
self.mcu_fan.setup_start_value(0., shutdown_power)
+ self.enable_pin = None
+ enable_pin = config.get('enable_pin', None)
+ if enable_pin is not None:
+ self.enable_pin = ppins.setup_pin('digital_out', enable_pin)
+ self.enable_pin.setup_max_duration(0.)
+
# Setup tachometer
self.tachometer = FanTachometer(config)
@@ -46,6 +52,11 @@ class Fan:
if value == self.last_fan_value:
return
print_time = max(self.last_fan_time + FAN_MIN_TIME, print_time)
+ if self.enable_pin:
+ if value > 0 and self.last_fan_value == 0:
+ self.enable_pin.set_digital(print_time, 1)
+ elif value == 0 and self.last_fan_value > 0:
+ self.enable_pin.set_digital(print_time, 0)
if (value and value < self.max_power and self.kick_start_time
and (not self.last_fan_value or value - self.last_fan_value > .5)):
# Run fan at full speed for specified kick_start_time