bed_mesh: move probe x and y offsets to the [probe] module
All probe offsets are now passed to the finalize() callback in the ProbePointsHelper Class. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
52df40dfbb
commit
3387cccdcf
|
@ -17,6 +17,12 @@
|
||||||
#[probe]
|
#[probe]
|
||||||
#pin: ar15
|
#pin: ar15
|
||||||
# Probe detection pin. This parameter must be provided.
|
# Probe detection pin. This parameter must be provided.
|
||||||
|
#x_offset: 0.0
|
||||||
|
# The distance (in mm) between the probe and the nozzle along the
|
||||||
|
# x-axis. The default is 0.
|
||||||
|
#y_offset: 0.0
|
||||||
|
# The distance (in mm) between the probe and the nozzle along the
|
||||||
|
# y-axis. The default is 0.
|
||||||
#z_offset:
|
#z_offset:
|
||||||
# The distance (in mm) between the bed and the nozzle when the probe
|
# The distance (in mm) between the bed and the nozzle when the probe
|
||||||
# triggers. This parameter must be provided.
|
# triggers. This parameter must be provided.
|
||||||
|
@ -76,9 +82,6 @@
|
||||||
#horizontal_move_z: 5
|
#horizontal_move_z: 5
|
||||||
# The height (in mm) that the head should be commanded to move to
|
# The height (in mm) that the head should be commanded to move to
|
||||||
# just prior to starting a probe operation. The default is 5.
|
# just prior to starting a probe operation. The default is 5.
|
||||||
#probe_offset:
|
|
||||||
# An X,Y point defining the probe's offset relative to the nozzle.
|
|
||||||
# This parameter must be provided.
|
|
||||||
#min_point:
|
#min_point:
|
||||||
# An X,Y point defining the minimum coordinate to probe on
|
# An X,Y point defining the minimum coordinate to probe on
|
||||||
# the bed. Note that this refers to the nozzle position,
|
# the bed. Note that this refers to the nozzle position,
|
||||||
|
@ -123,6 +126,9 @@
|
||||||
# may be applied to change the amount of slope interpolated.
|
# may be applied to change the amount of slope interpolated.
|
||||||
# Larger numbers will increase the amount of slope, which
|
# Larger numbers will increase the amount of slope, which
|
||||||
# results in more curvature in the mesh. Default is .2.
|
# results in more curvature in the mesh. Default is .2.
|
||||||
|
#manual_probe:
|
||||||
|
# See the manual_probe option of [bed_tilt] for details. The default
|
||||||
|
# is false if a [probe] config section is present and true otherwise.
|
||||||
|
|
||||||
|
|
||||||
# Multiple Z stepper tilt adjustment. This feature enables independent
|
# Multiple Z stepper tilt adjustment. This feature enables independent
|
||||||
|
|
|
@ -187,9 +187,6 @@ class BedMeshCalibrate:
|
||||||
self.probe_params['max_x'] = max(points, key=lambda p: p[0])[0]
|
self.probe_params['max_x'] = max(points, key=lambda p: p[0])[0]
|
||||||
self.probe_params['min_y'] = min(points, key=lambda p: p[1])[1]
|
self.probe_params['min_y'] = min(points, key=lambda p: p[1])[1]
|
||||||
self.probe_params['max_y'] = max(points, key=lambda p: p[1])[1]
|
self.probe_params['max_y'] = max(points, key=lambda p: p[1])[1]
|
||||||
offset = parse_pair(config, ('probe_offset',))
|
|
||||||
self.probe_params['x_offset'] = offset[0]
|
|
||||||
self.probe_params['y_offset'] = offset[1]
|
|
||||||
pps = parse_pair(config, ('mesh_pps', '2'), check=False,
|
pps = parse_pair(config, ('mesh_pps', '2'), check=False,
|
||||||
cast=int, minval=0)
|
cast=int, minval=0)
|
||||||
self.probe_params['mesh_x_pps'] = pps[0]
|
self.probe_params['mesh_x_pps'] = pps[0]
|
||||||
|
@ -202,9 +199,6 @@ class BedMeshCalibrate:
|
||||||
% (self.probe_params['algo']))
|
% (self.probe_params['algo']))
|
||||||
self.probe_params['tension'] = config.getfloat(
|
self.probe_params['tension'] = config.getfloat(
|
||||||
'bicubic_tension', .2, minval=0., maxval=2.)
|
'bicubic_tension', .2, minval=0., maxval=2.)
|
||||||
logging.debug('bed_mesh: probe/mesh parameters:')
|
|
||||||
for key, value in self.probe_params.iteritems():
|
|
||||||
logging.debug("%s : %s" % (key, value))
|
|
||||||
cmd_BED_MESH_MAP_help = "Probe the bed and serialize output"
|
cmd_BED_MESH_MAP_help = "Probe the bed and serialize output"
|
||||||
def cmd_BED_MESH_MAP(self, params):
|
def cmd_BED_MESH_MAP(self, params):
|
||||||
self.build_map = True
|
self.build_map = True
|
||||||
|
@ -230,7 +224,10 @@ class BedMeshCalibrate:
|
||||||
print_func(msg)
|
print_func(msg)
|
||||||
else:
|
else:
|
||||||
print_func("bed_mesh: bed has not been probed")
|
print_func("bed_mesh: bed has not been probed")
|
||||||
def finalize(self, z_offset, positions):
|
def finalize(self, offsets, positions):
|
||||||
|
self.probe_params['x_offset'] = offsets[0]
|
||||||
|
self.probe_params['y_offset'] = offsets[1]
|
||||||
|
z_offset = offsets[2]
|
||||||
if self.probe_helper.get_last_xy_home_positon() is not None \
|
if self.probe_helper.get_last_xy_home_positon() is not None \
|
||||||
and self.z_endstop_pos is not None:
|
and self.z_endstop_pos is not None:
|
||||||
# Using probe as a virtual endstop, warn user if the
|
# Using probe as a virtual endstop, warn user if the
|
||||||
|
@ -271,7 +268,6 @@ class BedMeshCalibrate:
|
||||||
except BedMeshError as e:
|
except BedMeshError as e:
|
||||||
raise self.gcode.error(e.message)
|
raise self.gcode.error(e.message)
|
||||||
self.bedmesh.set_mesh(mesh)
|
self.bedmesh.set_mesh(mesh)
|
||||||
self.print_probed_positions(logging.debug)
|
|
||||||
self.gcode.respond_info("Mesh Bed Leveling Complete")
|
self.gcode.respond_info("Mesh Bed Leveling Complete")
|
||||||
|
|
||||||
|
|
||||||
|
@ -344,6 +340,9 @@ class ZMesh:
|
||||||
def __init__(self, params):
|
def __init__(self, params):
|
||||||
self.mesh_z_table = None
|
self.mesh_z_table = None
|
||||||
self.probe_params = params
|
self.probe_params = params
|
||||||
|
logging.debug('bed_mesh: probe/mesh parameters:')
|
||||||
|
for key, value in self.probe_params.iteritems():
|
||||||
|
logging.debug("%s : %s" % (key, value))
|
||||||
self.mesh_x_min = params['min_x'] + params['x_offset']
|
self.mesh_x_min = params['min_x'] + params['x_offset']
|
||||||
self.mesh_x_max = params['max_x'] + params['x_offset']
|
self.mesh_x_max = params['max_x'] + params['x_offset']
|
||||||
self.mesh_y_min = params['min_y'] + params['y_offset']
|
self.mesh_y_min = params['min_y'] + params['y_offset']
|
||||||
|
|
|
@ -51,7 +51,8 @@ class BedTiltCalibrate:
|
||||||
def get_probed_position(self):
|
def get_probed_position(self):
|
||||||
kin = self.printer.lookup_object('toolhead').get_kinematics()
|
kin = self.printer.lookup_object('toolhead').get_kinematics()
|
||||||
return kin.calc_position()
|
return kin.calc_position()
|
||||||
def finalize(self, z_offset, positions):
|
def finalize(self, offsets, positions):
|
||||||
|
z_offset = offsets[2]
|
||||||
logging.info("Calculating bed_tilt with: %s", positions)
|
logging.info("Calculating bed_tilt with: %s", positions)
|
||||||
params = { 'x_adjust': self.bedtilt.x_adjust,
|
params = { 'x_adjust': self.bedtilt.x_adjust,
|
||||||
'y_adjust': self.bedtilt.y_adjust,
|
'y_adjust': self.bedtilt.y_adjust,
|
||||||
|
|
|
@ -33,7 +33,8 @@ class DeltaCalibrate:
|
||||||
def get_probed_position(self):
|
def get_probed_position(self):
|
||||||
kin = self.printer.lookup_object('toolhead').get_kinematics()
|
kin = self.printer.lookup_object('toolhead').get_kinematics()
|
||||||
return kin.get_stable_position()
|
return kin.get_stable_position()
|
||||||
def finalize(self, z_offset, positions):
|
def finalize(self, offsets, positions):
|
||||||
|
z_offset = offsets[2]
|
||||||
kin = self.printer.lookup_object('toolhead').get_kinematics()
|
kin = self.printer.lookup_object('toolhead').get_kinematics()
|
||||||
logging.info("Calculating delta_calibrate with: %s", positions)
|
logging.info("Calculating delta_calibrate with: %s", positions)
|
||||||
params = kin.get_calibrate_params()
|
params = kin.get_calibrate_params()
|
||||||
|
|
|
@ -16,6 +16,8 @@ class PrinterProbe:
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.printer = config.get_printer()
|
self.printer = config.get_printer()
|
||||||
self.speed = config.getfloat('speed', 5.0)
|
self.speed = config.getfloat('speed', 5.0)
|
||||||
|
self.x_offset = config.getfloat('x_offset', 0.)
|
||||||
|
self.y_offset = config.getfloat('y_offset', 0.)
|
||||||
self.z_offset = config.getfloat('z_offset')
|
self.z_offset = config.getfloat('z_offset')
|
||||||
# Infer Z position to move to during a probe
|
# Infer Z position to move to during a probe
|
||||||
if config.has_section('stepper_z'):
|
if config.has_section('stepper_z'):
|
||||||
|
@ -55,6 +57,8 @@ class PrinterProbe:
|
||||||
self.z_virtual_endstop = ProbeVirtualEndstop(
|
self.z_virtual_endstop = ProbeVirtualEndstop(
|
||||||
self.printer, self.mcu_probe)
|
self.printer, self.mcu_probe)
|
||||||
return self.z_virtual_endstop
|
return self.z_virtual_endstop
|
||||||
|
def get_offsets(self):
|
||||||
|
return self.x_offset, self.y_offset, self.z_offset
|
||||||
def last_home_position(self):
|
def last_home_position(self):
|
||||||
if self.z_virtual_endstop is None:
|
if self.z_virtual_endstop is None:
|
||||||
return None
|
return None
|
||||||
|
@ -153,7 +157,7 @@ class ProbePointsHelper:
|
||||||
self.speed = self.lift_speed = config.getfloat('speed', 50., above=0.)
|
self.speed = self.lift_speed = config.getfloat('speed', 50., above=0.)
|
||||||
# Lookup probe object
|
# Lookup probe object
|
||||||
self.probe = None
|
self.probe = None
|
||||||
self.probe_z_offset = 0.
|
self.probe_offsets = (0., 0., 0.)
|
||||||
manual_probe = config.getboolean('manual_probe', None)
|
manual_probe = config.getboolean('manual_probe', None)
|
||||||
if manual_probe is None:
|
if manual_probe is None:
|
||||||
manual_probe = not config.has_section('probe')
|
manual_probe = not config.has_section('probe')
|
||||||
|
@ -161,8 +165,8 @@ class ProbePointsHelper:
|
||||||
self.printer.try_load_module(config, 'probe')
|
self.printer.try_load_module(config, 'probe')
|
||||||
self.probe = self.printer.lookup_object('probe')
|
self.probe = self.printer.lookup_object('probe')
|
||||||
self.lift_speed = min(self.speed, self.probe.speed)
|
self.lift_speed = min(self.speed, self.probe.speed)
|
||||||
self.probe_z_offset = self.probe.z_offset
|
self.probe_offsets = self.probe.get_offsets()
|
||||||
if self.horizontal_move_z < self.probe_z_offset:
|
if self.horizontal_move_z < self.probe_offsets[2]:
|
||||||
raise config.error("horizontal_move_z can't be less than probe's"
|
raise config.error("horizontal_move_z can't be less than probe's"
|
||||||
" z_offset in %s" % (config.get_name()))
|
" z_offset in %s" % (config.get_name()))
|
||||||
# Internal probing state
|
# Internal probing state
|
||||||
|
@ -229,7 +233,7 @@ class ProbePointsHelper:
|
||||||
self.gcode.reset_last_position()
|
self.gcode.reset_last_position()
|
||||||
self.gcode.register_command('NEXT', None)
|
self.gcode.register_command('NEXT', None)
|
||||||
if success:
|
if success:
|
||||||
self.callback.finalize(self.probe_z_offset, self.results)
|
self.callback.finalize(self.probe_offsets, self.results)
|
||||||
|
|
||||||
def load_config(config):
|
def load_config(config):
|
||||||
return PrinterProbe(config)
|
return PrinterProbe(config)
|
||||||
|
|
|
@ -43,7 +43,8 @@ class ZTilt:
|
||||||
def get_probed_position(self):
|
def get_probed_position(self):
|
||||||
kin = self.printer.lookup_object('toolhead').get_kinematics()
|
kin = self.printer.lookup_object('toolhead').get_kinematics()
|
||||||
return kin.calc_position()
|
return kin.calc_position()
|
||||||
def finalize(self, z_offset, positions):
|
def finalize(self, offsets, positions):
|
||||||
|
z_offset = offsets[2]
|
||||||
logging.info("Calculating bed tilt with: %s", positions)
|
logging.info("Calculating bed tilt with: %s", positions)
|
||||||
params = { 'x_adjust': 0., 'y_adjust': 0., 'z_adjust': z_offset }
|
params = { 'x_adjust': 0., 'y_adjust': 0., 'z_adjust': z_offset }
|
||||||
def adjusted_height(pos, params):
|
def adjusted_height(pos, params):
|
||||||
|
|
Loading…
Reference in New Issue