homing: Move query_endstop() code from kinematic classes to homing.py

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2017-09-13 10:50:52 -04:00
parent a100f174f9
commit 857eb01bfa
6 changed files with 25 additions and 26 deletions

View File

@ -62,6 +62,8 @@ class CartKinematics:
# Set final homed position
coord[axis] = s.position_endstop + s.get_homed_offset()
homing_state.set_homed_position(coord)
def query_endstops(self, print_time):
return homing.query_endstops(print_time, self.steppers)
def motor_off(self, print_time):
self.limits = [(1.0, -1.0)] * 3
for stepper in self.steppers:
@ -74,9 +76,6 @@ class CartKinematics:
self.steppers[i].motor_enable(print_time, 1)
need_motor_enable |= self.steppers[i].need_motor_enable
self.need_motor_enable = need_motor_enable
def query_endstops(self, print_time):
endstops = [(s, s.query_endstop(print_time)) for s in self.steppers]
return [(s.name, es.query_endstop_wait()) for s, es in endstops]
def _check_endstops(self, move):
end_pos = move.end_pos
for i in StepList:

View File

@ -67,6 +67,8 @@ class CoreXYKinematics:
# Support endstop phase detection on Z axis
coord[axis] = s.position_endstop + s.get_homed_offset()
homing_state.set_homed_position(coord)
def query_endstops(self, print_time):
return homing.query_endstops(print_time, self.steppers)
def motor_off(self, print_time):
self.limits = [(1.0, -1.0)] * 3
for stepper in self.steppers:
@ -82,9 +84,6 @@ class CoreXYKinematics:
for i in StepList:
need_motor_enable |= self.steppers[i].need_motor_enable
self.need_motor_enable = need_motor_enable
def query_endstops(self, print_time):
endstops = [(s, s.query_endstop(print_time)) for s in self.steppers]
return [(s.name, es.query_endstop_wait()) for s, es in endstops]
def _check_endstops(self, move):
end_pos = move.end_pos
for i in StepList:

View File

@ -123,6 +123,8 @@ class DeltaKinematics:
+ self.steppers[i].get_homed_offset()
for i in StepList]
homing_state.set_homed_position(self._actuator_to_cartesian(spos))
def query_endstops(self, print_time):
return homing.query_endstops(print_time, self.steppers)
def motor_off(self, print_time):
self.limit_xy2 = -1.
for stepper in self.steppers:
@ -132,9 +134,6 @@ class DeltaKinematics:
for i in StepList:
self.steppers[i].motor_enable(print_time, 1)
self.need_motor_enable = False
def query_endstops(self, print_time):
endstops = [(s, s.query_endstop(print_time)) for s in self.steppers]
return [(s.name, es.query_endstop_wait()) for s, es in endstops]
def check_move(self, move):
end_pos = move.end_pos
xy2 = end_pos[0]**2 + end_pos[1]**2

View File

@ -36,18 +36,18 @@ class Homing:
print_time = self.toolhead.get_last_move_time()
endstops = []
for s in steppers:
es = s.enable_endstop_checking(print_time, s.step_dist / speed)
endstops.append((s, es, s.mcu_stepper.get_mcu_position()))
s.mcu_endstop.home_start(print_time, s.step_dist / speed)
endstops.append((s, s.mcu_stepper.get_mcu_position()))
self.toolhead.move(self._fill_coord(movepos), speed)
move_end_print_time = self.toolhead.get_last_move_time()
self.toolhead.reset_print_time()
for s, es, last_pos in endstops:
es.home_finalize(move_end_print_time)
for s, last_pos in endstops:
s.mcu_endstop.home_finalize(move_end_print_time)
# Wait for endstops to trigger
for s, es, last_pos in endstops:
for s, last_pos in endstops:
try:
es.home_wait()
except es.error as e:
s.mcu_endstop.home_wait()
except s.mcu_endstop.error as e:
raise EndstopError("Failed to home stepper %s: %s" % (
s.name, str(e)))
post_home_pos = s.mcu_stepper.get_mcu_position()
@ -57,6 +57,17 @@ class Homing:
def set_homed_position(self, pos):
self.toolhead.set_position(self._fill_coord(pos))
def query_endstops(print_time, steppers):
for s in steppers:
s.mcu_endstop.query_endstop(print_time)
out = []
for s in steppers:
try:
out.append((s.name, s.mcu_endstop.query_endstop_wait()))
except s.mcu_endstop.error as e:
raise EndstopError(str(e))
return out
class EndstopError(Exception):
pass

View File

@ -95,12 +95,6 @@ class PrinterHomingStepper(PrinterStepper):
self.homing_stepper_phases = None
if self.mcu_endstop.get_mcu().is_fileoutput():
self.homing_endstop_accuracy = self.homing_stepper_phases
def enable_endstop_checking(self, print_time, step_time):
self.mcu_endstop.home_start(print_time, step_time)
return self.mcu_endstop
def query_endstop(self, print_time):
self.mcu_endstop.query_endstop(print_time)
return self.mcu_endstop
def get_homing_speed(self):
# Round the configured homing speed so that it is an even
# number of ticks per step.

View File

@ -347,10 +347,7 @@ class ToolHead:
eventtime = self.reactor.pause(eventtime + 0.100)
def query_endstops(self):
last_move_time = self.get_last_move_time()
try:
return self.kin.query_endstops(last_move_time)
except self.mcu.error as e:
raise homing.EndstopError(str(e))
def set_extruder(self, extruder):
last_move_time = self.get_last_move_time()
self.extruder.set_active(last_move_time, False)