aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2024-05-23 13:51:04 -0400
committerKevin O'Connor <kevin@koconnor.net>2024-06-10 12:20:21 -0400
commit6f6122a576c42852ca8835f9cef5993d2ac76a1d (patch)
treed1db8e509a0245e87f6af8d5ce9b6910d99366b5 /klippy
parent8fc11b4a2e0dd33cd99e4d3c8ce4107acf4772ff (diff)
downloadkutter-6f6122a576c42852ca8835f9cef5993d2ac76a1d.tar.gz
kutter-6f6122a576c42852ca8835f9cef5993d2ac76a1d.tar.xz
kutter-6f6122a576c42852ca8835f9cef5993d2ac76a1d.zip
probe: Move Z_OFFSET_APPLY_PROBE to ProbeCommandHelper class
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy')
-rw-r--r--klippy/extras/probe.py38
1 files changed, 20 insertions, 18 deletions
diff --git a/klippy/extras/probe.py b/klippy/extras/probe.py
index c7e838aa..103a3586 100644
--- a/klippy/extras/probe.py
+++ b/klippy/extras/probe.py
@@ -34,6 +34,10 @@ class ProbeCommandHelper:
self.last_z_result = 0.
gcode.register_command('PROBE', self.cmd_PROBE,
desc=self.cmd_PROBE_help)
+ # Other commands
+ gcode.register_command('Z_OFFSET_APPLY_PROBE',
+ self.cmd_Z_OFFSET_APPLY_PROBE,
+ desc=self.cmd_Z_OFFSET_APPLY_PROBE_help)
def get_status(self, eventtime):
return {'name': self.name,
'last_query': self.last_state,
@@ -52,6 +56,22 @@ class ProbeCommandHelper:
pos = run_single_probe(self.probe, gcmd)
gcmd.respond_info("Result is z=%.6f" % (pos[2],))
self.last_z_result = pos[2]
+ cmd_Z_OFFSET_APPLY_PROBE_help = "Adjust the probe's z_offset"
+ def cmd_Z_OFFSET_APPLY_PROBE(self, gcmd):
+ gcode_move = self.printer.lookup_object("gcode_move")
+ offset = gcode_move.get_status()['homing_origin'].z
+ if offset == 0:
+ gcmd.respond_info("Nothing to do: Z Offset is 0")
+ return
+ z_offset = self.probe.get_offsets()[2]
+ new_calibrate = z_offset - offset
+ gcmd.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 = self.printer.lookup_object('configfile')
+ configfile.set(self.name, 'z_offset', "%.3f" % (new_calibrate,))
# Helper to track multiple probe attempts in a single command
class ProbeSessionHelper:
@@ -66,7 +86,6 @@ class ProbeSessionHelper:
self.z_offset = config.getfloat('z_offset')
self.probe_calibrate_z = 0.
self.multi_probe_pending = False
- 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')
@@ -106,9 +125,6 @@ class ProbeSessionHelper:
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)
@@ -294,20 +310,6 @@ class ProbeSessionHelper:
# Start manual probe
manual_probe.ManualProbeHelper(self.printer, gcmd,
self.probe_calibrate_finalize)
- def cmd_Z_OFFSET_APPLY_PROBE(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_offset - 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"
######################################################################