fan: Add a set_shutdown_speed() method

Add a set_shutdown_speed() method so that the heater_fan code does not
need to peek into the fan object's internal members.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-04-20 21:50:32 -04:00
parent 6d03dee104
commit 8f4f5da11c
2 changed files with 3 additions and 1 deletions

View File

@ -18,6 +18,8 @@ class PrinterFan:
cycle_time = config.getfloat('cycle_time', 0.010, above=0.) cycle_time = config.getfloat('cycle_time', 0.010, above=0.)
hardware_pwm = config.getboolean('hardware_pwm', False) hardware_pwm = config.getboolean('hardware_pwm', False)
self.mcu_fan.setup_cycle_time(cycle_time, hardware_pwm) self.mcu_fan.setup_cycle_time(cycle_time, hardware_pwm)
def set_shutdown_speed(self, speed):
self.mcu_fan.setup_start_value(0., max(0., min(self.max_power, speed)))
def set_speed(self, print_time, value): def set_speed(self, print_time, value):
value = max(0., min(self.max_power, value * self.max_power)) value = max(0., min(self.max_power, value * self.max_power))
if value == self.last_fan_value: if value == self.last_fan_value:

View File

@ -15,7 +15,7 @@ class PrinterHeaterFan:
self.fan = fan.PrinterFan(config) self.fan = fan.PrinterFan(config)
self.mcu = self.fan.mcu_fan.get_mcu() self.mcu = self.fan.mcu_fan.get_mcu()
self.fan_speed = config.getfloat("fan_speed", 1., minval=0., maxval=1.) self.fan_speed = config.getfloat("fan_speed", 1., minval=0., maxval=1.)
self.fan.mcu_fan.setup_start_value(0., self.fan.max_power) self.fan.set_shutdown_speed(1.)
def printer_state(self, state): def printer_state(self, state):
if state == 'ready': if state == 'ready':
pheater = self.printer.lookup_object('heater') pheater = self.printer.lookup_object('heater')