bed_mesh: Cache last position when get_position() is called.

Fixes issue #626.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2018-09-10 09:06:18 -04:00 committed by KevinOConnor
parent ea129d869e
commit d6f72eefa1
1 changed files with 3 additions and 2 deletions

View File

@ -92,12 +92,13 @@ class BedMesh:
# Return last, non-transformed position # Return last, non-transformed position
if self.z_mesh is None: if self.z_mesh is None:
# No mesh calibrated, so send toolhead position # No mesh calibrated, so send toolhead position
return self.toolhead.get_position() self.last_position[:] = self.toolhead.get_position()
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_adjust = self.get_z_factor(z) * self.z_mesh.get_z(x, y) z_adjust = self.get_z_factor(z) * self.z_mesh.get_z(x, y)
return [x, y, z - z_adjust, e] self.last_position[:] = [x, y, z - z_adjust, e]
return list(self.last_position)
def move(self, newpos, speed): def move(self, newpos, speed):
factor = self.get_z_factor(newpos[2]) factor = self.get_z_factor(newpos[2])
if self.z_mesh is None or not factor: if self.z_mesh is None or not factor: