controller_fan: Add "stepper" config option (#4447)

Allows contoller_fan sections to monitor only certain steppers instead of
all of them, similar to how heaters are currently handled.

Signed-off-by: Sophie Hirn <sophie.hirn@wyvernscale.com>
This commit is contained in:
Sophie Hirn 2021-07-20 16:19:59 +02:00 committed by GitHub
parent dafb74e3ab
commit de57ce3a99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 7 deletions

View file

@ -11,6 +11,9 @@ class ControllerFan:
def __init__(self, config):
self.printer = config.get_printer()
self.printer.register_event_handler("klippy:ready", self.handle_ready)
self.printer.register_event_handler("klippy:connect",
self.handle_connect)
self.steppers_to_monitor = config.get("stepper", "")
self.stepper_names = []
self.stepper_enable = self.printer.load_object(config, 'stepper_enable')
self.printer.load_object(config, 'heaters')
@ -24,12 +27,23 @@ class ControllerFan:
self.heater_name = config.get("heater", "extruder")
self.last_on = self.idle_timeout
self.last_speed = 0.
def handle_connect(self):
steppers = [n.strip() for n in self.steppers_to_monitor.split(',')]
all_steppers = [s.get_name()
for s in self.stepper_enable.get_steppers()]
if steppers == [""]:
self.stepper_names = all_steppers
return
if not all(x in all_steppers for x in steppers):
raise self.printer.config_error(
("One or more of these steppers are unknown: "
"%s (valid steppers are: %s)")
% (steppers, ", ".join(all_steppers)))
self.stepper_names = steppers
def handle_ready(self):
pheaters = self.printer.lookup_object('heaters')
self.heaters = [pheaters.lookup_heater(n.strip())
for n in self.heater_name.split(',')]
kin = self.printer.lookup_object('toolhead').get_kinematics()
self.stepper_names = [s.get_name() for s in kin.get_steppers()]
reactor = self.printer.get_reactor()
reactor.register_timer(self.callback, reactor.monotonic()+PIN_MIN_TIME)
def get_status(self, eventtime):