0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-02-16 22:37:35 +00:00

Simplify M190 annealing code

This commit is contained in:
vovodroid 2024-03-19 14:54:38 +02:00
parent 05896551f1
commit c730076e57

View file

@ -93,7 +93,7 @@ void GcodeSuite::M140_M190(const bool isM190) {
#if ENABLED(BED_ANNEALING_GCODE) #if ENABLED(BED_ANNEALING_GCODE)
const bool anneal = isM190 && !no_wait_for_cooling && parser.seenval('T'); const bool anneal = isM190 && !no_wait_for_cooling && parser.seenval('T');
const millis_t anneal_ms = anneal ? millis() + parser.value_millis_from_seconds() : 0UL; const millis_t anneal_ms = anneal ? parser.value_millis_from_seconds() : 0UL;
#else #else
constexpr bool anneal = false; constexpr bool anneal = false;
#endif #endif
@ -110,15 +110,11 @@ void GcodeSuite::M140_M190(const bool isM190) {
#if ENABLED(BED_ANNEALING_GCODE) #if ENABLED(BED_ANNEALING_GCODE)
if (anneal) { if (anneal) {
LCD_MESSAGE(MSG_BED_ANNEALING); LCD_MESSAGE(MSG_BED_ANNEALING);
const millis_t wait_ms = anneal_ms / (thermalManager.degBed() - temp) ;
// Loop from current temp down to the target // Loop from current temp down to the target
for (celsius_t cool_temp = thermalManager.degBed(); --cool_temp >= temp; ) { for (celsius_t cool_temp = thermalManager.degBed() - 1; cool_temp >= temp; --cool_temp) {
thermalManager.setTargetBed(cool_temp); // Cool by one degree thermalManager.setTargetBed(cool_temp); // Cool by one degree
thermalManager.wait_for_bed(false); // Could this wait forever? dwell(wait_ms); //Wait for going to the next degree
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; return;
} }