aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-12-06 09:59:00 -0500
committerKevin O'Connor <kevin@koconnor.net>2017-12-06 19:13:54 -0500
commit8d9ca6f2dd96e5b1c71999fb8497487fcb091493 (patch)
treedda12433dace1ab95dc26d38fb4dbf752591cb39 /klippy
parent1d6af72de5b28a32ef5506b312943caeecaf787b (diff)
downloadkutter-8d9ca6f2dd96e5b1c71999fb8497487fcb091493.tar.gz
kutter-8d9ca6f2dd96e5b1c71999fb8497487fcb091493.tar.xz
kutter-8d9ca6f2dd96e5b1c71999fb8497487fcb091493.zip
homing: Directly interact with the kinematic class when homing
Move the homing logic out of toolhead.py and into homing.py. This simplifies the toolhead logic and centralizes the homing code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy')
-rw-r--r--klippy/gcode.py4
-rw-r--r--klippy/homing.py11
-rw-r--r--klippy/toolhead.py8
3 files changed, 13 insertions, 10 deletions
diff --git a/klippy/gcode.py b/klippy/gcode.py
index 4af97e8a..c25608fb 100644
--- a/klippy/gcode.py
+++ b/klippy/gcode.py
@@ -354,11 +354,11 @@ class GCodeParser:
axes.append(self.axis2pos[axis])
if not axes:
axes = [0, 1, 2]
- homing_state = homing.Homing(self.toolhead, axes)
+ homing_state = homing.Homing(self.toolhead)
if self.is_fileinput:
homing_state.set_no_verify_retract()
try:
- self.toolhead.home(homing_state)
+ homing_state.home_axes(axes)
except homing.EndstopError as e:
raise error(str(e))
newpos = self.toolhead.get_position()
diff --git a/klippy/homing.py b/klippy/homing.py
index db99fea9..8ee78530 100644
--- a/klippy/homing.py
+++ b/klippy/homing.py
@@ -10,9 +10,9 @@ ENDSTOP_SAMPLE_TIME = .000015
ENDSTOP_SAMPLE_COUNT = 4
class Homing:
- def __init__(self, toolhead, changed_axes):
+ def __init__(self, toolhead):
self.toolhead = toolhead
- self.changed_axes = changed_axes
+ self.changed_axes = []
self.verify_retract = True
def set_no_verify_retract(self):
self.verify_retract = False
@@ -79,6 +79,13 @@ class Homing:
if s.get_mcu_position() == pos:
raise EndstopError(
"Endstop %s still triggered after retract" % (name,))
+ def home_axes(self, axes):
+ self.changed_axes = axes
+ try:
+ self.toolhead.get_kinematics().home(self)
+ except EndstopError:
+ self.toolhead.motor_off()
+ raise
def query_endstops(print_time, query_flags, steppers):
if query_flags == "get_mcu_position":
diff --git a/klippy/toolhead.py b/klippy/toolhead.py
index 3a73bb26..e258f473 100644
--- a/klippy/toolhead.py
+++ b/klippy/toolhead.py
@@ -327,12 +327,6 @@ class ToolHead:
self.move_queue.add_move(move)
if self.print_time > self.need_check_stall:
self._check_stall()
- def home(self, homing_state):
- try:
- self.kin.home(homing_state)
- except homing.EndstopError as e:
- self.motor_off()
- raise
def dwell(self, delay, check_stall=True):
self.get_last_move_time()
self.update_move_time(delay)
@@ -382,6 +376,8 @@ class ToolHead:
self.reset_print_time()
except:
logging.exception("Exception in do_shutdown")
+ def get_kinematics(self):
+ return self.kin
def get_max_velocity(self):
return self.max_velocity, self.max_accel
def get_max_axis_halt(self):