优化移轴页面,实现Z轴无法移动到负数
This commit is contained in:
parent
82de696e0a
commit
92646555e3
@ -129,9 +129,9 @@ class Panel(ScreenPanel):
|
|||||||
# The minimum is 1, but least 2 values are needed to create a scale
|
# The minimum is 1, but least 2 values are needed to create a scale
|
||||||
max_velocity = max(int(float(printer_cfg["max_velocity"])), 2)
|
max_velocity = max(int(float(printer_cfg["max_velocity"])), 2)
|
||||||
if "max_z_velocity" in printer_cfg:
|
if "max_z_velocity" in printer_cfg:
|
||||||
max_z_velocity = max(int(float(printer_cfg["max_z_velocity"])), 2)
|
self.max_z_velocity = max(int(float(printer_cfg["max_z_velocity"])), 2)
|
||||||
else:
|
else:
|
||||||
max_z_velocity = max_velocity
|
self.max_z_velocity = max_velocity
|
||||||
|
|
||||||
configurable_options = [
|
configurable_options = [
|
||||||
{
|
{
|
||||||
@ -184,7 +184,7 @@ class Panel(ScreenPanel):
|
|||||||
"type": "scale",
|
"type": "scale",
|
||||||
"tooltip": _("Only for the move panel"),
|
"tooltip": _("Only for the move panel"),
|
||||||
"value": "10",
|
"value": "10",
|
||||||
"range": [1, max_z_velocity],
|
"range": [1, self.max_z_velocity],
|
||||||
"step": 1,
|
"step": 1,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -249,14 +249,22 @@ class Panel(ScreenPanel):
|
|||||||
direction = "-" if direction == "+" else "+"
|
direction = "-" if direction == "+" else "+"
|
||||||
|
|
||||||
dist = f"{direction}{self.distance}"
|
dist = f"{direction}{self.distance}"
|
||||||
config_key = "move_speed_z" if axis == "Z" else "move_speed_xy"
|
config_key = "move_speed_z" if axis == "z" else "move_speed_xy"
|
||||||
|
if axis == "z":
|
||||||
|
pos_z_text = self.labels["pos_z"].get_text()
|
||||||
|
pos_z_match = re.search(r"Z:\s*([-+]?\d*\.\d+|\d+)", pos_z_text)
|
||||||
|
if pos_z_match:
|
||||||
|
z_value = float(pos_z_match.group(1))
|
||||||
|
if direction == "-" and z_value < float(self.distance):
|
||||||
|
self._screen.show_popup_message(_("Z axis cannot move to negative values"))
|
||||||
|
return
|
||||||
speed = (
|
speed = (
|
||||||
None
|
None
|
||||||
if self.ks_printer_cfg is None
|
if self.ks_printer_cfg is None
|
||||||
else self.ks_printer_cfg.getint(config_key, None)
|
else self.ks_printer_cfg.getint(config_key, None)
|
||||||
)
|
)
|
||||||
if speed is None:
|
if speed is None:
|
||||||
speed = self._config.get_config()["main"].getint(config_key, 20)
|
speed = self._config.get_config()["main"].getint(config_key, self.max_z_velocity)
|
||||||
speed = 60 * max(1, speed)
|
speed = 60 * max(1, speed)
|
||||||
script = f"{KlippyGcodes.MOVE_RELATIVE}\nG0 {axis}{dist} F{speed}"
|
script = f"{KlippyGcodes.MOVE_RELATIVE}\nG0 {axis}{dist} F{speed}"
|
||||||
self._screen._send_action(widget, "printer.gcode.script", {"script": script})
|
self._screen._send_action(widget, "printer.gcode.script", {"script": script})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user