mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-20 13:17:55 -06:00
fan_generic: Add support for named fans and gcode to control them (#3054)
Signed-off-by: Pontus Borg <liquidpontus@yahoo.se>
This commit is contained in:
parent
3eefc037c5
commit
c9e7119a93
3 changed files with 41 additions and 0 deletions
28
klippy/extras/fan_generic.py
Normal file
28
klippy/extras/fan_generic.py
Normal file
|
@ -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)
|
Loading…
Add table
Add a link
Reference in a new issue