probe: Support passing gcmd to probe.get_offsets()

Make it possible for the probe's get_offsets() code to depend on the
parameters of the probe request.  This is in preparation for eddy
"tap" support.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2026-01-22 11:22:05 -05:00
parent a353efa5b6
commit 2956c1e223
7 changed files with 27 additions and 29 deletions

View file

@ -107,8 +107,7 @@ class Calibrater:
self.gcode = self.printer.lookup_object('gcode')
self.probe = None
# probe settings are set to none, until they are available
self.lift_speed, self.probe_x_offset, self.probe_y_offset, _ = \
None, None, None, None
self.lift_speed = None
self.printer.register_event_handler("klippy:connect",
self._handle_connect)
self.speed = compensation.speed
@ -135,8 +134,6 @@ class Calibrater:
raise self.printer.config_error(
"AXIS_TWIST_COMPENSATION requires [probe] to be defined")
self.lift_speed = self.probe.get_probe_params()['lift_speed']
self.probe_x_offset, self.probe_y_offset, _ = \
self.probe.get_offsets()
def _register_gcode_handlers(self):
# register gcode handlers
@ -154,6 +151,7 @@ class Calibrater:
def cmd_AXIS_TWIST_COMPENSATION_CALIBRATE(self, gcmd):
self.gcmd = gcmd
probe_x_offset, probe_y_offset, _ = self.probe.get_offsets(gcmd)
sample_count = gcmd.get_int('SAMPLE_COUNT', DEFAULT_SAMPLE_COUNT)
axis = gcmd.get('AXIS', 'X')
@ -225,7 +223,7 @@ class Calibrater:
"Invalid axis.")
probe_points = self._calculate_probe_points(
nozzle_points, self.probe_x_offset, self.probe_y_offset)
nozzle_points, probe_x_offset, probe_y_offset)
# verify no other manual probe is in progress
manual_probe.verify_no_manual_probe(self.printer)
@ -237,7 +235,7 @@ class Calibrater:
self._calibration(probe_points, nozzle_points, interval_dist)
def _calculate_probe_points(self, nozzle_points,
probe_x_offset, probe_y_offset):
probe_x_offset, probe_y_offset):
# calculate the points to put the nozzle at
# returned as a list of tuples
probe_points = []

View file

@ -308,7 +308,7 @@ class BedMesh:
result["calibration"] = self.bmc.dump_calibration(gcmd)
else:
result["calibration"] = self.bmc.dump_calibration()
offsets = [0, 0, 0] if prb is None else prb.get_offsets()
offsets = [0, 0, 0] if prb is None else prb.get_offsets(gcmd)
result["probe_offsets"] = offsets
result["axis_minimum"] = th_sts["axis_minimum"]
result["axis_maximum"] = th_sts["axis_maximum"]
@ -1209,7 +1209,7 @@ class RapidScanHelper:
gcmd_params["SAMPLE_TIME"] = half_window * 2
self._raise_tool(gcmd, scan_height)
probe_session = pprobe.start_probe_session(gcmd)
offsets = pprobe.get_offsets()
offsets = pprobe.get_offsets(gcmd)
initial_move = True
for pos, is_probe_pt in self.probe_manager.iter_rapid_path():
pos = self._apply_offsets(pos[:2], offsets)

View file

@ -80,8 +80,8 @@ class BLTouchProbe:
self.handle_connect)
def get_probe_params(self, gcmd=None):
return self.param_helper.get_probe_params(gcmd)
def get_offsets(self):
return self.probe_offsets.get_offsets()
def get_offsets(self, gcmd=None):
return self.probe_offsets.get_offsets(gcmd)
def get_status(self, eventtime):
return self.cmd_helper.get_status(eventtime)
def start_probe_session(self, gcmd):

View file

@ -647,8 +647,8 @@ class LoadCellPrinterProbe:
def get_probe_params(self, gcmd=None):
return self._param_helper.get_probe_params(gcmd)
def get_offsets(self):
return self._probe_offsets.get_offsets()
def get_offsets(self, gcmd=None):
return self._probe_offsets.get_offsets(gcmd)
def start_probe_session(self, gcmd):
return self._probe_session.start_probe_session(gcmd)

View file

@ -54,7 +54,7 @@ class ProbeCommandHelper:
gcode.register_command('PROBE', self.cmd_PROBE,
desc=self.cmd_PROBE_help)
# PROBE_CALIBRATE command
self.probe_calibrate_pos = None
self.probe_calibrate_info = None
gcode.register_command('PROBE_CALIBRATE', self.cmd_PROBE_CALIBRATE,
desc=self.cmd_PROBE_CALIBRATE_help)
# Other commands
@ -89,13 +89,13 @@ class ProbeCommandHelper:
gcode = self.printer.lookup_object('gcode')
self.last_probe_position = gcode.Coord((pos.bed_x, pos.bed_y,
pos.bed_z))
x_offset, y_offset, z_offset = self.probe.get_offsets()
x_offset, y_offset, z_offset = self.probe.get_offsets(gcmd)
self.last_z_result = pos.bed_z + z_offset # Deprecated
def probe_calibrate_finalize(self, mpresult):
if mpresult is None:
return
x_offset, y_offset, z_offset = self.probe.get_offsets()
z_offset += mpresult.bed_z - self.probe_calibrate_pos.bed_z
ppos, offsets = self.probe_calibrate_info
z_offset = offsets[2] + mpresult.bed_z - ppos.bed_z
gcode = self.printer.lookup_object('gcode')
gcode.respond_info(
"%s: z_offset: %.3f\n"
@ -108,17 +108,17 @@ class ProbeCommandHelper:
manual_probe.verify_no_manual_probe(self.printer)
params = self.probe.get_probe_params(gcmd)
# Perform initial probe
pos = run_single_probe(self.probe, gcmd)
ppos = run_single_probe(self.probe, gcmd)
# Move away from the bed
curpos = self.printer.lookup_object('toolhead').get_position()
curpos[2] += 5.
self._move(curpos, params['lift_speed'])
# Move the nozzle over the probe point
curpos[0] = pos.bed_x
curpos[1] = pos.bed_y
curpos[0] = ppos.bed_x
curpos[1] = ppos.bed_y
self._move(curpos, params['probe_speed'])
# Start manual probe
self.probe_calibrate_pos = pos
self.probe_calibrate_info = (ppos, self.probe.get_offsets(gcmd))
manual_probe.ManualProbeHelper(self.printer, gcmd,
self.probe_calibrate_finalize)
cmd_PROBE_ACCURACY_help = "Probe Z-height accuracy at current XY position"
@ -174,7 +174,7 @@ class ProbeCommandHelper:
if offset == 0:
gcmd.respond_info("Nothing to do: Z Offset is 0")
return
z_offset = self.probe.get_offsets()[2]
z_offset = self.probe.get_offsets(gcmd)[2]
new_calibrate = z_offset - offset
gcmd.respond_info(
"%s: z_offset: %.3f\n"
@ -426,7 +426,7 @@ class ProbeOffsetsHelper:
self.x_offset = config.getfloat('x_offset', 0.)
self.y_offset = config.getfloat('y_offset', 0.)
self.z_offset = config.getfloat('z_offset')
def get_offsets(self):
def get_offsets(self, gcmd=None):
return self.x_offset, self.y_offset, self.z_offset
def create_probe_result(self, test_pos):
return manual_probe.ProbeResult(
@ -509,7 +509,7 @@ class ProbePointsHelper:
return
# Perform automatic probing
self.lift_speed = probe.get_probe_params(gcmd)['lift_speed']
self.probe_offsets = probe.get_offsets()
self.probe_offsets = probe.get_offsets(gcmd)
if self.horizontal_move_z < self.probe_offsets[2]:
raise gcmd.error("horizontal_move_z can't be less than"
" probe's z_offset")
@ -632,8 +632,8 @@ class PrinterProbe:
config, self.param_helper, self.homing_helper.start_probe_session)
def get_probe_params(self, gcmd=None):
return self.param_helper.get_probe_params(gcmd)
def get_offsets(self):
return self.probe_offsets.get_offsets()
def get_offsets(self, gcmd=None):
return self.probe_offsets.get_offsets(gcmd)
def get_status(self, eventtime):
return self.cmd_helper.get_status(eventtime)
def start_probe_session(self, gcmd):

View file

@ -563,8 +563,8 @@ class PrinterEddyProbe:
self.sensor_helper.add_client(cb)
def get_probe_params(self, gcmd=None):
return self.param_helper.get_probe_params(gcmd)
def get_offsets(self):
return self.probe_offsets.get_offsets()
def get_offsets(self, gcmd=None):
return self.probe_offsets.get_offsets(gcmd)
def get_status(self, eventtime):
return self.cmd_helper.get_status(eventtime)
def start_probe_session(self, gcmd):

View file

@ -90,8 +90,8 @@ class SmartEffectorProbe:
desc=self.cmd_SET_SMART_EFFECTOR_help)
def get_probe_params(self, gcmd=None):
return self.param_helper.get_probe_params(gcmd)
def get_offsets(self):
return self.probe_offsets.get_offsets()
def get_offsets(self, gcmd=None):
return self.probe_offsets.get_offsets(gcmd)
def get_status(self, eventtime):
return self.cmd_helper.get_status(eventtime)
def start_probe_session(self, gcmd):