probe: add ability to save babystepping (#4404)
Created two new extended gcodes: Z_OFFSET_APPLY_ENDSTOP, and Z_OFFSET_APPLY_PROBE. These use the z gcode offset to revise the probe offset, or z endstop position allowing users to make a frequently used babystepping value permanent without manual config editing. Signed-off-by: Ben Eastep <shifting@shifting.ca>
This commit is contained in:
@@ -10,6 +10,7 @@ class ManualProbe:
|
||||
self.printer = config.get_printer()
|
||||
# Register commands
|
||||
self.gcode = self.printer.lookup_object('gcode')
|
||||
self.gcode_move = self.printer.load_object(config, "gcode_move")
|
||||
self.gcode.register_command('MANUAL_PROBE', self.cmd_MANUAL_PROBE,
|
||||
desc=self.cmd_MANUAL_PROBE_help)
|
||||
zconfig = config.getsection('stepper_z')
|
||||
@@ -19,6 +20,10 @@ class ManualProbe:
|
||||
self.gcode.register_command(
|
||||
'Z_ENDSTOP_CALIBRATE', self.cmd_Z_ENDSTOP_CALIBRATE,
|
||||
desc=self.cmd_Z_ENDSTOP_CALIBRATE_help)
|
||||
self.gcode.register_command(
|
||||
'Z_OFFSET_APPLY_ENDSTOP',
|
||||
self.cmd_Z_OFFSET_APPLY_ENDSTOP,
|
||||
desc=self.cmd_Z_OFFSET_APPLY_ENDSTOP_help)
|
||||
def manual_probe_finalize(self, kin_pos):
|
||||
if kin_pos is not None:
|
||||
self.gcode.respond_info("Z position is %.3f" % (kin_pos[2],))
|
||||
@@ -38,6 +43,20 @@ class ManualProbe:
|
||||
cmd_Z_ENDSTOP_CALIBRATE_help = "Calibrate a Z endstop"
|
||||
def cmd_Z_ENDSTOP_CALIBRATE(self, gcmd):
|
||||
ManualProbeHelper(self.printer, gcmd, self.z_endstop_finalize)
|
||||
def cmd_Z_OFFSET_APPLY_ENDSTOP(self,gcmd):
|
||||
offset = self.gcode_move.get_status()['homing_origin'].z
|
||||
configfile = self.printer.lookup_object('configfile')
|
||||
if offset == 0:
|
||||
self.gcode.respond_info("Nothing to do: Z Offset is 0")
|
||||
else:
|
||||
new_calibrate = self.z_position_endstop - offset
|
||||
self.gcode.respond_info(
|
||||
"stepper_z: position_endstop: %.3f\n"
|
||||
"The SAVE_CONFIG command will update the printer config file\n"
|
||||
"with the above and restart the printer." % (new_calibrate))
|
||||
configfile.set('stepper_z', 'position_endstop',
|
||||
"%.3f" % (new_calibrate,))
|
||||
cmd_Z_OFFSET_APPLY_ENDSTOP_help = "Adjust the z endstop_position"
|
||||
|
||||
# Verify that a manual probe isn't already in progress
|
||||
def verify_no_manual_probe(printer):
|
||||
|
||||
Reference in New Issue
Block a user