heater_fan: Allow multiple heaters to be defined for a heater_fan

Support the case where a single cooling fan is used with multiple
extruders.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-08-17 10:20:12 -04:00
parent e88eab18d0
commit 1b07be070b
2 changed files with 10 additions and 5 deletions

View File

@ -298,7 +298,9 @@
# above parameters.
#heater: extruder
# Name of the config section defining the heater that this fan is
# associated with. The default is "extruder".
# associated with. If a comma separated list of heater names is
# provided here, then the fan will be enabled when any of the given
# heaters are enabled. The default is "extruder".
#heater_temp: 50.0
# A temperature (in Celsius) that the heater must drop below before
# the fan is disabled. The default is 50 Celsius.

View File

@ -12,18 +12,21 @@ class PrinterHeaterFan:
self.printer = config.get_printer()
self.heater_name = config.get("heater", "extruder0")
self.heater_temp = config.getfloat("heater_temp", 50.0)
self.heaters = []
self.fan = fan.PrinterFan(config, default_shutdown_speed=1.)
self.mcu = self.fan.mcu_fan.get_mcu()
self.fan_speed = config.getfloat("fan_speed", 1., minval=0., maxval=1.)
def printer_state(self, state):
if state == 'ready':
pheater = self.printer.lookup_object('heater')
self.heater = pheater.lookup_heater(self.heater_name)
self.heaters = [pheater.lookup_heater(n.strip())
for n in self.heater_name.split(',')]
reactor = self.printer.get_reactor()
reactor.register_timer(self.callback, reactor.NOW)
def callback(self, eventtime):
current_temp, target_temp = self.heater.get_temp(eventtime)
power = 0.
for heater in self.heaters:
current_temp, target_temp = heater.get_temp(eventtime)
if target_temp or current_temp > self.heater_temp:
power = self.fan_speed
print_time = self.mcu.estimated_print_time(eventtime) + PIN_MIN_TIME