diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-07-04 11:38:44 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-07-05 10:43:34 -0400 |
commit | 57932713086ad599048c7b70fb89285d55c86f92 (patch) | |
tree | 9e72c926f376888f0c6ab7dcc79aedf484833c26 /klippy/fan.py | |
parent | 09140a51d560372bb7e77297f7a2807e717167a0 (diff) | |
download | kutter-57932713086ad599048c7b70fb89285d55c86f92.tar.gz kutter-57932713086ad599048c7b70fb89285d55c86f92.tar.xz kutter-57932713086ad599048c7b70fb89285d55c86f92.zip |
fan: Support setting a max_power attribute for the print cooling fan
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/fan.py')
-rw-r--r-- | klippy/fan.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/klippy/fan.py b/klippy/fan.py index bd66f7b5..54cace6c 100644 --- a/klippy/fan.py +++ b/klippy/fan.py @@ -11,21 +11,22 @@ class PrinterFan: def __init__(self, printer, config): self.last_fan_value = 0. self.last_fan_time = 0. + self.max_power = config.getfloat('max_power', 1., above=0., maxval=1.) self.kick_start_time = config.getfloat('kick_start_time', 0.1, minval=0.) pin = config.get('pin') hard_pwm = config.getint('hard_pwm', 0) self.mcu_fan = printer.mcu.create_pwm(pin, PWM_CYCLE_TIME, hard_pwm, 0.) # External commands def set_speed(self, print_time, value): - value = max(0., min(1., value)) + value = max(0., min(self.max_power, value)) if value == self.last_fan_value: return mcu_time = self.mcu_fan.print_to_mcu_time(print_time) mcu_time = max(self.last_fan_time + FAN_MIN_TIME, mcu_time) - if (value and value < 1. + if (value and value < self.max_power and not self.last_fan_value and self.kick_start_time): # Run fan at full speed for specified kick_start_time - self.mcu_fan.set_pwm(mcu_time, 1.) + self.mcu_fan.set_pwm(mcu_time, self.max_power) mcu_time += self.kick_start_time self.mcu_fan.set_pwm(mcu_time, value) self.last_fan_time = mcu_time |