aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLane Roberts <nolatari@vandarin.net>2021-02-02 13:30:04 -0600
committerGitHub <noreply@github.com>2021-02-02 14:30:04 -0500
commit19397a0a2b5997d74b8aada1596310a3f383c626 (patch)
tree6d25a6b51414e83965166d6a9faa8dd01cb54380
parentb45b0162bfe0faa190bb6e7f3db4748c46c51dfc (diff)
downloadkutter-19397a0a2b5997d74b8aada1596310a3f383c626.tar.gz
kutter-19397a0a2b5997d74b8aada1596310a3f383c626.tar.xz
kutter-19397a0a2b5997d74b8aada1596310a3f383c626.zip
temperature_fan: Add MAX_SPEED and MIN_SPEED to SET_TEMPERATURE_FAN_TARGET command (#3873)
Allows setting min_speed and max_speed at runtime, rather than updating the config and restarting. Signed-off-by Lane Roberts <nolatari@vandarin.net>
-rw-r--r--docs/G-Codes.md4
-rw-r--r--klippy/extras/temperature_fan.py40
2 files changed, 36 insertions, 8 deletions
diff --git a/docs/G-Codes.md b/docs/G-Codes.md
index c656c416..0b0ad713 100644
--- a/docs/G-Codes.md
+++ b/docs/G-Codes.md
@@ -688,9 +688,9 @@ The following command is available when a
[temperature_fan config section](Config_Reference.md#temperature_fan)
is enabled:
- `SET_TEMPERATURE_FAN_TARGET temperature_fan=<temperature_fan_name>
- [target=<target_temperature>]`: Sets the target temperature for a
+ [target=<target_temperature>] [min_speed=<min_speed>] [max_speed=<max_speed>]`: Sets the target temperature for a
temperature_fan. If a target is not supplied, it is set to the
- specified temperature in the config file.
+ specified temperature in the config file. If speeds are not supplied, no change is applied.
## Adxl345 Accelerometer Commands
diff --git a/klippy/extras/temperature_fan.py b/klippy/extras/temperature_fan.py
index 8309f096..8ddedabb 100644
--- a/klippy/extras/temperature_fan.py
+++ b/klippy/extras/temperature_fan.py
@@ -23,8 +23,12 @@ class TemperatureFan:
self.sensor.setup_callback(self.temperature_callback)
pheaters.register_sensor(config, self)
self.speed_delay = self.sensor.get_report_time_delta()
- self.max_speed = config.getfloat('max_speed', 1., above=0., maxval=1.)
- self.min_speed = config.getfloat('min_speed', 0.3, minval=0., maxval=1.)
+ self.max_speed_conf = config.getfloat(
+ 'max_speed', 1., above=0., maxval=1.)
+ self.max_speed = self.max_speed_conf
+ self.min_speed_conf = config.getfloat(
+ 'min_speed', 0.3, minval=0., maxval=1.)
+ self.min_speed = self.min_speed_conf
self.last_temp = 0.
self.last_temp_time = 0.
self.target_temp_conf = config.getfloat(
@@ -39,8 +43,8 @@ class TemperatureFan:
gcode = self.printer.lookup_object('gcode')
gcode.register_mux_command(
"SET_TEMPERATURE_FAN_TARGET", "TEMPERATURE_FAN", self.name,
- self.cmd_SET_TEMPERATURE_FAN_TARGET_TEMP,
- desc=self.cmd_SET_TEMPERATURE_FAN_TARGET_TEMP_help)
+ self.cmd_SET_TEMPERATURE_FAN_TARGET,
+ desc=self.cmd_SET_TEMPERATURE_FAN_TARGET_help)
def set_speed(self, read_time, value):
if value <= 0.:
@@ -71,10 +75,20 @@ class TemperatureFan:
status["temperature"] = self.last_temp
status["target"] = self.target_temp
return status
- cmd_SET_TEMPERATURE_FAN_TARGET_TEMP_help = "Sets a temperature fan target"
- def cmd_SET_TEMPERATURE_FAN_TARGET_TEMP(self, gcmd):
+ cmd_SET_TEMPERATURE_FAN_TARGET_help = \
+ "Sets a temperature fan target and fan speed limits"
+ def cmd_SET_TEMPERATURE_FAN_TARGET(self, gcmd):
temp = gcmd.get_float('TARGET', self.target_temp_conf)
self.set_temp(temp)
+ min_speed = gcmd.get_float('MIN_SPEED', self.min_speed)
+ max_speed = gcmd.get_float('MAX_SPEED', self.max_speed)
+ if min_speed > max_speed:
+ raise self.printer.command_error(
+ "Requested min speed (%.1f) is greater than max speed (%.1f)"
+ % (min_speed, max_speed))
+ self.set_min_speed(min_speed)
+ self.set_max_speed(max_speed)
+
def set_temp(self, degrees):
if degrees and (degrees < self.min_temp or degrees > self.max_temp):
raise self.printer.command_error(
@@ -82,6 +96,20 @@ class TemperatureFan:
% (degrees, self.min_temp, self.max_temp))
self.target_temp = degrees
+ def set_min_speed(self, speed):
+ if speed and (speed < 0. or speed > 1.):
+ raise self.printer.command_error(
+ "Requested min speed (%.1f) out of range (0.0 : 1.0)"
+ % (speed))
+ self.min_speed = speed
+
+ def set_max_speed(self, speed):
+ if speed and (speed < 0. or speed > 1.):
+ raise self.printer.command_error(
+ "Requested max speed (%.1f) out of range (0.0 : 1.0)"
+ % (speed))
+ self.max_speed = speed
+
######################################################################
# Bang-bang control algo
######################################################################