mirror of
https://github.com/andreili/klipper.git
synced 2025-08-23 19:34:06 +02:00
generic_cartesian: Fixed safe_z_home and manual_probe for new kinematics
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
8627c94d6a
commit
ca83c13f37
@ -5,6 +5,14 @@
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
import logging, bisect
|
||||
|
||||
# Helper to lookup the Z stepper config section
|
||||
def lookup_z_endstop_config(config):
|
||||
if config.has_section('stepper_z'):
|
||||
return config.getsection('stepper_z')
|
||||
elif config.has_section('carriage z'):
|
||||
return config.getsection('carriage z')
|
||||
return None
|
||||
|
||||
class ManualProbe:
|
||||
def __init__(self, config):
|
||||
self.printer = config.get_printer()
|
||||
@ -14,9 +22,13 @@ class ManualProbe:
|
||||
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)
|
||||
zconfig = lookup_z_endstop_config(config)
|
||||
if zconfig is not None:
|
||||
self.z_position_endstop = zconfig.getfloat('position_endstop', None,
|
||||
note_valid=False)
|
||||
self.z_endstop_config_name = zconfig.get_name()
|
||||
else:
|
||||
self.z_position_endstop = self.z_endstop_config_name = None
|
||||
# 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',
|
||||
@ -67,11 +79,13 @@ class ManualProbe:
|
||||
return
|
||||
z_pos = self.z_position_endstop - kin_pos[2]
|
||||
self.gcode.respond_info(
|
||||
"stepper_z: position_endstop: %.3f\n"
|
||||
"%s: position_endstop: %.3f\n"
|
||||
"The SAVE_CONFIG command will update the printer config file\n"
|
||||
"with the above and restart the printer." % (z_pos,))
|
||||
"with the above and restart the printer." % (
|
||||
self.z_endstop_config_name, z_pos,))
|
||||
configfile = self.printer.lookup_object('configfile')
|
||||
configfile.set('stepper_z', 'position_endstop', "%.3f" % (z_pos,))
|
||||
configfile.set(self.z_endstop_config_name, 'position_endstop',
|
||||
"%.3f" % (z_pos,))
|
||||
cmd_Z_ENDSTOP_CALIBRATE_help = "Calibrate a Z endstop"
|
||||
def cmd_Z_ENDSTOP_CALIBRATE(self, gcmd):
|
||||
ManualProbeHelper(self.printer, gcmd, self.z_endstop_finalize)
|
||||
@ -83,11 +97,12 @@ class ManualProbe:
|
||||
else:
|
||||
new_calibrate = self.z_position_endstop - offset
|
||||
self.gcode.respond_info(
|
||||
"stepper_z: position_endstop: %.3f\n"
|
||||
"%s: position_endstop: %.3f\n"
|
||||
"The SAVE_CONFIG command will update the printer config file\n"
|
||||
"with the above and restart the printer." % (new_calibrate))
|
||||
configfile.set('stepper_z', 'position_endstop',
|
||||
"%.3f" % (new_calibrate,))
|
||||
"with the above and restart the printer." % (
|
||||
self.z_endstop_config_name, new_calibrate))
|
||||
configfile.set(self.z_endstop_config_name, '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')
|
||||
|
@ -174,11 +174,8 @@ class ProbeCommandHelper:
|
||||
|
||||
# Helper to lookup the minimum Z position for the printer
|
||||
def lookup_minimum_z(config):
|
||||
if config.has_section('stepper_z'):
|
||||
zconfig = config.getsection('stepper_z')
|
||||
return zconfig.getfloat('position_min', 0., note_valid=False)
|
||||
elif config.has_section('carriage z'):
|
||||
zconfig = config.getsection('carriage z')
|
||||
zconfig = manual_probe.lookup_z_endstop_config(config)
|
||||
if zconfig is not None:
|
||||
return zconfig.getfloat('position_min', 0., note_valid=False)
|
||||
pconfig = config.getsection('printer')
|
||||
return pconfig.getfloat('minimum_z_position', 0., note_valid=False)
|
||||
|
@ -3,6 +3,7 @@
|
||||
# Copyright (C) 2019 Florian Heilmann <Florian.Heilmann@gmx.net>
|
||||
#
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
from . import manual_probe
|
||||
|
||||
class SafeZHoming:
|
||||
def __init__(self, config):
|
||||
@ -11,7 +12,9 @@ class SafeZHoming:
|
||||
self.home_x_pos, self.home_y_pos = x_pos, y_pos
|
||||
self.z_hop = config.getfloat("z_hop", default=0.0)
|
||||
self.z_hop_speed = config.getfloat('z_hop_speed', 15., above=0.)
|
||||
zconfig = config.getsection('stepper_z')
|
||||
zconfig = manual_probe.lookup_z_endstop_config(config)
|
||||
if zconfig is None:
|
||||
raise gcmd.error('Missing Z endstop config for safe_z_homing')
|
||||
self.max_z = zconfig.getfloat('position_max', note_valid=False)
|
||||
self.speed = config.getfloat('speed', 50.0, above=0.)
|
||||
self.move_to_previous = config.getboolean('move_to_previous', False)
|
||||
|
Loading…
x
Reference in New Issue
Block a user