Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toolhead: new RESET_VELOCITY_LIMIT command to reset velocity limits #472

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/G-Codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,12 @@ printer config file. See the
[printer config section](Config_Reference.md#printer) for a
description of each parameter.

### RESET_VELOCITY_LIMIT
`RESET_VELOCITY_LIMIT`: This command resets the velocity limits to the values
specified in the printer config file. See the
[printer config section](Config_Reference.md#printer) for a
description of each parameter.

#### ⚠️ SET_KINEMATICS_LIMIT

`SET_KINEMATICS_LIMIT [<X,Y,Z>_ACCEL=<value>] [<X,Y,Z>_VELOCITY=<value>]
Expand Down
26 changes: 26 additions & 0 deletions klippy/toolhead.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ def __init__(self, config):
self.square_corner_velocity = config.getfloat(
"square_corner_velocity", 5.0, minval=0.0
)
self.orig_cfg = {}
self.orig_cfg["max_velocity"] = self.max_velocity
self.orig_cfg["max_accel"] = self.max_accel
self.orig_cfg["min_cruise_ratio"] = self.min_cruise_ratio
self.orig_cfg["square_corner_velocity"] = self.square_corner_velocity
self.junction_deviation = self.max_accel_to_decel = 0
self._calc_junction_deviation()
# Input stall detection
Expand Down Expand Up @@ -346,6 +351,11 @@ def __init__(self, config):
self.cmd_SET_VELOCITY_LIMIT,
desc=self.cmd_SET_VELOCITY_LIMIT_help,
)
gcode.register_command(
"RESET_VELOCITY_LIMIT",
self.cmd_RESET_VELOCITY_LIMIT,
desc=self.cmd_RESET_VELOCITY_LIMIT_help,
)
gcode.register_command("M204", self.cmd_M204)
self.printer.register_event_handler(
"klippy:shutdown", self._handle_shutdown
Expand Down Expand Up @@ -822,6 +832,22 @@ def cmd_SET_VELOCITY_LIMIT(self, gcmd):
):
gcmd.respond_info("\n".join(msg), log=False)

cmd_RESET_VELOCITY_LIMIT_help = "Reset printer velocity limits"

def cmd_RESET_VELOCITY_LIMIT(self, gcmd):
self.max_velocity = self.orig_cfg["max_velocity"]
self.max_accel = self.orig_cfg["max_accel"]
self.square_corner_velocity = self.orig_cfg["square_corner_velocity"]
self.min_cruise_ratio = self.orig_cfg["min_cruise_ratio"]
self._calc_junction_deviation()
msg = (
"max_velocity: %.6f" % self.max_velocity,
"max_accel: %.6f" % self.max_accel,
"minimum_cruise_ratio: %.6f" % self.min_cruise_ratio,
"square_corner_velocity: %.6f" % self.square_corner_velocity,
)
gcmd.respond_info("\n".join(msg), log=False)

def cmd_M204(self, gcmd):
# Use S for accel
accel = gcmd.get_float("S", None, above=0.0)
Expand Down
2 changes: 2 additions & 0 deletions test/klippy/commands.test
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ SET_GCODE_OFFSET Z_ADJUST=-.1
SET_VELOCITY_LIMIT ACCEL=100 VELOCITY=20 SQUARE_CORNER_VELOCITY=1 ACCEL_TO_DECEL=200
M204 S500

RESET_VELOCITY_LIMIT

SET_PRESSURE_ADVANCE EXTRUDER=extruder ADVANCE=.001
SET_PRESSURE_ADVANCE ADVANCE=.002 ADVANCE_LOOKAHEAD_TIME=.001

Expand Down
Loading