probe_eddy_current: Separate probe style commands from homing operations

Separate homing operations (as called from probe:z_virtual_endstop)
from the normal probe command handling.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2025-04-04 03:53:32 -04:00
parent ab9b9e8584
commit 37952e8686

View file

@ -302,7 +302,7 @@ class EddyGatherSamples:
self._check_samples()
# Helper for implementing PROBE style commands (descend until trigger)
class EddyEndstopWrapper:
class EddyDescend:
REASON_SENSOR_ERROR = mcu.MCU_trsync.REASON_COMMS_TIMEOUT + 1
def __init__(self, config, sensor_helper, calibration, param_helper):
self._printer = config.get_printer()
@ -315,11 +315,8 @@ class EddyEndstopWrapper:
self._dispatch = mcu.TriggerDispatch(self._mcu)
self._trigger_time = 0.
self._gather = None
# Interface for MCU_endstop
def get_mcu(self):
return self._mcu
def add_stepper(self, stepper):
self._dispatch.add_stepper(stepper)
probe.LookupZSteppers(config, self._dispatch.add_stepper)
# Interface for phoming.probing_move()
def get_steppers(self):
return self._dispatch.get_steppers()
def home_start(self, print_time, sample_time, sample_count, rest_time,
@ -346,11 +343,10 @@ class EddyEndstopWrapper:
return home_end_time
self._trigger_time = trigger_time
return trigger_time
def query_endstop(self, print_time):
return False # XXX
# Probe session interface
def start_probe_session(self, gcmd):
self.multi_probe_begin()
self._gather = EddyGatherSamples(self._printer, self._sensor_helper,
self._calibration, self._z_offset)
return self
def run_probe(self, gcmd):
toolhead = self._printer.lookup_object('toolhead')
@ -370,20 +366,43 @@ class EddyEndstopWrapper:
def pull_probed_results(self):
return self._gather.pull_probed()
def end_probe_session(self):
self.multi_probe_end()
# Interface for ProbeEndstopWrapper
def multi_probe_begin(self):
self._gather = EddyGatherSamples(self._printer, self._sensor_helper,
self._calibration, self._z_offset)
def multi_probe_end(self):
self._gather.finish()
self._gather = None
# Wrapper to emulate mcu_endstop for probe:z_virtual_endstop
# Note that this does not provide accurate results
class EddyEndstopWrapper:
def __init__(self, sensor_helper, eddy_descend):
self._sensor_helper = sensor_helper
self._eddy_descend = eddy_descend
self._hw_probe_session = None
# Interface for MCU_endstop
def get_mcu(self):
return self._sensor_helper.get_mcu()
def add_stepper(self, stepper):
pass
def get_steppers(self):
return self._eddy_descend.get_steppers()
def home_start(self, print_time, sample_time, sample_count, rest_time,
triggered=True):
return self._eddy_descend.home_start(
print_time, sample_time, sample_count, rest_time, triggered)
def home_wait(self, home_end_time):
return self._eddy_descend.home_wait(home_end_time)
def query_endstop(self, print_time):
return False # XXX
# Interface for HomingViaProbeHelper
def multi_probe_begin(self):
self._hw_probe_session = self._eddy_descend.start_probe_session(None)
def multi_probe_end(self):
self._hw_probe_session.end_probe_session()
self._hw_probe_session = None
def probe_prepare(self, hmove):
pass
def probe_finish(self, hmove):
pass
def get_position_endstop(self):
return self._z_offset
return self._eddy_descend._z_offset
# Implementing probing with "METHOD=scan"
class EddyScanningProbe:
@ -436,14 +455,14 @@ class PrinterEddyProbe:
self.sensor_helper = sensors[sensor_type](config, self.calibration)
# Probe interface
self.param_helper = probe.ProbeParameterHelper(config)
self.mcu_probe = EddyEndstopWrapper(
self.eddy_descend = EddyDescend(
config, self.sensor_helper, self.calibration, self.param_helper)
self.cmd_helper = probe.ProbeCommandHelper(config, self)
self.probe_offsets = probe.ProbeOffsetsHelper(config)
self.homing_helper = probe.HomingViaProbeHelper(config, self.mcu_probe,
self.param_helper)
self.probe_session = probe.ProbeSessionHelper(
config, self.param_helper, self.mcu_probe.start_probe_session)
config, self.param_helper, self.eddy_descend.start_probe_session)
mcu_probe = EddyEndstopWrapper(self.sensor_helper, self.eddy_descend)
probe.HomingViaProbeHelper(config, mcu_probe, self.param_helper)
self.printer.add_object('probe', self)
def add_client(self, cb):
self.sensor_helper.add_client(cb)