From 9f8f3cd77d97339bd825053b064ae4d08d5d6902 Mon Sep 17 00:00:00 2001 From: dalegaard Date: Sat, 3 Sep 2022 18:23:55 +0200 Subject: fan: add enable_pin option (#5732) Signed-off-by: Lasse Dalegaard --- klippy/extras/fan.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'klippy/extras/fan.py') 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 -- cgit v1.2.3-70-g09d2