homing: Directly interact with the kinematic class on query_endstops()
Move the query_endstop logic out of toolhead.py and into homing.py. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
8d9ca6f2dd
commit
f6d4284d5c
|
@ -26,6 +26,8 @@ class CartKinematics:
|
|||
self.steppers[1].set_max_jerk(max_halt_velocity, max_accel)
|
||||
self.steppers[2].set_max_jerk(
|
||||
min(max_halt_velocity, self.max_z_velocity), max_accel)
|
||||
def get_steppers(self):
|
||||
return list(self.steppers)
|
||||
def set_position(self, newpos):
|
||||
for i in StepList:
|
||||
self.steppers[i].set_position(newpos[i])
|
||||
|
@ -62,8 +64,6 @@ 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, query_flags):
|
||||
return homing.query_endstops(print_time, query_flags, self.steppers)
|
||||
def motor_off(self, print_time):
|
||||
self.limits = [(1.0, -1.0)] * 3
|
||||
for stepper in self.steppers:
|
||||
|
|
|
@ -33,6 +33,8 @@ class CoreXYKinematics:
|
|||
self.steppers[1].set_max_jerk(max_xy_halt_velocity, max_accel)
|
||||
self.steppers[2].set_max_jerk(
|
||||
min(max_halt_velocity, self.max_z_velocity), self.max_z_accel)
|
||||
def get_steppers(self):
|
||||
return list(self.steppers)
|
||||
def set_position(self, newpos):
|
||||
pos = (newpos[0] + newpos[1], newpos[0] - newpos[1], newpos[2])
|
||||
for i in StepList:
|
||||
|
@ -71,8 +73,6 @@ 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, query_flags):
|
||||
return homing.query_endstops(print_time, query_flags, self.steppers)
|
||||
def motor_off(self, print_time):
|
||||
self.limits = [(1.0, -1.0)] * 3
|
||||
for stepper in self.steppers:
|
||||
|
|
|
@ -58,6 +58,8 @@ class DeltaKinematics:
|
|||
% (math.sqrt(self.max_xy2), math.sqrt(self.slow_xy2),
|
||||
math.sqrt(self.very_slow_xy2)))
|
||||
self.set_position([0., 0., 0.])
|
||||
def get_steppers(self):
|
||||
return list(self.steppers)
|
||||
def _cartesian_to_actuator(self, coord):
|
||||
return [math.sqrt(self.arm_length2
|
||||
- (self.towers[i][0] - coord[0])**2
|
||||
|
@ -124,8 +126,6 @@ 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, query_flags):
|
||||
return homing.query_endstops(print_time, query_flags, self.steppers)
|
||||
def motor_off(self, print_time):
|
||||
self.limit_xy2 = -1.
|
||||
for stepper in self.steppers:
|
||||
|
|
|
@ -409,7 +409,7 @@ class GCodeParser:
|
|||
if self.toolhead is None:
|
||||
self.cmd_default(params)
|
||||
return
|
||||
raw_pos = self.toolhead.query_endstops("get_mcu_position")
|
||||
raw_pos = homing.query_position(self.toolhead)
|
||||
self.respond("X:%.3f Y:%.3f Z:%.3f E:%.3f Count %s" % (
|
||||
self.last_position[0], self.last_position[1],
|
||||
self.last_position[2], self.last_position[3],
|
||||
|
@ -451,12 +451,7 @@ class GCodeParser:
|
|||
cmd_QUERY_ENDSTOPS_aliases = ["M119"]
|
||||
def cmd_QUERY_ENDSTOPS(self, params):
|
||||
# Get Endstop Status
|
||||
if self.is_fileinput:
|
||||
return
|
||||
try:
|
||||
res = self.toolhead.query_endstops()
|
||||
except homing.EndstopError as e:
|
||||
raise error(str(e))
|
||||
res = homing.query_endstops(self.toolhead)
|
||||
self.respond(" ".join(["%s:%s" % (name, ["open", "TRIGGERED"][not not t])
|
||||
for name, t in res]))
|
||||
cmd_PID_TUNE_help = "Run PID Tuning"
|
||||
|
|
|
@ -87,11 +87,9 @@ class Homing:
|
|||
self.toolhead.motor_off()
|
||||
raise
|
||||
|
||||
def query_endstops(print_time, query_flags, steppers):
|
||||
if query_flags == "get_mcu_position":
|
||||
# Only the commanded position is requested
|
||||
return [(s.name.upper(), s.mcu_stepper.get_mcu_position())
|
||||
for s in steppers]
|
||||
def query_endstops(toolhead):
|
||||
print_time = toolhead.get_last_move_time()
|
||||
steppers = toolhead.get_kinematics().get_steppers()
|
||||
out = []
|
||||
for s in steppers:
|
||||
for mcu_endstop, name in s.get_endstops():
|
||||
|
@ -101,6 +99,10 @@ def query_endstops(print_time, query_flags, steppers):
|
|||
out.append((name, mcu_endstop.query_endstop_wait()))
|
||||
return out
|
||||
|
||||
def query_position(toolhead):
|
||||
steppers = toolhead.get_kinematics().get_steppers()
|
||||
return [(s.name.upper(), s.mcu_stepper.get_mcu_position()) for s in steppers]
|
||||
|
||||
class EndstopError(Exception):
|
||||
pass
|
||||
|
||||
|
|
|
@ -348,9 +348,6 @@ class ToolHead:
|
|||
while (not self.sync_print_time
|
||||
or self.print_time >= self.mcu.estimated_print_time(eventtime)):
|
||||
eventtime = self.reactor.pause(eventtime + 0.100)
|
||||
def query_endstops(self, query_flags=""):
|
||||
last_move_time = self.get_last_move_time()
|
||||
return self.kin.query_endstops(last_move_time, query_flags)
|
||||
def set_extruder(self, extruder):
|
||||
last_move_time = self.get_last_move_time()
|
||||
self.extruder.set_active(last_move_time, False)
|
||||
|
|
Loading…
Reference in New Issue