homing: Move low-level probing logic from probe.py to homing.py

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2021-03-29 10:05:39 -04:00
parent da735ab312
commit 862d3f9633
2 changed files with 13 additions and 13 deletions

View File

@ -85,9 +85,8 @@ class Homing:
for s, name, spos, epos in end_mcu_pos:
md = (epos - spos) * s.get_step_dist()
s.set_tag_position(s.get_tag_position() + md)
self.set_homed_position(kin.calc_tag_position())
else:
self.toolhead.set_position(movepos)
movepos = list(kin.calc_tag_position())[:3] + movepos[3:]
self.toolhead.set_position(movepos)
# Signal homing/probing move complete
try:
self.printer.send_event("homing:homing_move_end",
@ -106,6 +105,7 @@ class Homing:
"Probe triggered prior to movement")
raise self.printer.command_error(
"Endstop %s still triggered after retract" % (name,))
return movepos
def home_rails(self, rails, forcepos, movepos):
# Notify of upcoming homing operation
self.printer.send_event("homing:home_rails_begin", self, rails)
@ -166,8 +166,12 @@ class PrinterHoming:
# Register g-code commands
gcode = self.printer.lookup_object('gcode')
gcode.register_command('G28', self.cmd_G28)
def new_homing_state(self):
return Homing(self.printer)
def probing_move(self, mcu_probe, pos, speed):
homing_state = Homing(self.printer)
endstops = [(mcu_probe, "probe")]
verify = self.printer.get_start_args().get('debugoutput') is None
return homing_state.homing_move(pos, endstops, speed,
probe_pos=True, verify_movement=verify)
def cmd_G28(self, gcmd):
# Move to origin
axes = []

View File

@ -113,23 +113,19 @@ class PrinterProbe:
curtime = self.printer.get_reactor().monotonic()
if 'z' not in toolhead.get_status(curtime)['homed_axes']:
raise self.printer.command_error("Must home before probe")
homing_state = self.printer.lookup_object('homing').new_homing_state()
phoming = self.printer.lookup_object('homing')
pos = toolhead.get_position()
pos[2] = self.z_position
endstops = [(self.mcu_probe, "probe")]
verify = self.printer.get_start_args().get('debugoutput') is None
try:
homing_state.homing_move(pos, endstops, speed,
probe_pos=True, verify_movement=verify)
epos = phoming.probing_move(self.mcu_probe, pos, speed)
except self.printer.command_error as e:
reason = str(e)
if "Timeout during endstop homing" in reason:
reason += HINT_TIMEOUT
raise self.printer.command_error(reason)
pos = toolhead.get_position()
self.gcode.respond_info("probe at %.3f,%.3f is z=%.6f"
% (pos[0], pos[1], pos[2]))
return pos[:3]
% (epos[0], epos[1], epos[2]))
return epos[:3]
def _move(self, coord, speed):
self.printer.lookup_object('toolhead').manual_move(coord, speed)
def _calc_mean(self, positions):