Skip to content

Commit

Permalink
toolhead: new RESET_VELOCITY_LIMIT command to reset velocity limits (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerlz authored Dec 23, 2024
1 parent 2ad3338 commit 07adab6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
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

0 comments on commit 07adab6

Please sign in to comment.