Skip to content

Commit

Permalink
min_time setting added in [fan] section
Browse files Browse the repository at this point in the history
  • Loading branch information
trofen committed Sep 18, 2023
1 parent 8ef0f7d commit 1d59669
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 6 additions & 0 deletions docs/Config_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2661,6 +2661,12 @@ pin:
# Time (in seconds) to run the fan at full speed when either first
# enabling or increasing it by more than 50% (helps get the fan
# spinning). The default is 0.100 seconds.
#min_time: 0.1
# The minimum time in seconds during which the fan will execute the
# previous set speed value and not start executing the next one.
# The default is 0.100 seconds.
# The value can be changed downwards if the gcode contains a lot of
# fast fan speed changes.
#off_below: 0.0
# The minimum input speed which will power the fan (expressed as a
# value from 0.0 to 1.0). When a speed lower than off_below is
Expand Down
5 changes: 2 additions & 3 deletions klippy/extras/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# This file may be distributed under the terms of the GNU GPLv3 license.
from . import pulse_counter

FAN_MIN_TIME = 0.100

class Fan:
def __init__(self, config, default_shutdown_speed=0.):
self.printer = config.get_printer()
Expand All @@ -18,6 +16,7 @@ def __init__(self, config, default_shutdown_speed=0.):
minval=0.)
self.off_below = config.getfloat('off_below', default=0.,
minval=0., maxval=1.)
self.min_time = config.getfloat('min_time', 0.1, above=0.)
cycle_time = config.getfloat('cycle_time', 0.010, above=0.)
hardware_pwm = config.getboolean('hardware_pwm', False)
shutdown_speed = config.getfloat(
Expand Down Expand Up @@ -51,7 +50,7 @@ def set_speed(self, print_time, value):
value = max(0., min(self.max_power, value * self.max_power))
if value == self.last_fan_value:
return
print_time = max(self.last_fan_time + FAN_MIN_TIME, print_time)
print_time = max(self.last_fan_time + self.min_time, print_time)
if self.enable_pin:
if value > 0 and self.last_fan_value == 0:
self.enable_pin.set_digital(print_time, 1)
Expand Down

0 comments on commit 1d59669

Please sign in to comment.