fan: Allow the fan shutdown_speed to be configured
Add a shutdown_speed config option to fans so that users can specify the speed on a shutdown event. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
FAN_MIN_TIME = 0.100
|
||||
|
||||
class PrinterFan:
|
||||
def __init__(self, config):
|
||||
def __init__(self, config, default_shutdown_speed=0.):
|
||||
self.last_fan_value = 0.
|
||||
self.last_fan_time = 0.
|
||||
self.max_power = config.getfloat('max_power', 1., above=0., maxval=1.)
|
||||
@@ -18,8 +18,10 @@ class PrinterFan:
|
||||
cycle_time = config.getfloat('cycle_time', 0.010, above=0.)
|
||||
hardware_pwm = config.getboolean('hardware_pwm', False)
|
||||
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)))
|
||||
shutdown_speed = config.getfloat(
|
||||
'shutdown_speed', default_shutdown_speed, minval=0., maxval=1.)
|
||||
self.mcu_fan.setup_start_value(
|
||||
0., max(0., min(self.max_power, shutdown_speed)))
|
||||
def set_speed(self, print_time, value):
|
||||
value = max(0., min(self.max_power, value * self.max_power))
|
||||
if value == self.last_fan_value:
|
||||
|
||||
@@ -12,10 +12,9 @@ class PrinterHeaterFan:
|
||||
self.printer = config.get_printer()
|
||||
self.heater_name = config.get("heater", "extruder0")
|
||||
self.heater_temp = config.getfloat("heater_temp", 50.0)
|
||||
self.fan = fan.PrinterFan(config)
|
||||
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.)
|
||||
self.fan.set_shutdown_speed(1.)
|
||||
def printer_state(self, state):
|
||||
if state == 'ready':
|
||||
pheater = self.printer.lookup_object('heater')
|
||||
|
||||
@@ -14,7 +14,7 @@ class TemperatureFan:
|
||||
def __init__(self, config):
|
||||
self.name = config.get_name()
|
||||
self.printer = config.get_printer()
|
||||
self.fan = fan.PrinterFan(config)
|
||||
self.fan = fan.PrinterFan(config, default_shutdown_speed=1.)
|
||||
self.mcu = self.fan.mcu_fan.get_mcu()
|
||||
self.min_temp = config.getfloat('min_temp', minval=KELVIN_TO_CELCIUS)
|
||||
self.max_temp = config.getfloat('max_temp', above=self.min_temp)
|
||||
@@ -22,7 +22,6 @@ class TemperatureFan:
|
||||
self.sensor.setup_minmax(self.min_temp, self.max_temp)
|
||||
self.sensor.setup_callback(self.temperature_callback)
|
||||
self.speed_delay = self.sensor.get_report_time_delta()
|
||||
self.fan.set_shutdown_speed(1.)
|
||||
self.max_speed = config.getfloat('max_speed', 1., above=0., maxval=1.)
|
||||
self.min_speed = config.getfloat('min_speed', 0.3, above=0., maxval=1.)
|
||||
self.last_temp = 0.
|
||||
|
||||
Reference in New Issue
Block a user