Set the initial state based on target temperature

This commit is contained in:
Scott Lahteine 2016-05-08 17:07:45 -07:00
parent 6b13c430ae
commit 9b92bb8f31

View file

@ -1047,15 +1047,14 @@ void Temperature::init() {
int heater_index = heater_id >= 0 ? heater_id : EXTRUDERS;
// If the target temperature changes, restart
if (tr_target_temperature[heater_index] != target_temperature)
*state = TRInactive;
if (tr_target_temperature[heater_index] != target_temperature) {
tr_target_temperature[heater_index] = target_temperature;
*state = target_temperature > 0 ? TRFirstHeating : TRInactive;
}
switch (*state) {
// Inactive state waits for a target temperature to be set
case TRInactive:
if (target_temperature <= 0) break;
tr_target_temperature[heater_index] = target_temperature;
*state = TRFirstHeating;
case TRInactive: break;
// When first heating, wait for the temperature to be reached then go to Stable state
case TRFirstHeating:
if (temperature < tr_target_temperature[heater_index]) break;