skew_correction: Make sure to call reset_last_position() on a skew update

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2020-08-16 22:08:28 -04:00
parent 4115a77342
commit b9ac6d6306
1 changed files with 10 additions and 7 deletions

View File

@ -69,6 +69,12 @@ class PrinterSkew:
def move(self, newpos, speed): def move(self, newpos, speed):
corrected_pos = self.calc_skew(newpos) corrected_pos = self.calc_skew(newpos)
self.next_transform.move(corrected_pos, speed) self.next_transform.move(corrected_pos, speed)
def _update_skew(self, xy_factor, xz_factor, yz_factor):
self.xy_factor = xy_factor
self.xz_factor = xz_factor
self.yz_factor = yz_factor
gcode = self.printer.lookup_object('gcode')
gcode.reset_last_position()
cmd_GET_CURRENT_SKEW_help = "Report current printer skew" cmd_GET_CURRENT_SKEW_help = "Report current printer skew"
def cmd_GET_CURRENT_SKEW(self, gcmd): def cmd_GET_CURRENT_SKEW(self, gcmd):
out = "Current Printer Skew:" out = "Current Printer Skew:"
@ -90,9 +96,7 @@ class PrinterSkew:
cmd_SET_SKEW_help = "Set skew based on lengths of measured object" cmd_SET_SKEW_help = "Set skew based on lengths of measured object"
def cmd_SET_SKEW(self, gcmd): def cmd_SET_SKEW(self, gcmd):
if gcmd.get_int("CLEAR", 0): if gcmd.get_int("CLEAR", 0):
self.xy_factor = 0. self._update_skew(0., 0., 0.)
self.xz_factor = 0.
self.yz_factor = 0.
return return
planes = ["XY", "XZ", "YZ"] planes = ["XY", "XZ", "YZ"]
for plane in planes: for plane in planes:
@ -113,14 +117,13 @@ class PrinterSkew:
def cmd_SKEW_PROFILE(self, gcmd): def cmd_SKEW_PROFILE(self, gcmd):
if gcmd.get('LOAD', None) is not None: if gcmd.get('LOAD', None) is not None:
name = gcmd.get('LOAD') name = gcmd.get('LOAD')
if name not in self.skew_profiles: prof = self.skew_profiles.get(name)
if prof is None:
gcmd.respond_info( gcmd.respond_info(
"skew_correction: Load failed, unknown profile [%s]" "skew_correction: Load failed, unknown profile [%s]"
% (name)) % (name))
return return
self.xy_factor = self.skew_profiles[name]['xy_skew'] self._update_skew(prof['xy_skew'], prof['xz_skew'], prof['yz_skew'])
self.xz_factor = self.skew_profiles[name]['xz_skew']
self.yz_factor = self.skew_profiles[name]['yz_skew']
elif gcmd.get('SAVE', None) is not None: elif gcmd.get('SAVE', None) is not None:
name = gcmd.get('SAVE') name = gcmd.get('SAVE')
configfile = self.printer.lookup_object('configfile') configfile = self.printer.lookup_object('configfile')