Skip to content

Instantly share code, notes, and snippets.

@CODeRUS
Created June 20, 2022 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CODeRUS/115e62d90e9650efee71cde4d6e4a068 to your computer and use it in GitHub Desktop.
Save CODeRUS/115e62d90e9650efee71cde4d6e4a068 to your computer and use it in GitHub Desktop.
klipper probe offset changer
# Probe offset change support
#
import logging
class PrinterProbeChanger:
def __init__(self, config):
self.printer = config.get_printer()
self.name = config.get_name()
self.gcode = self.printer.lookup_object('gcode')
self.gcode.register_command('PROBE_PRINT_OFFSETS', self.cmd_PROBE_PRINT_OFFSETS,
desc=self.cmd_PROBE_PRINT_OFFSETS_help)
self.gcode.register_command('PROBE_SET_OFFSETS', self.cmd_PROBE_SET_OFFSETS,
desc=self.cmd_PROBE_SET_OFFSETS_help)
cmd_PROBE_PRINT_OFFSETS_help = "Print current probe offsets"
def cmd_PROBE_PRINT_OFFSETS(self, gcmd):
probe = self.printer.lookup_object('probe', None)
if probe is None:
gcmd.error("Probe is not defined!")
return
gcmd.respond_info("Probe offsets:\nx_offset: %.3f\ny_offset: %.3f\nz_offset: %.3f" % (probe.x_offset, probe.y_offset, probe.z_offset))
cmd_PROBE_SET_OFFSETS_help = "Change probe offsets"
def cmd_PROBE_SET_OFFSETS(self, gcmd):
probe = self.printer.lookup_object('probe', None)
if probe is None:
gcmd.error("Probe is not defined!")
return
x_offset = gcmd.get_float('X', None)
if x_offset is not None:
probe.x_offset = x_offset
y_offset = gcmd.get_float('Y', None)
if y_offset is not None:
probe.y_offset = y_offset
z_offset = gcmd.get_float('Z', None)
if z_offset is not None:
probe.z_offset = z_offset
def load_config(config):
return PrinterProbeChanger(config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment