From c2522ce1f50dd5efcf2ab3952a239097b8e3ce59 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 8 May 2016 16:51:33 -0700 Subject: [PATCH] Fallthru in thermal runaway test when TRState changes --- Marlin/temperature.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index f8c85fbc9..a8f9c916f 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -1056,24 +1056,21 @@ void Temperature::init() { *state = TRInactive; // Inactive state waits for a target temperature to be set case TRInactive: - if (target_temperature > 0) { - tr_target_temperature[heater_index] = target_temperature; - *state = TRFirstHeating; - } - break; + if (target_temperature <= 0) break; + tr_target_temperature[heater_index] = target_temperature; + *state = TRFirstHeating; // When first heating, wait for the temperature to be reached then go to Stable state case TRFirstHeating: - if (temperature >= tr_target_temperature[heater_index]) *state = TRStable; - break; + if (temperature < tr_target_temperature[heater_index]) break; + *state = TRStable; // While the temperature is stable watch for a bad temperature case TRStable: - // If the temperature is over the target (-hysteresis) restart the timer - if (temperature >= tr_target_temperature[heater_index] - hysteresis_degc) - *timer = millis(); - // If the timer goes too long without a reset, trigger shutdown - else if (ELAPSED(millis(), *timer + period_seconds * 1000UL)) + if (temperature < tr_target_temperature[heater_index] - hysteresis_degc && ELAPSED(millis(), *timer)) *state = TRRunaway; - break; + else { + *timer = millis() + period_seconds * 1000UL; + break; + } case TRRunaway: _temp_error(heater_id, PSTR(MSG_T_THERMAL_RUNAWAY), PSTR(MSG_THERMAL_RUNAWAY)); }