From b1ea4f3befe202e681115fe4e6b4a5986a581e17 Mon Sep 17 00:00:00 2001
From: Kevin O'Connor <kevin@koconnor.net>
Date: Sun, 25 Apr 2021 14:58:44 -0400
Subject: [PATCH] toolhead: Do not limit SET_VELOCITY_LIMIT to values specified
 in config

Allow a larger velocity, accel, and square_corner_velocity than what
is specified in the config file.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
---
 docs/Config_Changes.md |  4 ++++
 klippy/toolhead.py     | 12 ++++--------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/docs/Config_Changes.md b/docs/Config_Changes.md
index bf8f1124d..64fd43c53 100644
--- a/docs/Config_Changes.md
+++ b/docs/Config_Changes.md
@@ -6,6 +6,10 @@ All dates in this document are approximate.
 
 # Changes
 
+20210430: The SET_VELOCITY_LIMIT (and M204) command may now set a
+velocity, acceleration, and square_corner_velocity larger than the
+specified values in the config file.
+
 20210325: Support for the `pin_map` config option is deprecated. Use
 the [sample-aliases.cfg](../config/sample-aliases.cfg) file to
 translate to the actual micro-controller pin names. The `pin_map`
diff --git a/klippy/toolhead.py b/klippy/toolhead.py
index e1a791799..abb4eb5f9 100644
--- a/klippy/toolhead.py
+++ b/klippy/toolhead.py
@@ -217,9 +217,6 @@ class ToolHead:
         self.max_accel_to_decel = self.requested_accel_to_decel
         self.square_corner_velocity = config.getfloat(
             'square_corner_velocity', 5., minval=0.)
-        self.config_max_velocity = self.max_velocity
-        self.config_max_accel = self.max_accel
-        self.config_square_corner_velocity = self.square_corner_velocity
         self.junction_deviation = 0.
         self._calc_junction_deviation()
         # Print time tracking
@@ -560,10 +557,9 @@ class ToolHead:
             'SQUARE_CORNER_VELOCITY', self.square_corner_velocity, minval=0.)
         self.requested_accel_to_decel = gcmd.get_float(
             'ACCEL_TO_DECEL', self.requested_accel_to_decel, above=0.)
-        self.max_velocity = min(max_velocity, self.config_max_velocity)
-        self.max_accel = min(max_accel, self.config_max_accel)
-        self.square_corner_velocity = min(square_corner_velocity,
-                                          self.config_square_corner_velocity)
+        self.max_velocity = max_velocity
+        self.max_accel = max_accel
+        self.square_corner_velocity = square_corner_velocity
         self._calc_junction_deviation()
         msg = ("max_velocity: %.6f\n"
                "max_accel: %.6f\n"
@@ -586,7 +582,7 @@ class ToolHead:
                                   % (gcmd.get_commandline(),))
                 return
             accel = min(p, t)
-        self.max_accel = min(accel, self.config_max_accel)
+        self.max_accel = accel
         self._calc_junction_deviation()
 
 def add_printer_objects(config):