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:
parent
da735ab312
commit
862d3f9633
|
@ -85,9 +85,8 @@ class Homing:
|
||||||
for s, name, spos, epos in end_mcu_pos:
|
for s, name, spos, epos in end_mcu_pos:
|
||||||
md = (epos - spos) * s.get_step_dist()
|
md = (epos - spos) * s.get_step_dist()
|
||||||
s.set_tag_position(s.get_tag_position() + md)
|
s.set_tag_position(s.get_tag_position() + md)
|
||||||
self.set_homed_position(kin.calc_tag_position())
|
movepos = list(kin.calc_tag_position())[:3] + movepos[3:]
|
||||||
else:
|
self.toolhead.set_position(movepos)
|
||||||
self.toolhead.set_position(movepos)
|
|
||||||
# Signal homing/probing move complete
|
# Signal homing/probing move complete
|
||||||
try:
|
try:
|
||||||
self.printer.send_event("homing:homing_move_end",
|
self.printer.send_event("homing:homing_move_end",
|
||||||
|
@ -106,6 +105,7 @@ class Homing:
|
||||||
"Probe triggered prior to movement")
|
"Probe triggered prior to movement")
|
||||||
raise self.printer.command_error(
|
raise self.printer.command_error(
|
||||||
"Endstop %s still triggered after retract" % (name,))
|
"Endstop %s still triggered after retract" % (name,))
|
||||||
|
return movepos
|
||||||
def home_rails(self, rails, forcepos, movepos):
|
def home_rails(self, rails, forcepos, movepos):
|
||||||
# Notify of upcoming homing operation
|
# Notify of upcoming homing operation
|
||||||
self.printer.send_event("homing:home_rails_begin", self, rails)
|
self.printer.send_event("homing:home_rails_begin", self, rails)
|
||||||
|
@ -166,8 +166,12 @@ class PrinterHoming:
|
||||||
# Register g-code commands
|
# Register g-code commands
|
||||||
gcode = self.printer.lookup_object('gcode')
|
gcode = self.printer.lookup_object('gcode')
|
||||||
gcode.register_command('G28', self.cmd_G28)
|
gcode.register_command('G28', self.cmd_G28)
|
||||||
def new_homing_state(self):
|
def probing_move(self, mcu_probe, pos, speed):
|
||||||
return Homing(self.printer)
|
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):
|
def cmd_G28(self, gcmd):
|
||||||
# Move to origin
|
# Move to origin
|
||||||
axes = []
|
axes = []
|
||||||
|
|
|
@ -113,23 +113,19 @@ class PrinterProbe:
|
||||||
curtime = self.printer.get_reactor().monotonic()
|
curtime = self.printer.get_reactor().monotonic()
|
||||||
if 'z' not in toolhead.get_status(curtime)['homed_axes']:
|
if 'z' not in toolhead.get_status(curtime)['homed_axes']:
|
||||||
raise self.printer.command_error("Must home before probe")
|
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 = toolhead.get_position()
|
||||||
pos[2] = self.z_position
|
pos[2] = self.z_position
|
||||||
endstops = [(self.mcu_probe, "probe")]
|
|
||||||
verify = self.printer.get_start_args().get('debugoutput') is None
|
|
||||||
try:
|
try:
|
||||||
homing_state.homing_move(pos, endstops, speed,
|
epos = phoming.probing_move(self.mcu_probe, pos, speed)
|
||||||
probe_pos=True, verify_movement=verify)
|
|
||||||
except self.printer.command_error as e:
|
except self.printer.command_error as e:
|
||||||
reason = str(e)
|
reason = str(e)
|
||||||
if "Timeout during endstop homing" in reason:
|
if "Timeout during endstop homing" in reason:
|
||||||
reason += HINT_TIMEOUT
|
reason += HINT_TIMEOUT
|
||||||
raise self.printer.command_error(reason)
|
raise self.printer.command_error(reason)
|
||||||
pos = toolhead.get_position()
|
|
||||||
self.gcode.respond_info("probe at %.3f,%.3f is z=%.6f"
|
self.gcode.respond_info("probe at %.3f,%.3f is z=%.6f"
|
||||||
% (pos[0], pos[1], pos[2]))
|
% (epos[0], epos[1], epos[2]))
|
||||||
return pos[:3]
|
return epos[:3]
|
||||||
def _move(self, coord, speed):
|
def _move(self, coord, speed):
|
||||||
self.printer.lookup_object('toolhead').manual_move(coord, speed)
|
self.printer.lookup_object('toolhead').manual_move(coord, speed)
|
||||||
def _calc_mean(self, positions):
|
def _calc_mean(self, positions):
|
||||||
|
|
Loading…
Reference in New Issue