BED_ANNEALING_GCODE (#26341)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Vovodroid 2023-11-12 04:40:49 +02:00 committed by GitHub
parent d159ec5c90
commit 884a3249fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 4 deletions

View file

@ -779,6 +779,9 @@
//#define BED_LIMIT_SWITCHING // Keep the bed temperature within BED_HYSTERESIS of the target //#define BED_LIMIT_SWITCHING // Keep the bed temperature within BED_HYSTERESIS of the target
#endif #endif
// Add 'M190 R T' for more gradual M190 R bed cooling.
//#define BED_ANNEALING_GCODE
//=========================================================================== //===========================================================================
//==================== PID > Chamber Temperature Control ==================== //==================== PID > Chamber Temperature Control ====================
//=========================================================================== //===========================================================================

View file

@ -54,6 +54,16 @@
* *
* With PRINTJOB_TIMER_AUTOSTART turning on heaters will start the print job timer * With PRINTJOB_TIMER_AUTOSTART turning on heaters will start the print job timer
* (used by printingIsActive, etc.) and turning off heaters will stop the timer. * (used by printingIsActive, etc.) and turning off heaters will stop the timer.
*
* With BED_ANNEALING_GCODE:
*
* M190 Parameters
* T<seconds>: Cooldown time, for more gradual cooling. Use with R parameter.
* M190 R T - Cool the bed down over a given period of time.
*
* Examples
* M190 R70 T600: Cool down to 70°C over a period of ten minutes.
*
*/ */
void GcodeSuite::M140_M190(const bool isM190) { void GcodeSuite::M140_M190(const bool isM190) {
@ -81,19 +91,47 @@ void GcodeSuite::M140_M190(const bool isM190) {
if (!got_temp) return; if (!got_temp) return;
thermalManager.setTargetBed(temp); #if ENABLED(BED_ANNEALING_GCODE)
thermalManager.isHeatingBed() ? LCD_MESSAGE(MSG_BED_HEATING) : LCD_MESSAGE(MSG_BED_COOLING); const bool anneal = isM190 && !no_wait_for_cooling && parser.seenval('T');
const millis_t anneal_ms = anneal ? millis() + parser.value_millis_from_seconds() : 0UL;
#else
constexpr bool anneal = false;
#endif
if (!anneal) {
thermalManager.setTargetBed(temp);
thermalManager.isHeatingBed() ? LCD_MESSAGE(MSG_BED_HEATING) : LCD_MESSAGE(MSG_BED_COOLING);
}
// With PRINTJOB_TIMER_AUTOSTART, M190 can start the timer, and M140 can stop it // With PRINTJOB_TIMER_AUTOSTART, M190 can start the timer, and M140 can stop it
TERN_(PRINTJOB_TIMER_AUTOSTART, thermalManager.auto_job_check_timer(isM190, !isM190)); TERN_(PRINTJOB_TIMER_AUTOSTART, thermalManager.auto_job_check_timer(isM190, !isM190));
if (isM190) if (isM190) {
#if ENABLED(BED_ANNEALING_GCODE)
if (anneal) {
LCD_MESSAGE(MSG_BED_ANNEALING);
// Loop from current temp down to the target
for (celsius_t cool_temp = thermalManager.degBed(); --cool_temp >= temp; ) {
thermalManager.setTargetBed(cool_temp); // Cool by one degree
thermalManager.wait_for_bed(false); // Could this wait forever?
const millis_t ms = millis();
if (PENDING(ms, anneal_ms) && cool_temp > temp) { // Still warmer and waiting?
const millis_t remain = anneal_ms - ms;
dwell(remain / (cool_temp - temp)); // Wait for a fraction of remaining time
}
}
return;
}
#endif
thermalManager.wait_for_bed(no_wait_for_cooling); thermalManager.wait_for_bed(no_wait_for_cooling);
else }
else {
ui.set_status_reset_fn([]{ ui.set_status_reset_fn([]{
const celsius_t c = thermalManager.degTargetBed(); const celsius_t c = thermalManager.degTargetBed();
return c < 30 || thermalManager.degBedNear(c); return c < 30 || thermalManager.degBedNear(c);
}); });
}
} }
#endif // HAS_HEATED_BED #endif // HAS_HEATED_BED

View file

@ -626,6 +626,7 @@ namespace LanguageNarrow_en {
LSTR MSG_COOLING = _UxGT("Cooling..."); LSTR MSG_COOLING = _UxGT("Cooling...");
LSTR MSG_BED_HEATING = _UxGT("Bed Heating..."); LSTR MSG_BED_HEATING = _UxGT("Bed Heating...");
LSTR MSG_BED_COOLING = _UxGT("Bed Cooling..."); LSTR MSG_BED_COOLING = _UxGT("Bed Cooling...");
LSTR MSG_BED_ANNEALING = _UxGT("Annealing...");
LSTR MSG_PROBE_HEATING = _UxGT("Probe Heating..."); LSTR MSG_PROBE_HEATING = _UxGT("Probe Heating...");
LSTR MSG_PROBE_COOLING = _UxGT("Probe Cooling..."); LSTR MSG_PROBE_COOLING = _UxGT("Probe Cooling...");
LSTR MSG_CHAMBER_HEATING = _UxGT("Chamber Heating..."); LSTR MSG_CHAMBER_HEATING = _UxGT("Chamber Heating...");