Browse Source

M303 followup

- Put 'D' before other params for clean exit.
- Use serial on/off for debug status.
Scott Lahteine 4 years ago
parent
commit
f2ed18d150
2 changed files with 20 additions and 17 deletions
  1. 1
    1
      Marlin/Configuration.h
  2. 19
    16
      Marlin/src/gcode/temp/M303.cpp

+ 1
- 1
Marlin/Configuration.h View File

@@ -473,7 +473,7 @@
473 473
 #if ENABLED(PIDTEMP)
474 474
   //#define PID_EDIT_MENU         // Add PID editing to the "Advanced Settings" menu. (~700 bytes of PROGMEM)
475 475
   //#define PID_AUTOTUNE_MENU     // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM)
476
-  //#define PID_DEBUG             // Sends debug data to the serial port.  Use M303 D to toggle activation.
476
+  //#define PID_DEBUG             // Sends debug data to the serial port. Use 'M303 D' to toggle activation.
477 477
   //#define PID_OPENLOOP 1        // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
478 478
   //#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
479 479
   //#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders)

+ 19
- 16
Marlin/src/gcode/temp/M303.cpp View File

@@ -34,18 +34,31 @@
34 34
 /**
35 35
  * M303: PID relay autotune
36 36
  *
37
- *       S<temperature> sets the target temperature. (default 150C / 70C)
38
- *       E<extruder> (-1 for the bed) (default 0)
39
- *       C<cycles> Minimum 3. Default 5.
40
- *       U<bool> with a non-zero value will apply the result to current settings
41
- *       D Toggles PID_DEBUG flag. No other action happens even if more parameters are specified.
37
+ *  S<temperature>  Set the target temperature. (Default: 150C / 70C)
38
+ *  E<extruder>     Extruder number to tune, or -1 for the bed. (Default: E0)
39
+ *  C<cycles>       Number of times to repeat the procedure. (Minimum: 3, Default: 5)
40
+ *  U<bool>         Flag to apply the result to the current PID values
41
+ *
42
+ * With PID_DEBUG:
43
+ *  D               Toggle PID debugging and EXIT without further action.
42 44
  */
43 45
 
44 46
 #if ENABLED(PID_DEBUG)
45
-  bool PID_Debug_Flag = 0;
47
+  bool pid_debug_flag = 0;
46 48
 #endif
47 49
 
48 50
 void GcodeSuite::M303() {
51
+
52
+  #if ENABLED(PID_DEBUG)
53
+    if (parser.seen('D')) {
54
+      pid_debug_flag = !pid_debug_flag;
55
+      SERIAL_ECHO_START();
56
+      SERIAL_ECHOPGM("PID Debug ");
57
+      serialprintln_onoff(pid_debug_flag);
58
+      return;
59
+    }
60
+  #endif
61
+
49 62
   #if ENABLED(PIDTEMPBED)
50 63
     #define SI H_BED
51 64
   #else
@@ -69,16 +82,6 @@ void GcodeSuite::M303() {
69 82
   const bool u = parser.boolval('U');
70 83
   const int16_t temp = parser.celsiusval('S', e < 0 ? 70 : 150);
71 84
 
72
-  #if ENABLED(PID_DEBUG)
73
-    bool d = parser.boolval('D');
74
-    if (d) {
75
-      PID_Debug_Flag = !PID_Debug_Flag;
76
-      SERIAL_ECHOPGM("PID Debug set to: ");
77
-      SERIAL_ECHOLN( PID_Debug_Flag );
78
-      return;
79
-    }
80
-  #endif
81
-
82 85
   #if DISABLED(BUSY_WHILE_HEATING)
83 86
     KEEPALIVE_STATE(NOT_BUSY);
84 87
   #endif

Loading…
Cancel
Save