diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 77c077ed42..f02e69ee5a 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -473,7 +473,7 @@ #if ENABLED(PIDTEMP) //#define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of PROGMEM) //#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM) - //#define PID_DEBUG // Sends debug data to the serial port. Use M303 D to toggle activation. + //#define PID_DEBUG // Sends debug data to the serial port. Use 'M303 D' to toggle activation. //#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX //#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay //#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders) diff --git a/Marlin/src/gcode/temp/M303.cpp b/Marlin/src/gcode/temp/M303.cpp index ba119f0d41..657dd867ee 100644 --- a/Marlin/src/gcode/temp/M303.cpp +++ b/Marlin/src/gcode/temp/M303.cpp @@ -34,18 +34,31 @@ /** * M303: PID relay autotune * - * S sets the target temperature. (default 150C / 70C) - * E (-1 for the bed) (default 0) - * C Minimum 3. Default 5. - * U with a non-zero value will apply the result to current settings - * D Toggles PID_DEBUG flag. No other action happens even if more parameters are specified. + * S Set the target temperature. (Default: 150C / 70C) + * E Extruder number to tune, or -1 for the bed. (Default: E0) + * C Number of times to repeat the procedure. (Minimum: 3, Default: 5) + * U Flag to apply the result to the current PID values + * + * With PID_DEBUG: + * D Toggle PID debugging and EXIT without further action. */ #if ENABLED(PID_DEBUG) - bool PID_Debug_Flag = 0; + bool pid_debug_flag = 0; #endif void GcodeSuite::M303() { + + #if ENABLED(PID_DEBUG) + if (parser.seen('D')) { + pid_debug_flag = !pid_debug_flag; + SERIAL_ECHO_START(); + SERIAL_ECHOPGM("PID Debug "); + serialprintln_onoff(pid_debug_flag); + return; + } + #endif + #if ENABLED(PIDTEMPBED) #define SI H_BED #else @@ -69,16 +82,6 @@ void GcodeSuite::M303() { const bool u = parser.boolval('U'); const int16_t temp = parser.celsiusval('S', e < 0 ? 70 : 150); - #if ENABLED(PID_DEBUG) - bool d = parser.boolval('D'); - if (d) { - PID_Debug_Flag = !PID_Debug_Flag; - SERIAL_ECHOPGM("PID Debug set to: "); - SERIAL_ECHOLN( PID_Debug_Flag ); - return; - } - #endif - #if DISABLED(BUSY_WHILE_HEATING) KEEPALIVE_STATE(NOT_BUSY); #endif