|
@@ -1056,24 +1056,21 @@ void Temperature::init() {
|
1056
|
1056
|
*state = TRInactive;
|
1057
|
1057
|
// Inactive state waits for a target temperature to be set
|
1058
|
1058
|
case TRInactive:
|
1059
|
|
- if (target_temperature > 0) {
|
1060
|
|
- tr_target_temperature[heater_index] = target_temperature;
|
1061
|
|
- *state = TRFirstHeating;
|
1062
|
|
- }
|
1063
|
|
- break;
|
|
1059
|
+ if (target_temperature <= 0) break;
|
|
1060
|
+ tr_target_temperature[heater_index] = target_temperature;
|
|
1061
|
+ *state = TRFirstHeating;
|
1064
|
1062
|
// When first heating, wait for the temperature to be reached then go to Stable state
|
1065
|
1063
|
case TRFirstHeating:
|
1066
|
|
- if (temperature >= tr_target_temperature[heater_index]) *state = TRStable;
|
1067
|
|
- break;
|
|
1064
|
+ if (temperature < tr_target_temperature[heater_index]) break;
|
|
1065
|
+ *state = TRStable;
|
1068
|
1066
|
// While the temperature is stable watch for a bad temperature
|
1069
|
1067
|
case TRStable:
|
1070
|
|
- // If the temperature is over the target (-hysteresis) restart the timer
|
1071
|
|
- if (temperature >= tr_target_temperature[heater_index] - hysteresis_degc)
|
1072
|
|
- *timer = millis();
|
1073
|
|
- // If the timer goes too long without a reset, trigger shutdown
|
1074
|
|
- else if (ELAPSED(millis(), *timer + period_seconds * 1000UL))
|
|
1068
|
+ if (temperature < tr_target_temperature[heater_index] - hysteresis_degc && ELAPSED(millis(), *timer))
|
1075
|
1069
|
*state = TRRunaway;
|
1076
|
|
- break;
|
|
1070
|
+ else {
|
|
1071
|
+ *timer = millis() + period_seconds * 1000UL;
|
|
1072
|
+ break;
|
|
1073
|
+ }
|
1077
|
1074
|
case TRRunaway:
|
1078
|
1075
|
_temp_error(heater_id, PSTR(MSG_T_THERMAL_RUNAWAY), PSTR(MSG_THERMAL_RUNAWAY));
|
1079
|
1076
|
}
|