mirror of https://github.com/Desuuuu/klipper.git
probe: Infer position_endstop when using probe:z_virtual_offset
Don't require (or permit) the user to specify a stepper_z position_endstop when using the probe:z_virtual_offset mechanism. In that case the position_endstop should always equal the probe's z_offset - so no need to have the user specify it. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
a9a0bb87fa
commit
c5d4e14298
|
@ -13,7 +13,9 @@
|
||||||
# QUERY_PROBE extended g-code commands become available. The probe
|
# QUERY_PROBE extended g-code commands become available. The probe
|
||||||
# section also creates a virtual "probe:z_virtual_endstop" pin. One
|
# section also creates a virtual "probe:z_virtual_endstop" pin. One
|
||||||
# may set the stepper_z endstop_pin to this virtual pin on cartesian
|
# may set the stepper_z endstop_pin to this virtual pin on cartesian
|
||||||
# style printers that use the probe in place of a z endstop.
|
# style printers that use the probe in place of a z endstop. If using
|
||||||
|
# "probe:z_virtual_endstop" then do not define a position_endstop in
|
||||||
|
# the stepper_z config section.
|
||||||
#[probe]
|
#[probe]
|
||||||
#pin: ar15
|
#pin: ar15
|
||||||
# Probe detection pin. This parameter must be provided.
|
# Probe detection pin. This parameter must be provided.
|
||||||
|
|
|
@ -30,8 +30,6 @@ deactivate_gcode:
|
||||||
|
|
||||||
# Example bed_tilt config section
|
# Example bed_tilt config section
|
||||||
[bed_tilt]
|
[bed_tilt]
|
||||||
#x_adjust:
|
|
||||||
#y_adjust:
|
|
||||||
points:
|
points:
|
||||||
100,100
|
100,100
|
||||||
10,10
|
10,10
|
||||||
|
@ -45,8 +43,8 @@ points:
|
||||||
|
|
||||||
# If the BLTouch is used to home the Z axis, then define a
|
# If the BLTouch is used to home the Z axis, then define a
|
||||||
# homing_override section, use probe:z_virtual_endstop as the
|
# homing_override section, use probe:z_virtual_endstop as the
|
||||||
# endstop_pin in the stepper_z section, and set the position_endstop
|
# endstop_pin in the stepper_z section, and do not set
|
||||||
# in the stepper_z section to match the probe's z_offset.
|
# position_endstop in the stepper_z section.
|
||||||
#[homing_override]
|
#[homing_override]
|
||||||
#set_position_z: 5
|
#set_position_z: 5
|
||||||
#axes: z
|
#axes: z
|
||||||
|
|
|
@ -138,11 +138,6 @@ class BedMeshCalibrate:
|
||||||
self._init_probe_params(config, points)
|
self._init_probe_params(config, points)
|
||||||
self.probe_helper = probe.ProbePointsHelper(
|
self.probe_helper = probe.ProbePointsHelper(
|
||||||
config, self.probe_finalize, points)
|
config, self.probe_finalize, points)
|
||||||
self.z_endstop_pos = None
|
|
||||||
if config.has_section('stepper_z'):
|
|
||||||
zconfig = config.getsection('stepper_z')
|
|
||||||
self.z_endstop_pos = zconfig.getfloat(
|
|
||||||
'position_endstop', None)
|
|
||||||
self.gcode = self.printer.lookup_object('gcode')
|
self.gcode = self.printer.lookup_object('gcode')
|
||||||
self.gcode.register_command(
|
self.gcode.register_command(
|
||||||
'BED_MESH_CALIBRATE', self.cmd_BED_MESH_CALIBRATE,
|
'BED_MESH_CALIBRATE', self.cmd_BED_MESH_CALIBRATE,
|
||||||
|
@ -227,18 +222,6 @@ class BedMeshCalibrate:
|
||||||
self.probe_params['x_offset'] = offsets[0]
|
self.probe_params['x_offset'] = offsets[0]
|
||||||
self.probe_params['y_offset'] = offsets[1]
|
self.probe_params['y_offset'] = offsets[1]
|
||||||
z_offset = offsets[2]
|
z_offset = offsets[2]
|
||||||
if self.probe_helper.get_last_xy_home_positon() is not None \
|
|
||||||
and self.z_endstop_pos is not None:
|
|
||||||
# Using probe as a virtual endstop, warn user if the
|
|
||||||
# stepper_z position_endstop is different
|
|
||||||
if self.z_endstop_pos != z_offset:
|
|
||||||
z_msg = "bed_mesh: WARN - probe z_offset is not" \
|
|
||||||
" equal to Z position_endstop\n"
|
|
||||||
z_msg += "[probe] z_offset: %.4f\n" % z_offset
|
|
||||||
z_msg += "[stepper_z] position_endstop: %.4f" \
|
|
||||||
% self.z_endstop_pos
|
|
||||||
logging.info(z_msg)
|
|
||||||
self.gcode.respond_info(z_msg)
|
|
||||||
x_cnt = self.probe_params['x_count']
|
x_cnt = self.probe_params['x_count']
|
||||||
y_cnt = self.probe_params['y_count']
|
y_cnt = self.probe_params['y_count']
|
||||||
# create a 2-D array representing the probed z-positions.
|
# create a 2-D array representing the probed z-positions.
|
||||||
|
|
|
@ -38,7 +38,6 @@ class PrinterProbe:
|
||||||
self.mcu_probe = ProbeEndstopWrapper(config, self.mcu_probe)
|
self.mcu_probe = ProbeEndstopWrapper(config, self.mcu_probe)
|
||||||
# Create z_virtual_endstop pin
|
# Create z_virtual_endstop pin
|
||||||
ppins.register_chip('probe', self)
|
ppins.register_chip('probe', self)
|
||||||
self.z_virtual_endstop = None
|
|
||||||
# Register PROBE/QUERY_PROBE commands
|
# Register PROBE/QUERY_PROBE commands
|
||||||
self.gcode = self.printer.lookup_object('gcode')
|
self.gcode = self.printer.lookup_object('gcode')
|
||||||
self.gcode.register_command(
|
self.gcode.register_command(
|
||||||
|
@ -54,15 +53,9 @@ class PrinterProbe:
|
||||||
raise pins.error("Probe virtual endstop only useful as endstop pin")
|
raise pins.error("Probe virtual endstop only useful as endstop pin")
|
||||||
if pin_params['invert'] or pin_params['pullup']:
|
if pin_params['invert'] or pin_params['pullup']:
|
||||||
raise pins.error("Can not pullup/invert probe virtual endstop")
|
raise pins.error("Can not pullup/invert probe virtual endstop")
|
||||||
self.z_virtual_endstop = ProbeVirtualEndstop(
|
return ProbeVirtualEndstop(self, self.mcu_probe)
|
||||||
self.printer, self.mcu_probe)
|
|
||||||
return self.z_virtual_endstop
|
|
||||||
def get_offsets(self):
|
def get_offsets(self):
|
||||||
return self.x_offset, self.y_offset, self.z_offset
|
return self.x_offset, self.y_offset, self.z_offset
|
||||||
def last_home_position(self):
|
|
||||||
if self.z_virtual_endstop is None:
|
|
||||||
return None
|
|
||||||
return self.z_virtual_endstop.position
|
|
||||||
cmd_PROBE_help = "Probe Z-height at current XY position"
|
cmd_PROBE_help = "Probe Z-height at current XY position"
|
||||||
def cmd_PROBE(self, params):
|
def cmd_PROBE(self, params):
|
||||||
toolhead = self.printer.lookup_object('toolhead')
|
toolhead = self.printer.lookup_object('toolhead')
|
||||||
|
@ -112,25 +105,24 @@ class ProbeEndstopWrapper:
|
||||||
self.gcode.run_script_from_command(self.deactivate_gcode)
|
self.gcode.run_script_from_command(self.deactivate_gcode)
|
||||||
self.mcu_endstop.home_finalize()
|
self.mcu_endstop.home_finalize()
|
||||||
|
|
||||||
# Wrapper that records the last XY position of a virtual endstop probe
|
# Wrapper for probe:z_virtual_endstop handling
|
||||||
class ProbeVirtualEndstop:
|
class ProbeVirtualEndstop:
|
||||||
def __init__(self, printer, mcu_endstop):
|
def __init__(self, probe, mcu_endstop):
|
||||||
self.printer = printer
|
self.probe = probe
|
||||||
self.mcu_endstop = mcu_endstop
|
self.mcu_endstop = mcu_endstop
|
||||||
self.position = None
|
|
||||||
# Wrappers
|
# Wrappers
|
||||||
self.get_mcu = self.mcu_endstop.get_mcu
|
self.get_mcu = self.mcu_endstop.get_mcu
|
||||||
self.add_stepper = self.mcu_endstop.add_stepper
|
self.add_stepper = self.mcu_endstop.add_stepper
|
||||||
self.get_steppers = self.mcu_endstop.get_steppers
|
self.get_steppers = self.mcu_endstop.get_steppers
|
||||||
self.home_start = self.mcu_endstop.home_start
|
self.home_start = self.mcu_endstop.home_start
|
||||||
self.home_wait = self.mcu_endstop.home_wait
|
self.home_wait = self.mcu_endstop.home_wait
|
||||||
|
self.home_finalize = self.mcu_endstop.home_finalize
|
||||||
self.query_endstop = self.mcu_endstop.query_endstop
|
self.query_endstop = self.mcu_endstop.query_endstop
|
||||||
self.query_endstop_wait = self.mcu_endstop.query_endstop_wait
|
self.query_endstop_wait = self.mcu_endstop.query_endstop_wait
|
||||||
self.home_prepare = self.mcu_endstop.home_prepare
|
self.home_prepare = self.mcu_endstop.home_prepare
|
||||||
self.TimeoutError = self.mcu_endstop.TimeoutError
|
self.TimeoutError = self.mcu_endstop.TimeoutError
|
||||||
def home_finalize(self):
|
def get_position_endstop(self):
|
||||||
self.position = self.printer.lookup_object('toolhead').get_position()
|
return self.probe.get_offsets()[2]
|
||||||
self.mcu_endstop.home_finalize()
|
|
||||||
|
|
||||||
# Helper code that can probe a series of points and report the
|
# Helper code that can probe a series of points and report the
|
||||||
# position at each point.
|
# position at each point.
|
||||||
|
@ -164,11 +156,6 @@ class ProbePointsHelper:
|
||||||
self.gcode = self.toolhead = None
|
self.gcode = self.toolhead = None
|
||||||
def get_lift_speed(self):
|
def get_lift_speed(self):
|
||||||
return self.lift_speed
|
return self.lift_speed
|
||||||
def get_last_xy_home_positon(self):
|
|
||||||
probe = self.printer.lookup_object('probe', None)
|
|
||||||
if probe is None:
|
|
||||||
return None
|
|
||||||
return probe.last_home_position()
|
|
||||||
def _lift_z(self, z_pos, add=False, speed=None):
|
def _lift_z(self, z_pos, add=False, speed=None):
|
||||||
# Lift toolhead
|
# Lift toolhead
|
||||||
curpos = self.toolhead.get_position()
|
curpos = self.toolhead.get_position()
|
||||||
|
|
|
@ -121,7 +121,9 @@ class PrinterRail:
|
||||||
mcu_endstop = ppins.setup_pin('endstop', config.get('endstop_pin'))
|
mcu_endstop = ppins.setup_pin('endstop', config.get('endstop_pin'))
|
||||||
self.endstops = [(mcu_endstop, self.name)]
|
self.endstops = [(mcu_endstop, self.name)]
|
||||||
stepper.add_to_endstop(mcu_endstop)
|
stepper.add_to_endstop(mcu_endstop)
|
||||||
if default_position_endstop is None:
|
if hasattr(mcu_endstop, "get_position_endstop"):
|
||||||
|
self.position_endstop = mcu_endstop.get_position_endstop()
|
||||||
|
elif default_position_endstop is None:
|
||||||
self.position_endstop = config.getfloat('position_endstop')
|
self.position_endstop = config.getfloat('position_endstop')
|
||||||
else:
|
else:
|
||||||
self.position_endstop = config.getfloat(
|
self.position_endstop = config.getfloat(
|
||||||
|
|
Loading…
Reference in New Issue