From 3506d1e994f1952fa8de3167f7abb1e82e17f5ef Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 12 Oct 2017 11:31:12 -0400 Subject: [PATCH] fan: Enable heater_fan objects on an MCU shutdown event Should the MCU go into an error state, set the heater_fan to max_power. Signed-off-by: Kevin O'Connor --- config/example-extras.cfg | 7 ++++++- klippy/fan.py | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/config/example-extras.cfg b/config/example-extras.cfg index 0e712f7e..97183b7c 100644 --- a/config/example-extras.cfg +++ b/config/example-extras.cfg @@ -29,7 +29,8 @@ # Heater cooling fans (one may define any number of sections with a # "heater_fan" prefix). A "heater fan" is a fan that will be enabled -# whenever its associated heater is active. +# whenever its associated heater is active. In the event of an MCU +# software error the heater_fan will be set to its max_power. #[heater_fan my_nozzle_fan] # See the "fan" section for fan configuration parameters. #pin: ar4 @@ -40,6 +41,10 @@ #heater_temp: 50.0 # A temperature (in Celsius) that the heater must drop below before # the fan is disabled. The default is 50 Celsius. +#fan_speed: +# The fan speed (expressed as a value from 0.0 to 1.0) that the fan +# will be set to when its associated heater is enabled. The default +# is max_power. # Additional micro-controllers (one may define any number of sections diff --git a/klippy/fan.py b/klippy/fan.py index 3f9bd63d..5401c5ec 100644 --- a/klippy/fan.py +++ b/klippy/fan.py @@ -39,6 +39,10 @@ class PrinterHeaterFan: heater = config.get("heater", "extruder0") self.heater = extruder.get_printer_heater(printer, heater) self.heater_temp = config.getfloat("heater_temp", 50.0) + max_power = self.fan.max_power + self.fan_speed = config.getfloat( + "fan_speed", max_power, minval=0., maxval=max_power) + self.fan.mcu_fan.setup_shutdown_value(max_power) printer.reactor.register_timer(self.callback, printer.reactor.NOW) def callback(self, eventtime): current_temp, target_temp = self.heater.get_temp(eventtime) @@ -47,7 +51,7 @@ class PrinterHeaterFan: return eventtime + 1. power = 0. if target_temp or current_temp > self.heater_temp: - power = 1. + power = self.fan_speed print_time = self.mcu.estimated_print_time(eventtime) + FAN_MIN_TIME self.fan.set_speed(print_time, power) return eventtime + 1.