aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/example-extras.cfg12
-rw-r--r--klippy/extras/homing_heaters.py70
-rw-r--r--klippy/heater.py2
-rw-r--r--klippy/homing.py4
4 files changed, 88 insertions, 0 deletions
diff --git a/config/example-extras.cfg b/config/example-extras.cfg
index 156b4c8f..01ffeeac 100644
--- a/config/example-extras.cfg
+++ b/config/example-extras.cfg
@@ -791,6 +791,18 @@
# by during the check_gain_time check. It is rare to customize this
# value. The default is 2.
+# Tool to disable heaters when homing or probing an axis
+#[homing_heaters]
+#steppers:
+# A comma separated list of steppers that should cause heaters to be
+# disabled. The default is to disable heaters for any homing/probing
+# move.
+# Typical example: stepper_z
+#heaters:
+# A comma separated list of heaters to disable during homing/probing
+# moves. The default is to disable all heaters.
+# Typical example: extruder, heater_bed
+
# MAXxxxxx serial peripheral interface (SPI) temperature based
# sensors. The following parameters are available in heater sections
# that use one of these sensor types.
diff --git a/klippy/extras/homing_heaters.py b/klippy/extras/homing_heaters.py
new file mode 100644
index 00000000..ff132180
--- /dev/null
+++ b/klippy/extras/homing_heaters.py
@@ -0,0 +1,70 @@
+# Heater handling on homing moves
+#
+# Copyright (C) 2016-2018 Kevin O'Connor <kevin@koconnor.net>
+#
+# This file may be distributed under the terms of the GNU GPLv3 license.
+
+import logging
+
+class HomingHeaters:
+ def __init__(self, config):
+ self.printer = config.get_printer()
+ self.printer.register_event_handler("klippy:connect",
+ self.handle_connect)
+ self.printer.register_event_handler("homing:move_begin",
+ self.handle_homing_move_begin)
+ self.printer.register_event_handler("homing:move_end",
+ self.handle_homing_move_end)
+ self.heaters_to_disable = config.get("heaters", "")
+ self.disable_heaters = []
+ self.steppers_needing_quiet = config.get("steppers", "")
+ self.flaky_steppers = []
+ self.pheater = self.printer.lookup_object('heater')
+ self.target_save = {}
+
+ def handle_connect(self):
+ # heaters to disable
+ all_heaters = self.pheater.get_all_heaters()
+ self.disable_heaters = [n.strip()
+ for n in self.heaters_to_disable.split(',')]
+ if self.disable_heaters == [""]:
+ self.disable_heaters = all_heaters
+ else:
+ if not all(x in all_heaters for x in self.disable_heaters):
+ raise self.printer.config_error(
+ "One or more of these heaters are unknown: %s" % (
+ self.disable_heaters))
+ # steppers valid?
+ kin = self.printer.lookup_object('toolhead').get_kinematics()
+ all_steppers = [s.get_name() for s in kin.get_steppers()]
+ self.flaky_steppers = [n.strip()
+ for n in self.steppers_needing_quiet.split(',')]
+ if self.flaky_steppers == [""]:
+ return
+ if not all(x in all_steppers for x in self.flaky_steppers):
+ raise self.printer.config_error(
+ "One or more of these steppers are unknown: %s" % (
+ self.flaky_steppers))
+ def check_eligible(self, endstops):
+ if self.flaky_steppers == [""]:
+ return True
+ steppers_being_homed = [s.get_name()
+ for es, name in endstops
+ for s in es.get_steppers()]
+ return any(x in self.flaky_steppers for x in steppers_being_homed)
+ def handle_homing_move_begin(self, endstops):
+ if not self.check_eligible(endstops):
+ return
+ for heater_name in self.disable_heaters:
+ heater = self.pheater.lookup_heater(heater_name)
+ self.target_save[heater_name] = heater.get_temp(0)[1]
+ heater.set_temp(0.)
+ def handle_homing_move_end(self, endstops):
+ if not self.check_eligible(endstops):
+ return
+ for heater_name in self.disable_heaters:
+ heater = self.pheater.lookup_heater(heater_name)
+ heater.set_temp(self.target_save[heater_name])
+
+def load_config(config):
+ return HomingHeaters(config)
diff --git a/klippy/heater.py b/klippy/heater.py
index 6e350ab2..4228dfc1 100644
--- a/klippy/heater.py
+++ b/klippy/heater.py
@@ -250,6 +250,8 @@ class PrinterHeaters:
self.register_sensor(config, heater, gcode_id)
self.available_heaters.append(config.get_name())
return heater
+ def get_all_heaters(self):
+ return self.available_heaters
def lookup_heater(self, heater_name):
if heater_name not in self.heaters:
raise self.printer.config_error(
diff --git a/klippy/homing.py b/klippy/homing.py
index 1c2557f4..be940447 100644
--- a/klippy/homing.py
+++ b/klippy/homing.py
@@ -66,6 +66,8 @@ class Homing:
print_time, ENDSTOP_SAMPLE_TIME, ENDSTOP_SAMPLE_COUNT,
rest_time, notify=self._endstop_notify)
self.toolhead.dwell(HOMING_START_DELAY)
+ # notify anyone out there of move start
+ self.printer.send_event("homing:move_begin", endstops)
# Issue move
error = None
try:
@@ -80,6 +82,8 @@ class Homing:
except mcu_endstop.TimeoutError as e:
if error is None:
error = "Failed to home %s: %s" % (name, str(e))
+ # notify anyone out there of move end
+ self.printer.send_event("homing:move_end", endstops)
# Determine stepper halt positions
self.toolhead.flush_step_generation()
end_mcu_pos = [(s, name, spos, s.get_mcu_position())