From 1d596697a52523c1650e3511123df93bae7416d8 Mon Sep 17 00:00:00 2001 From: trofen Date: Mon, 18 Sep 2023 15:37:36 +0300 Subject: [PATCH] min_time setting added in [fan] section --- docs/Config_Reference.md | 6 ++++++ klippy/extras/fan.py | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md index 25e7cc46e6fb..7be7d28d6056 100644 --- a/docs/Config_Reference.md +++ b/docs/Config_Reference.md @@ -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 diff --git a/klippy/extras/fan.py b/klippy/extras/fan.py index d6e687218c5e..431770038e38 100644 --- a/klippy/extras/fan.py +++ b/klippy/extras/fan.py @@ -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() @@ -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( @@ -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)