diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2016-08-25 11:24:18 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-03-03 20:00:16 -0500 |
commit | f53897758da58ac0201dcfaecbedc8409d828da2 (patch) | |
tree | 468fcbb0df87a82cd1dea2a026d612f81d46111a /klippy/fan.py | |
parent | 54002c43914ea7a88cb831fe16bbfb695c533f74 (diff) | |
download | kutter-f53897758da58ac0201dcfaecbedc8409d828da2.tar.gz kutter-f53897758da58ac0201dcfaecbedc8409d828da2.tar.xz kutter-f53897758da58ac0201dcfaecbedc8409d828da2.zip |
heater: Support max_power setting for heaters
Change the mcu PWM value from an integer (0-255) to a float (0. - 1.).
Add support for limiting the maximum power (as measured over a
sufficiently long duration) to a particular heater.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/fan.py')
-rw-r--r-- | klippy/fan.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/klippy/fan.py b/klippy/fan.py index 98e73ba6..739af2f1 100644 --- a/klippy/fan.py +++ b/klippy/fan.py @@ -11,7 +11,7 @@ class PrinterFan: self.printer = printer self.config = config self.mcu_fan = None - self.last_fan_value = 0 + self.last_fan_value = 0. self.last_fan_time = 0. self.kick_start_time = config.getfloat('kick_start_time', 0.1) def build_config(self): @@ -20,15 +20,15 @@ class PrinterFan: self.mcu_fan = self.printer.mcu.create_pwm(pin, hard_pwm, 0) # External commands def set_speed(self, print_time, value): - value = max(0, min(255, int(value*255. + 0.5))) + value = max(0., min(1., 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 < 255 + if (value and value < 1. 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, 255) + self.mcu_fan.set_pwm(mcu_time, 1.) mcu_time += self.kick_start_time self.mcu_fan.set_pwm(mcu_time, value) self.last_fan_time = mcu_time |