bed_mesh: Add x,y offsets to min/max points in probe_finalize

This eliminates the need for the "mesh_params" dict to have references to the x and y offsets.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2019-11-14 17:40:43 -05:00 committed by KevinOConnor
parent 5b20ac416c
commit fe929e4696
1 changed files with 13 additions and 18 deletions

View File

@ -298,8 +298,6 @@ class BedMeshCalibrate:
self.points[rri][1] - y_offset, self.points[rri][1] - y_offset,
self.points[rri][0], self.points[rri][1])) self.points[rri][0], self.points[rri][1]))
def _init_mesh_params(self, config, points): def _init_mesh_params(self, config, points):
self.mesh_params['x_offset'] = 0.
self.mesh_params['y_offset'] = 0.
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.mesh_params['mesh_x_pps'] = pps[0] self.mesh_params['mesh_x_pps'] = pps[0]
@ -428,16 +426,14 @@ class BedMeshCalibrate:
else: else:
print_func("bed_mesh: bed has not been probed") print_func("bed_mesh: bed has not been probed")
def probe_finalize(self, offsets, positions): def probe_finalize(self, offsets, positions):
self.mesh_params['x_offset'] = offsets[0] x_offset, y_offset, z_offset = offsets
self.mesh_params['y_offset'] = offsets[1] params = self.mesh_params
self.mesh_params['min_x'] = min(positions, key=lambda p: p[0])[0] params['min_x'] = min(positions, key=lambda p: p[0])[0] + x_offset
self.mesh_params['max_x'] = max(positions, key=lambda p: p[0])[0] params['max_x'] = max(positions, key=lambda p: p[0])[0] + x_offset
self.mesh_params['min_y'] = min(positions, key=lambda p: p[1])[1] params['min_y'] = min(positions, key=lambda p: p[1])[1] + y_offset
self.mesh_params['max_y'] = max(positions, key=lambda p: p[1])[1] params['max_y'] = max(positions, key=lambda p: p[1])[1] + y_offset
x_cnt = params['x_count']
z_offset = offsets[2] y_cnt = params['y_count']
x_cnt = self.mesh_params['x_count']
y_cnt = self.mesh_params['y_count']
if self.relative_reference_index is not None: if self.relative_reference_index is not None:
# zero out probe z offset and # zero out probe z offset and
@ -496,7 +492,6 @@ class BedMeshCalibrate:
(len(self.probed_matrix), str(self.probed_matrix))) (len(self.probed_matrix), str(self.probed_matrix)))
if self.build_map: if self.build_map:
params = self.mesh_params
outdict = { outdict = {
'min_point': (params['min_x'], params['min_y']), 'min_point': (params['min_x'], params['min_y']),
'max_point': (params['max_x'], params['max_y']), 'max_point': (params['max_x'], params['max_y']),
@ -505,7 +500,7 @@ class BedMeshCalibrate:
self.gcode.respond( self.gcode.respond(
"mesh_map_output " + json.dumps(outdict)) "mesh_map_output " + json.dumps(outdict))
else: else:
mesh = ZMesh(self.mesh_params) mesh = ZMesh(params)
try: try:
mesh.build_mesh(self.probed_matrix) mesh.build_mesh(self.probed_matrix)
except BedMeshError as e: except BedMeshError as e:
@ -585,10 +580,10 @@ class ZMesh:
logging.debug('bed_mesh: probe/mesh parameters:') logging.debug('bed_mesh: probe/mesh parameters:')
for key, value in self.mesh_params.iteritems(): for key, value in self.mesh_params.iteritems():
logging.debug("%s : %s" % (key, value)) logging.debug("%s : %s" % (key, value))
self.mesh_x_min = params['min_x'] + params['x_offset'] self.mesh_x_min = params['min_x']
self.mesh_x_max = params['max_x'] + params['x_offset'] self.mesh_x_max = params['max_x']
self.mesh_y_min = params['min_y'] + params['y_offset'] self.mesh_y_min = params['min_y']
self.mesh_y_max = params['max_y'] + params['y_offset'] self.mesh_y_max = params['max_y']
logging.debug( logging.debug(
"bed_mesh: Mesh Min: (%.2f,%.2f) Mesh Max: (%.2f,%.2f)" "bed_mesh: Mesh Min: (%.2f,%.2f) Mesh Max: (%.2f,%.2f)"
% (self.mesh_x_min, self.mesh_y_min, % (self.mesh_x_min, self.mesh_y_min,