bed_mesh: move the "fade offset" out of the ZMesh
This is a temporary offset applied to the mesh used to fade toward a "target". For clarity, apply the fade offset when the final z calculation is made. SIgned-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
87e12c0430
commit
4dfe01a2cd
|
@ -118,8 +118,6 @@ class BedMesh:
|
||||||
"bed_mesh: ERROR, fade_target lies outside of mesh z "
|
"bed_mesh: ERROR, fade_target lies outside of mesh z "
|
||||||
"range\nmin: %.4f, max: %.4f, fade_target: %.4f"
|
"range\nmin: %.4f, max: %.4f, fade_target: %.4f"
|
||||||
% (min_z, max_z, err_target))
|
% (min_z, max_z, err_target))
|
||||||
if self.fade_target:
|
|
||||||
mesh.offset_mesh(self.fade_target)
|
|
||||||
min_z, max_z = mesh.get_z_range()
|
min_z, max_z = mesh.get_z_range()
|
||||||
if self.fade_dist <= max(abs(min_z), abs(max_z)):
|
if self.fade_dist <= max(abs(min_z), abs(max_z)):
|
||||||
self.z_mesh = None
|
self.z_mesh = None
|
||||||
|
@ -132,7 +130,7 @@ class BedMesh:
|
||||||
else:
|
else:
|
||||||
self.fade_target = 0.
|
self.fade_target = 0.
|
||||||
self.z_mesh = mesh
|
self.z_mesh = mesh
|
||||||
self.splitter.initialize(mesh)
|
self.splitter.initialize(mesh, self.fade_target)
|
||||||
# cache the current position before a transform takes place
|
# cache the current position before a transform takes place
|
||||||
gcode_move = self.printer.lookup_object('gcode_move')
|
gcode_move = self.printer.lookup_object('gcode_move')
|
||||||
gcode_move.reset_last_position()
|
gcode_move.reset_last_position()
|
||||||
|
@ -152,9 +150,9 @@ class BedMesh:
|
||||||
else:
|
else:
|
||||||
# return current position minus the current z-adjustment
|
# return current position minus the current z-adjustment
|
||||||
x, y, z, e = self.toolhead.get_position()
|
x, y, z, e = self.toolhead.get_position()
|
||||||
z_adj = self.z_mesh.calc_z(x, y)
|
max_adj = self.z_mesh.calc_z(x, y)
|
||||||
factor = 1.
|
factor = 1.
|
||||||
max_adj = z_adj + self.fade_target
|
z_adj = max_adj - self.fade_target
|
||||||
if min(z, (z - max_adj)) >= self.fade_end:
|
if min(z, (z - max_adj)) >= self.fade_end:
|
||||||
# Fade out is complete, no factor
|
# Fade out is complete, no factor
|
||||||
factor = 0.
|
factor = 0.
|
||||||
|
@ -707,9 +705,11 @@ class MoveSplitter:
|
||||||
self.move_check_distance = config.getfloat(
|
self.move_check_distance = config.getfloat(
|
||||||
'move_check_distance', 5., minval=3.)
|
'move_check_distance', 5., minval=3.)
|
||||||
self.z_mesh = None
|
self.z_mesh = None
|
||||||
|
self.fade_offset = 0.
|
||||||
self.gcode = gcode
|
self.gcode = gcode
|
||||||
def initialize(self, mesh):
|
def initialize(self, mesh, fade_offset):
|
||||||
self.z_mesh = mesh
|
self.z_mesh = mesh
|
||||||
|
self.fade_offset = fade_offset
|
||||||
def build_move(self, prev_pos, next_pos, factor):
|
def build_move(self, prev_pos, next_pos, factor):
|
||||||
self.prev_pos = tuple(prev_pos)
|
self.prev_pos = tuple(prev_pos)
|
||||||
self.next_pos = tuple(next_pos)
|
self.next_pos = tuple(next_pos)
|
||||||
|
@ -723,7 +723,8 @@ class MoveSplitter:
|
||||||
self.axis_move = [not isclose(d, 0., abs_tol=1e-10) for d in axes_d]
|
self.axis_move = [not isclose(d, 0., abs_tol=1e-10) for d in axes_d]
|
||||||
def _calc_z_offset(self, pos):
|
def _calc_z_offset(self, pos):
|
||||||
z = self.z_mesh.calc_z(pos[0], pos[1])
|
z = self.z_mesh.calc_z(pos[0], pos[1])
|
||||||
return self.z_factor * z + self.z_mesh.mesh_offset
|
offset = self.fade_offset
|
||||||
|
return self.z_factor * (z - offset) + offset
|
||||||
def _set_next_move(self, distance_from_prev):
|
def _set_next_move(self, distance_from_prev):
|
||||||
t = distance_from_prev / self.total_move_length
|
t = distance_from_prev / self.total_move_length
|
||||||
if t > 1. or t < 0.:
|
if t > 1. or t < 0.:
|
||||||
|
@ -766,7 +767,6 @@ class ZMesh:
|
||||||
self.probed_matrix = self.mesh_matrix = None
|
self.probed_matrix = self.mesh_matrix = None
|
||||||
self.mesh_params = params
|
self.mesh_params = params
|
||||||
self.avg_z = 0.
|
self.avg_z = 0.
|
||||||
self.mesh_offset = 0.
|
|
||||||
logging.debug('bed_mesh: probe/mesh parameters:')
|
logging.debug('bed_mesh: probe/mesh parameters:')
|
||||||
for key, value in self.mesh_params.items():
|
for key, value in self.mesh_params.items():
|
||||||
logging.debug("%s : %s" % (key, value))
|
logging.debug("%s : %s" % (key, value))
|
||||||
|
@ -802,7 +802,7 @@ class ZMesh:
|
||||||
(self.mesh_y_count - 1)
|
(self.mesh_y_count - 1)
|
||||||
def get_mesh_matrix(self):
|
def get_mesh_matrix(self):
|
||||||
if self.mesh_matrix is not None:
|
if self.mesh_matrix is not None:
|
||||||
return [[round(z + self.mesh_offset, 6) for z in line]
|
return [[round(z, 6) for z in line]
|
||||||
for line in self.mesh_matrix]
|
for line in self.mesh_matrix]
|
||||||
return [[]]
|
return [[]]
|
||||||
def get_probed_matrix(self):
|
def get_probed_matrix(self):
|
||||||
|
@ -851,12 +851,6 @@ class ZMesh:
|
||||||
# z step distances
|
# z step distances
|
||||||
self.avg_z = round(self.avg_z, 2)
|
self.avg_z = round(self.avg_z, 2)
|
||||||
self.print_mesh(logging.debug)
|
self.print_mesh(logging.debug)
|
||||||
def offset_mesh(self, offset):
|
|
||||||
if self.mesh_matrix:
|
|
||||||
self.mesh_offset = offset
|
|
||||||
for y_line in self.mesh_matrix:
|
|
||||||
for idx, z in enumerate(y_line):
|
|
||||||
y_line[idx] = z - self.mesh_offset
|
|
||||||
def get_x_coordinate(self, index):
|
def get_x_coordinate(self, index):
|
||||||
return self.mesh_x_min + self.mesh_x_dist * index
|
return self.mesh_x_min + self.mesh_x_dist * index
|
||||||
def get_y_coordinate(self, index):
|
def get_y_coordinate(self, index):
|
||||||
|
|
Loading…
Reference in New Issue