Skip to content

Commit

Permalink
M303 followup
Browse files Browse the repository at this point in the history
- Put 'D' before other params for clean exit.
- Use serial on/off for debug status.
  • Loading branch information
thinkyhead committed Mar 25, 2020
1 parent 1986e1c commit f2ed18d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
35 changes: 19 additions & 16 deletions Marlin/src/gcode/temp/M303.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,31 @@
/**
* M303: PID relay autotune
*
* S<temperature> sets the target temperature. (default 150C / 70C)
* E<extruder> (-1 for the bed) (default 0)
* C<cycles> Minimum 3. Default 5.
* U<bool> 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<temperature> Set the target temperature. (Default: 150C / 70C)
* E<extruder> Extruder number to tune, or -1 for the bed. (Default: E0)
* C<cycles> Number of times to repeat the procedure. (Minimum: 3, Default: 5)
* U<bool> 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
Expand All @@ -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
Expand Down

0 comments on commit f2ed18d

Please sign in to comment.