zcalibrate: fix delta and round beds not working fixes #1310

This commit is contained in:
alfrix 2024-03-21 09:56:30 -03:00
parent 6ab0566fe1
commit 54ad2981bc

View File

@ -15,6 +15,8 @@ class Panel(ScreenPanel):
super().__init__(screen, title) super().__init__(screen, title)
self.mesh_min = [] self.mesh_min = []
self.mesh_max = [] self.mesh_max = []
self.mesh_radius = None
self.mesh_origin = [0, 0]
self.zero_ref = [] self.zero_ref = []
self.z_hop_speed = 15.0 self.z_hop_speed = 15.0
self.z_hop = 5.0 self.z_hop = 5.0
@ -105,11 +107,18 @@ class Panel(ScreenPanel):
self._add_button("Probe", "probe", pobox) self._add_button("Probe", "probe", pobox)
functions.append("probe") functions.append("probe")
if "BED_MESH_CALIBRATE" in self._printer.available_commands: if "BED_MESH_CALIBRATE" in self._printer.available_commands:
self.mesh_min = self._csv_to_array(self._printer.get_config_section("bed_mesh")['mesh_min']) mesh = self._printer.get_config_section("bed_mesh")
self.mesh_max = self._csv_to_array(self._printer.get_config_section("bed_mesh")['mesh_max']) logging.info(f"Mesh: {mesh}")
if 'mesh_radius' in mesh:
self.mesh_radius = float(mesh['mesh_radius'])
if 'mesh_origin' in mesh:
self.mesh_origin = self._csv_to_array(mesh['mesh_origin'])
logging.info(f"Mesh Radius: {self.mesh_radius} Origin: {self.mesh_origin}")
else:
self.mesh_min = self._csv_to_array(mesh['mesh_min'])
self.mesh_max = self._csv_to_array(mesh['mesh_max'])
if 'zero_reference_position' in self._printer.get_config_section("bed_mesh"): if 'zero_reference_position' in self._printer.get_config_section("bed_mesh"):
self.zero_ref = self._csv_to_array( self.zero_ref = self._csv_to_array(mesh['zero_reference_position'])
self._printer.get_config_section("bed_mesh")['zero_reference_position'])
if "probe" not in functions: if "probe" not in functions:
# This is used to do a manual bed mesh if there is no probe # This is used to do a manual bed mesh if there is no probe
self._add_button("Bed mesh", "mesh", pobox) self._add_button("Bed mesh", "mesh", pobox)
@ -186,9 +195,9 @@ class Panel(ScreenPanel):
if ("safe_z_home" in self._printer.get_config_section_list() and if ("safe_z_home" in self._printer.get_config_section_list() and
"Z_ENDSTOP_CALIBRATE" not in self._printer.available_commands): "Z_ENDSTOP_CALIBRATE" not in self._printer.available_commands):
return self._get_safe_z() return self._get_safe_z()
if "delta" in self._printer.get_config_section("printer")['kinematics']: if self.mesh_radius or "delta" in self._printer.get_config_section("printer")['kinematics']:
logging.info("Detected delta kinematics calibrating at 0,0") logging.info(f"Round bed calibrating at {self.mesh_origin}")
return 0 - self.x_offset, 0 - self.y_offset return self.mesh_origin[0] - self.x_offset, self.mesh_origin[1] - self.y_offset
x, y = self._calculate_position() x, y = self._calculate_position()
return x, y return x, y