bed_tilt: Support saving calibration data via SAVE_CONFIG command
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
5a1b2d61ae
commit
d48e8ea162
|
@ -11,10 +11,11 @@ class BedTilt:
|
||||||
self.printer = config.get_printer()
|
self.printer = config.get_printer()
|
||||||
self.x_adjust = config.getfloat('x_adjust', 0.)
|
self.x_adjust = config.getfloat('x_adjust', 0.)
|
||||||
self.y_adjust = config.getfloat('y_adjust', 0.)
|
self.y_adjust = config.getfloat('y_adjust', 0.)
|
||||||
self.z_adjust = 0.
|
self.z_adjust = config.getfloat('z_adjust', 0.)
|
||||||
if config.get('points', None) is not None:
|
if config.get('points', None) is not None:
|
||||||
BedTiltCalibrate(config, self)
|
BedTiltCalibrate(config, self)
|
||||||
self.toolhead = None
|
self.toolhead = None
|
||||||
|
# Register move transform with g-code class
|
||||||
gcode = self.printer.lookup_object('gcode')
|
gcode = self.printer.lookup_object('gcode')
|
||||||
gcode.set_move_transform(self)
|
gcode.set_move_transform(self)
|
||||||
def printer_state(self, state):
|
def printer_state(self, state):
|
||||||
|
@ -27,6 +28,14 @@ class BedTilt:
|
||||||
x, y, z, e = newpos
|
x, y, z, e = newpos
|
||||||
self.toolhead.move([x, y, z + x*self.x_adjust + y*self.y_adjust
|
self.toolhead.move([x, y, z + x*self.x_adjust + y*self.y_adjust
|
||||||
+ self.z_adjust, e], speed)
|
+ self.z_adjust, e], speed)
|
||||||
|
def update_adjust(self, x_adjust, y_adjust, z_adjust):
|
||||||
|
self.x_adjust = x_adjust
|
||||||
|
self.y_adjust = y_adjust
|
||||||
|
self.z_adjust = z_adjust
|
||||||
|
configfile = self.printer.lookup_object('configfile')
|
||||||
|
configfile.set('bed_tilt', 'x_adjust', "%.6f" % (x_adjust,))
|
||||||
|
configfile.set('bed_tilt', 'y_adjust', "%.6f" % (y_adjust,))
|
||||||
|
configfile.set('bed_tilt', 'z_adjust', "%.6f" % (z_adjust,))
|
||||||
|
|
||||||
# Helper script to calibrate the bed tilt
|
# Helper script to calibrate the bed tilt
|
||||||
class BedTiltCalibrate:
|
class BedTiltCalibrate:
|
||||||
|
@ -74,11 +83,10 @@ class BedTiltCalibrate:
|
||||||
logging.info("orig: %s new: %s", adjusted_height(pos, params),
|
logging.info("orig: %s new: %s", adjusted_height(pos, params),
|
||||||
adjusted_height(pos, new_params))
|
adjusted_height(pos, new_params))
|
||||||
# Update current bed_tilt calculations
|
# 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
|
z_diff = new_params['z_adjust'] - z_offset
|
||||||
bed_tilt.z_adjust = z_diff
|
bed_tilt = self.printer.lookup_object('bed_tilt')
|
||||||
|
bed_tilt.update_adjust(new_params['x_adjust'], new_params['y_adjust'],
|
||||||
|
z_diff)
|
||||||
self.gcode.reset_last_position()
|
self.gcode.reset_last_position()
|
||||||
# Report results back to user
|
# Report results back to user
|
||||||
if self.z_position_endstop is not None:
|
if self.z_position_endstop is not None:
|
||||||
|
@ -103,8 +111,8 @@ class BedTiltCalibrate:
|
||||||
self.printer.set_rollover_info("bed_tilt", "bed_tilt: %s" % (msg,))
|
self.printer.set_rollover_info("bed_tilt", "bed_tilt: %s" % (msg,))
|
||||||
self.gcode.respond_info(
|
self.gcode.respond_info(
|
||||||
"%s\nThe above parameters have been applied to the current\n"
|
"%s\nThe above parameters have been applied to the current\n"
|
||||||
"session. Update the printer config file with the above to\n"
|
"session. The SAVE_CONFIG command will update the printer\n"
|
||||||
"use these settings in future sessions." % (msg,))
|
"config file and restart the printer." % (msg,))
|
||||||
|
|
||||||
def load_config(config):
|
def load_config(config):
|
||||||
return BedTilt(config)
|
return BedTilt(config)
|
||||||
|
|
Loading…
Reference in New Issue