diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2018-04-03 12:02:17 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2018-04-03 13:18:53 -0400 |
commit | 5e060c3c65897c57705e90a8a4d66b9b6b5497ba (patch) | |
tree | 4f50c49d5eb985db464bed93515ec4e5b1efbf12 | |
parent | 0f1a1427791e0b6cf50127bc8cfe094e4e20e9a9 (diff) | |
download | kutter-5e060c3c65897c57705e90a8a4d66b9b6b5497ba.tar.gz kutter-5e060c3c65897c57705e90a8a4d66b9b6b5497ba.tar.xz kutter-5e060c3c65897c57705e90a8a4d66b9b6b5497ba.zip |
bed_tilt: Apply bed_tilt_calibrate settings to current session
Apply the bed tilt settings immediately after finding them. This
makes it easier for users to perform automatic tilt calibration at the
start of every print.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r-- | klippy/extras/bed_tilt.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/klippy/extras/bed_tilt.py b/klippy/extras/bed_tilt.py index c4c5b506..6013382d 100644 --- a/klippy/extras/bed_tilt.py +++ b/klippy/extras/bed_tilt.py @@ -11,6 +11,7 @@ class BedTilt: self.printer = config.get_printer() self.x_adjust = config.getfloat('x_adjust', 0.) self.y_adjust = config.getfloat('y_adjust', 0.) + self.z_adjust = 0. if config.get('points', None) is not None: BedTiltCalibrate(config, self) self.toolhead = None @@ -21,11 +22,11 @@ class BedTilt: self.toolhead = self.printer.lookup_object('toolhead') def get_position(self): x, y, z, e = self.toolhead.get_position() - return [x, y, z - x*self.x_adjust - y*self.y_adjust, e] + return [x, y, z - x*self.x_adjust - y*self.y_adjust - self.z_adjust, e] def move(self, newpos, speed): x, y, z, e = newpos - self.toolhead.move([x, y, z + x*self.x_adjust + y*self.y_adjust, e], - speed) + self.toolhead.move([x, y, z + x*self.x_adjust + y*self.y_adjust + + self.z_adjust, e], speed) # Helper script to calibrate the bed tilt class BedTiltCalibrate: @@ -84,7 +85,14 @@ class BedTiltCalibrate: for pos in positions: logging.info("orig: %s new: %s", adjusted_height(pos, params), adjusted_height(pos, new_params)) + # Update current bed_tilt calculations + bed_tilt = self.printer.lookup_object('bed_tilt') + bed_tilt.x_adjust = new_params['x_adjust'] + bed_tilt.y_adjust = new_params['y_adjust'] z_diff = new_params['z_adjust'] - z_offset + bed_tilt.z_adjust = z_diff + self.gcode.reset_last_position() + # Report results back to user if self.z_position_endstop is not None: # Cartesian style robot z_extra = "" @@ -104,10 +112,11 @@ class BedTiltCalibrate: z_adjust = "Add %.6f to endstop position\n" % (-z_diff,) msg = "%sx_adjust: %.6f y_adjust: %.6f" % ( z_adjust, new_params['x_adjust'], new_params['y_adjust']) - logging.info("bed_tilt_calibrate: %s", msg) + self.printer.set_rollover_info("bed_tilt", "bed_tilt: %s" % (msg,)) self.gcode.respond_info( - "%s\nTo use these parameters, update the printer config file with\n" - "the above and then issue a RESTART command" % (msg,)) + "%s\nThe above parameters have been applied to the current\n" + "session. Update the printer config file with the above to\n" + "use these settings in future sessions." % (msg,)) def load_config(config): return BedTilt(config) |