From 1baa45913ffd05a808d5d9ea0ae0161ebbaff247 Mon Sep 17 00:00:00 2001
From: Kevin O'Connor <kevin@koconnor.net>
Date: Fri, 12 Jan 2024 22:52:32 -0500
Subject: [PATCH] output_pin: Deprecate the maximum_mcu_duration parameter

Advise users to configure a pwm_tool config section if checking for
maximum mcu duration is required.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
---
 docs/Config_Changes.md      |  4 ++++
 docs/Config_Reference.md    | 18 +++++++++---------
 klippy/extras/output_pin.py |  1 +
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/docs/Config_Changes.md b/docs/Config_Changes.md
index bd00e3d7e..c660c42aa 100644
--- a/docs/Config_Changes.md
+++ b/docs/Config_Changes.md
@@ -8,6 +8,10 @@ All dates in this document are approximate.
 
 ## Changes
 
+20240123: The output_pin `maximum_mcu_duration` parameter is
+deprecated. Use a [pwm_tool config section](Config_Reference.md#pwm_tool)
+instead. The option will be removed in the near future.
+
 20240123: The output_pin `static_value` parameter is deprecated.
 Replace with `value` and `shutdown_value` parameters.  The option will
 be removed in the near future.
diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md
index a6964e5bd..226b7a133 100644
--- a/docs/Config_Reference.md
+++ b/docs/Config_Reference.md
@@ -3102,13 +3102,6 @@ pin:
 #shutdown_value:
 #   The value to set the pin to on an MCU shutdown event. The default
 #   is 0 (for low voltage).
-#maximum_mcu_duration:
-#   The maximum duration a non-shutdown value may be driven by the MCU
-#   without an acknowledge from the host.
-#   If host can not keep up with an update, the MCU will shutdown
-#   and set all pins to their respective shutdown values.
-#   Default: 0 (disabled)
-#   Usual values are around 5 seconds.
 #cycle_time: 0.100
 #   The amount of time (in seconds) per PWM cycle. It is recommended
 #   this be 10 milliseconds or greater when using software based PWM.
@@ -3128,8 +3121,9 @@ pin:
 #   then the 'value' parameter can be specified using the desired
 #   amperage for the stepper. The default is to not scale the 'value'
 #   parameter.
+#maximum_mcu_duration:
 #static_value:
-#   This option is deprecated and should no longer be specified.
+#   These options are deprecated and should no longer be specified.
 ```
 
 ### [pwm_tool]
@@ -3144,9 +3138,15 @@ extended [g-code commands](G-Codes.md#output_pin).
 [pwm_tool my_tool]
 pin:
 #   The pin to configure as an output. This parameter must be provided.
+#maximum_mcu_duration:
+#   The maximum duration a non-shutdown value may be driven by the MCU
+#   without an acknowledge from the host.
+#   If host can not keep up with an update, the MCU will shutdown
+#   and set all pins to their respective shutdown values.
+#   Default: 0 (disabled)
+#   Usual values are around 5 seconds.
 #value:
 #shutdown_value:
-#maximum_mcu_duration:
 #cycle_time: 0.100
 #hardware_pwm: False
 #scale:
diff --git a/klippy/extras/output_pin.py b/klippy/extras/output_pin.py
index 7b78775be..76789c37d 100644
--- a/klippy/extras/output_pin.py
+++ b/klippy/extras/output_pin.py
@@ -36,6 +36,7 @@ class PrinterOutputPin:
                                            maxval=MAX_SCHEDULE_TIME)
         self.mcu_pin.setup_max_duration(max_mcu_duration)
         if max_mcu_duration:
+            config.deprecate('maximum_mcu_duration')
             self.resend_interval = max_mcu_duration - RESEND_HOST_TIME
         # Determine start and shutdown values
         static_value = config.getfloat('static_value', None,