manual_probe: Add Z_OFFSET_APPLY_ENDSTOP for delta

Current Z_OFFSET_APPLY_ENDSTOP command only works for printers
with cartesian architecture which have separate Z axis defined.
But this functionality (persisting Z babystep value to endstops)
is exactly as convinient for delta printers, therefore this
PR implements it.

Signed-off-by: Jan Herich <jan.herich@gmail.com>
This commit is contained in:
janherich 2022-11-25 13:09:56 +01:00 committed by KevinOConnor
parent 8621ebbed2
commit f078a27905
1 changed files with 45 additions and 0 deletions

View File

@ -13,9 +13,25 @@ class ManualProbe:
self.gcode_move = self.printer.load_object(config, "gcode_move")
self.gcode.register_command('MANUAL_PROBE', self.cmd_MANUAL_PROBE,
desc=self.cmd_MANUAL_PROBE_help)
# Endstop value for cartesian printers with separate Z axis
zconfig = config.getsection('stepper_z')
self.z_position_endstop = zconfig.getfloat('position_endstop', None,
note_valid=False)
# Endstop values for linear delta printers with vertical A,B,C towers
a_tower_config = config.getsection('stepper_a')
self.a_position_endstop = a_tower_config.getfloat('position_endstop',
None,
note_valid=False)
b_tower_config = config.getsection('stepper_b')
self.b_position_endstop = b_tower_config.getfloat('position_endstop',
None,
note_valid=False)
c_tower_config = config.getsection('stepper_c')
self.c_position_endstop = c_tower_config.getfloat('position_endstop',
None,
note_valid=False)
# Conditionally register appropriate commands depending on printer
# Cartestian printers with separate Z Axis
if self.z_position_endstop is not None:
self.gcode.register_command(
'Z_ENDSTOP_CALIBRATE', self.cmd_Z_ENDSTOP_CALIBRATE,
@ -24,6 +40,12 @@ class ManualProbe:
'Z_OFFSET_APPLY_ENDSTOP',
self.cmd_Z_OFFSET_APPLY_ENDSTOP,
desc=self.cmd_Z_OFFSET_APPLY_ENDSTOP_help)
# Linear delta printers with A,B,C towers
if 'delta' == config.getsection('printer').get('kinematics'):
self.gcode.register_command(
'Z_OFFSET_APPLY_ENDSTOP',
self.cmd_Z_OFFSET_APPLY_DELTA_ENDSTOPS,
desc=self.cmd_Z_OFFSET_APPLY_ENDSTOP_help)
self.reset_status()
def manual_probe_finalize(self, kin_pos):
if kin_pos is not None:
@ -66,6 +88,29 @@ class ManualProbe:
"with the above and restart the printer." % (new_calibrate))
configfile.set('stepper_z', 'position_endstop',
"%.3f" % (new_calibrate,))
def cmd_Z_OFFSET_APPLY_DELTA_ENDSTOPS(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_a_calibrate = self.a_position_endstop - offset
new_b_calibrate = self.b_position_endstop - offset
new_c_calibrate = self.c_position_endstop - offset
self.gcode.respond_info(
"stepper_a: position_endstop: %.3f\n"
"stepper_b: position_endstop: %.3f\n"
"stepper_c: position_endstop: %.3f\n"
"The SAVE_CONFIG command will update the printer config file\n"
"with the above and restart the printer." % (new_a_calibrate,
new_b_calibrate,
new_c_calibrate))
configfile.set('stepper_a', 'position_endstop',
"%.3f" % (new_a_calibrate,))
configfile.set('stepper_b', 'position_endstop',
"%.3f" % (new_b_calibrate,))
configfile.set('stepper_c', 'position_endstop',
"%.3f" % (new_c_calibrate,))
cmd_Z_OFFSET_APPLY_ENDSTOP_help = "Adjust the z endstop_position"
# Verify that a manual probe isn't already in progress