diff --git a/docs/G-Codes.md b/docs/G-Codes.md index b18e0186e..4ef4c0a2c 100644 --- a/docs/G-Codes.md +++ b/docs/G-Codes.md @@ -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 [_ACCEL=] [_VELOCITY=] diff --git a/klippy/toolhead.py b/klippy/toolhead.py index 0b6cfe2cb..59df059ef 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -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 @@ -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 @@ -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) diff --git a/test/klippy/commands.test b/test/klippy/commands.test index e838ae25f..fcf095951 100644 --- a/test/klippy/commands.test +++ b/test/klippy/commands.test @@ -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