Merge pull request #3438 from thinkyhead/rc_M109_residency_loop_fix
Fix bug which can cause an infinite M109 loop
This commit is contained in:
commit
6bd20371f0
@ -4290,7 +4290,7 @@ inline void gcode_M109() {
|
|||||||
#ifdef TEMP_RESIDENCY_TIME
|
#ifdef TEMP_RESIDENCY_TIME
|
||||||
long residency_start_ms = -1;
|
long residency_start_ms = -1;
|
||||||
// Loop until the temperature has stabilized
|
// Loop until the temperature has stabilized
|
||||||
#define TEMP_CONDITIONS (residency_start_ms < 0 || now < residency_start_ms + (TEMP_RESIDENCY_TIME) * 1000UL)
|
#define TEMP_CONDITIONS (residency_start_ms == -1 || now < residency_start_ms + (TEMP_RESIDENCY_TIME) * 1000UL)
|
||||||
#else
|
#else
|
||||||
// Loop until the temperature is very close target
|
// Loop until the temperature is very close target
|
||||||
#define TEMP_CONDITIONS (isHeatingHotend(target_extruder))
|
#define TEMP_CONDITIONS (isHeatingHotend(target_extruder))
|
||||||
@ -4307,7 +4307,7 @@ inline void gcode_M109() {
|
|||||||
#endif
|
#endif
|
||||||
#ifdef TEMP_RESIDENCY_TIME
|
#ifdef TEMP_RESIDENCY_TIME
|
||||||
SERIAL_PROTOCOLPGM(" W:");
|
SERIAL_PROTOCOLPGM(" W:");
|
||||||
if (residency_start_ms >= 0) {
|
if (residency_start_ms != -1) {
|
||||||
long rem = (((TEMP_RESIDENCY_TIME) * 1000UL) - (now - residency_start_ms)) / 1000UL;
|
long rem = (((TEMP_RESIDENCY_TIME) * 1000UL) - (now - residency_start_ms)) / 1000UL;
|
||||||
SERIAL_PROTOCOLLN(rem);
|
SERIAL_PROTOCOLLN(rem);
|
||||||
}
|
}
|
||||||
@ -4323,10 +4323,18 @@ inline void gcode_M109() {
|
|||||||
refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out
|
refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out
|
||||||
|
|
||||||
#ifdef TEMP_RESIDENCY_TIME
|
#ifdef TEMP_RESIDENCY_TIME
|
||||||
|
|
||||||
|
float temp_diff = labs(degHotend(target_extruder) - degTargetHotend(target_extruder));
|
||||||
|
|
||||||
|
if (residency_start_ms == -1) {
|
||||||
// Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.
|
// Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.
|
||||||
|
if (temp_diff < TEMP_WINDOW) residency_start_ms = millis();
|
||||||
|
}
|
||||||
|
else if (temp_diff > TEMP_HYSTERESIS) {
|
||||||
// Restart the timer whenever the temperature falls outside the hysteresis.
|
// Restart the timer whenever the temperature falls outside the hysteresis.
|
||||||
if (labs(degHotend(target_extruder) - degTargetHotend(target_extruder)) > ((residency_start_ms < 0) ? TEMP_WINDOW : TEMP_HYSTERESIS))
|
|
||||||
residency_start_ms = millis();
|
residency_start_ms = millis();
|
||||||
|
}
|
||||||
|
|
||||||
#endif //TEMP_RESIDENCY_TIME
|
#endif //TEMP_RESIDENCY_TIME
|
||||||
|
|
||||||
} // while(!cancel_heatup && TEMP_CONDITIONS)
|
} // while(!cancel_heatup && TEMP_CONDITIONS)
|
||||||
|
Loading…
Reference in New Issue
Block a user