aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbondus <liquidpontus@yahoo.se>2020-08-07 17:39:44 +0200
committerGitHub <noreply@github.com>2020-08-07 11:39:44 -0400
commitc9e7119a933530c2989c94f7333bbea963a47fbd (patch)
treeac3db34cf96f5e5d43cfa831f1c4db51a87ad765
parent3eefc037c5ffbef5dbb4d40baa89bee6d0f98473 (diff)
downloadkutter-c9e7119a933530c2989c94f7333bbea963a47fbd.tar.gz
kutter-c9e7119a933530c2989c94f7333bbea963a47fbd.tar.xz
kutter-c9e7119a933530c2989c94f7333bbea963a47fbd.zip
fan_generic: Add support for named fans and gcode to control them (#3054)
Signed-off-by: Pontus Borg <liquidpontus@yahoo.se>
-rw-r--r--config/example-extras.cfg6
-rw-r--r--docs/G-Codes.md7
-rw-r--r--klippy/extras/fan_generic.py28
3 files changed, 41 insertions, 0 deletions
diff --git a/config/example-extras.cfg b/config/example-extras.cfg
index 419c8f94..3e4b728d 100644
--- a/config/example-extras.cfg
+++ b/config/example-extras.cfg
@@ -1224,6 +1224,12 @@
# given id. The default is to not report the temperature via M105.
+# Manually controlled fan (one may define any number of sections with a
+# "fan_generic" prefix). The speed of a manually controlled fan is set with the
+# SET_FAN_SPEED gcode command.
+#[fan_generic extruder_partfan]
+# Options are the same as for the [fan] section
+
######################################################################
# Additional servos, LEDs, buttons, and other pins
######################################################################
diff --git a/docs/G-Codes.md b/docs/G-Codes.md
index 35523839..3b5db9ad 100644
--- a/docs/G-Codes.md
+++ b/docs/G-Codes.md
@@ -244,6 +244,13 @@ The following command is available when an "output_pin" config section
is enabled:
- `SET_PIN PIN=config_name VALUE=<value>`
+## Manually Controlled Fans Commands
+
+The following command is available when a "fan_generic" config section
+is enabled:
+- `SET_FAN_SPEED FAN=config_name SPEED=<speed>` This command sets
+ the speed of a fan. <speed> must be between 0.0 and 1.0.
+
## Neopixel and Dotstar Commands
The following command is available when "neopixel" or "dotstar" config
diff --git a/klippy/extras/fan_generic.py b/klippy/extras/fan_generic.py
new file mode 100644
index 00000000..def9a77e
--- /dev/null
+++ b/klippy/extras/fan_generic.py
@@ -0,0 +1,28 @@
+# Support fans that are controlled by gcode
+#
+# Copyright (C) 2016-2020 Kevin O'Connor <kevin@koconnor.net>
+#
+# This file may be distributed under the terms of the GNU GPLv3 license.
+from . import fan
+
+class PrinterFanGeneric:
+ cmd_SET_FAN_SPEED_help = "Sets the speed of a fan"
+ def __init__(self, config):
+ self.printer = config.get_printer()
+ self.fan = fan.Fan(config, default_shutdown_speed=0.)
+ self.fan_name = config.get_name().split()[-1]
+
+ gcode = self.printer.lookup_object("gcode")
+ gcode.register_mux_command("SET_FAN_SPEED", "FAN",
+ self.fan_name,
+ self.cmd_SET_FAN_SPEED,
+ desc=self.cmd_SET_FAN_SPEED_help)
+
+ def get_status(self, eventtime):
+ return self.fan.get_status(eventtime)
+ def cmd_SET_FAN_SPEED(self, gcmd):
+ speed = gcmd.get_float('SPEED', 0.)
+ self.fan.set_speed_from_command(speed)
+
+def load_config_prefix(config):
+ return PrinterFanGeneric(config)