Chamber Heater PID (#21156)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
		@@ -40,19 +40,15 @@
 | 
			
		||||
 *  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:
 | 
			
		||||
 * With PID_DEBUG, PID_BED_DEBUG, or PID_CHAMBER_DEBUG:
 | 
			
		||||
 *  D               Toggle PID debugging and EXIT without further action.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#if ENABLED(PID_DEBUG)
 | 
			
		||||
  bool pid_debug_flag = 0;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void GcodeSuite::M303() {
 | 
			
		||||
 | 
			
		||||
  #if ENABLED(PID_DEBUG)
 | 
			
		||||
  #if ANY(PID_DEBUG, PID_BED_DEBUG, PID_CHAMBER_DEBUG)
 | 
			
		||||
    if (parser.seen('D')) {
 | 
			
		||||
      pid_debug_flag = !pid_debug_flag;
 | 
			
		||||
      thermalManager.pid_debug_flag ^= true;
 | 
			
		||||
      SERIAL_ECHO_START();
 | 
			
		||||
      SERIAL_ECHOPGM("PID Debug ");
 | 
			
		||||
      serialprintln_onoff(pid_debug_flag);
 | 
			
		||||
@@ -60,25 +56,34 @@ void GcodeSuite::M303() {
 | 
			
		||||
    }
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
  #define SI TERN(PIDTEMPBED, H_BED, H_E0)
 | 
			
		||||
  #define EI TERN(PIDTEMP, HOTENDS - 1, H_BED)
 | 
			
		||||
  const heater_id_t e = (heater_id_t)parser.intval('E');
 | 
			
		||||
  if (!WITHIN(e, SI, EI)) {
 | 
			
		||||
    SERIAL_ECHOLNPGM(STR_PID_BAD_EXTRUDER_NUM);
 | 
			
		||||
    TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM));
 | 
			
		||||
    return;
 | 
			
		||||
  const heater_id_t hid = (heater_id_t)parser.intval('E');
 | 
			
		||||
  int16_t default_temp;
 | 
			
		||||
  switch (hid) {
 | 
			
		||||
    #if ENABLED(PIDTEMP)
 | 
			
		||||
      case 0 ... HOTENDS - 1: default_temp = PREHEAT_1_TEMP_HOTEND; break;
 | 
			
		||||
    #endif
 | 
			
		||||
    #if ENABLED(PIDTEMPBED)
 | 
			
		||||
      case H_BED: default_temp = PREHEAT_1_TEMP_BED; break;
 | 
			
		||||
    #endif
 | 
			
		||||
    #if ENABLED(PIDTEMPCHAMBER)
 | 
			
		||||
      case H_CHAMBER: default_temp = PREHEAT_1_TEMP_CHAMBER; break;
 | 
			
		||||
    #endif
 | 
			
		||||
    default:
 | 
			
		||||
      SERIAL_ECHOLNPGM(STR_PID_BAD_HEATER_ID);
 | 
			
		||||
      TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM));
 | 
			
		||||
      return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const int16_t temp = parser.celsiusval('S', default_temp);
 | 
			
		||||
  const int c = parser.intval('C', 5);
 | 
			
		||||
  const bool u = parser.boolval('U');
 | 
			
		||||
  const int16_t temp = parser.celsiusval('S', e < 0 ? PREHEAT_1_TEMP_BED : PREHEAT_1_TEMP_HOTEND);
 | 
			
		||||
 | 
			
		||||
  #if DISABLED(BUSY_WHILE_HEATING)
 | 
			
		||||
    KEEPALIVE_STATE(NOT_BUSY);
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
  LCD_MESSAGEPGM(MSG_PID_AUTOTUNE);
 | 
			
		||||
  thermalManager.PID_autotune(temp, e, c, u);
 | 
			
		||||
  thermalManager.PID_autotune(temp, hid, c, u);
 | 
			
		||||
  ui.reset_status();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user