From b9ac6d63069974a90a3740eaf2a3e5ae81e35470 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 16 Aug 2020 22:08:28 -0400 Subject: [PATCH] skew_correction: Make sure to call reset_last_position() on a skew update Signed-off-by: Kevin O'Connor --- klippy/extras/skew_correction.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/klippy/extras/skew_correction.py b/klippy/extras/skew_correction.py index c3731da3..afb68bbb 100644 --- a/klippy/extras/skew_correction.py +++ b/klippy/extras/skew_correction.py @@ -69,6 +69,12 @@ class PrinterSkew: def move(self, newpos, speed): corrected_pos = self.calc_skew(newpos) 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" def cmd_GET_CURRENT_SKEW(self, gcmd): out = "Current Printer Skew:" @@ -90,9 +96,7 @@ class PrinterSkew: cmd_SET_SKEW_help = "Set skew based on lengths of measured object" def cmd_SET_SKEW(self, gcmd): if gcmd.get_int("CLEAR", 0): - self.xy_factor = 0. - self.xz_factor = 0. - self.yz_factor = 0. + self._update_skew(0., 0., 0.) return planes = ["XY", "XZ", "YZ"] for plane in planes: @@ -113,14 +117,13 @@ class PrinterSkew: def cmd_SKEW_PROFILE(self, gcmd): if gcmd.get('LOAD', None) is not None: name = gcmd.get('LOAD') - if name not in self.skew_profiles: + prof = self.skew_profiles.get(name) + if prof is None: gcmd.respond_info( "skew_correction: Load failed, unknown profile [%s]" % (name)) return - self.xy_factor = self.skew_profiles[name]['xy_skew'] - self.xz_factor = self.skew_profiles[name]['xz_skew'] - self.yz_factor = self.skew_profiles[name]['yz_skew'] + self._update_skew(prof['xy_skew'], prof['xz_skew'], prof['yz_skew']) elif gcmd.get('SAVE', None) is not None: name = gcmd.get('SAVE') configfile = self.printer.lookup_object('configfile')