aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/probe.py
diff options
context:
space:
mode:
authorshiftingtech <53156353+shiftingtech@users.noreply.github.com>2021-07-25 18:20:15 -0600
committerGitHub <noreply@github.com>2021-07-25 20:20:15 -0400
commitf949bc882d140e45373981c5ae1772f09782aa64 (patch)
tree6b19a4c8fa9a0d6b50ec1b64461919dbbcc58a54 /klippy/extras/probe.py
parent0075b29081c1d3f8aa001d68ef6c8899cdbd0adc (diff)
downloadkutter-f949bc882d140e45373981c5ae1772f09782aa64.tar.gz
kutter-f949bc882d140e45373981c5ae1772f09782aa64.tar.xz
kutter-f949bc882d140e45373981c5ae1772f09782aa64.zip
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>
Diffstat (limited to 'klippy/extras/probe.py')
-rw-r--r--klippy/extras/probe.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/klippy/extras/probe.py b/klippy/extras/probe.py
index 700a8955..3f27a73e 100644
--- a/klippy/extras/probe.py
+++ b/klippy/extras/probe.py
@@ -27,6 +27,7 @@ class PrinterProbe:
self.multi_probe_pending = False
self.last_state = False
self.last_z_result = 0.
+ self.gcode_move = self.printer.load_object(config, "gcode_move")
# Infer Z position to move to during a probe
if config.has_section('stepper_z'):
zconfig = config.getsection('stepper_z')
@@ -70,6 +71,9 @@ class PrinterProbe:
desc=self.cmd_PROBE_CALIBRATE_help)
self.gcode.register_command('PROBE_ACCURACY', self.cmd_PROBE_ACCURACY,
desc=self.cmd_PROBE_ACCURACY_help)
+ self.gcode.register_command('Z_OFFSET_APPLY_PROBE',
+ self.cmd_Z_OFFSET_APPLY_PROBE,
+ desc=self.cmd_Z_OFFSET_APPLY_PROBE_help)
def _handle_homing_move_begin(self, hmove):
if self.mcu_probe in hmove.get_mcu_endstops():
self.mcu_probe.probe_prepare(hmove)
@@ -262,6 +266,21 @@ class PrinterProbe:
# Start manual probe
manual_probe.ManualProbeHelper(self.printer, gcmd,
self.probe_calibrate_finalize)
+ def cmd_Z_OFFSET_APPLY_PROBE(self,gcmd):
+ z_offset = self.probe_calibrate_z
+ 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.probe_calibrate_z - offset
+ self.gcode.respond_info(
+ "%s: z_offset: %.3f\n"
+ "The SAVE_CONFIG command will update the printer config file\n"
+ "with the above and restart the printer."
+ % (self.name, new_calibrate))
+ configfile.set(self.name, 'z_offset', "%.3f" % (new_calibrate,))
+ cmd_Z_OFFSET_APPLY_PROBE_help = "Adjust the probe's z_offset"
# Endstop wrapper that enables probe specific features
class ProbeEndstopWrapper: