Skip to content

Commit

Permalink
TM: Also clear the status flags when disabling the model
Browse files Browse the repository at this point in the history
Disabling the model during a warn/error condition will also stop
updating the warning/error flag, keeping the printer in an error state.

Clear all flags as well when changing model settings.
  • Loading branch information
wavexx authored and DRracer committed Jan 2, 2023
1 parent 9cbf0a2 commit 5020981
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Firmware/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2369,11 +2369,18 @@ void model_data::step(uint8_t heater_pwm, uint8_t fan_pwm, float heater_temp, fl
flag_bits.warning = (fabsf(dT_err_f) > warn_s);
}

// clear error flags and mark as uninitialized
void reinitialize()
{
data.flags = 1; // shorcut to reset all error flags
warning_state.assert = false; // explicitly clear assertions
}

// verify calibration status and trigger a model reset if valid
void setup()
{
if(!calibrated()) enabled = false;
data.flag_bits.uninitialized = true;
reinitialize();
}

bool calibrated()
Expand Down Expand Up @@ -2504,7 +2511,7 @@ static void temp_model_reset_enabled(bool enabled)
{
TempMgrGuard temp_mgr_guard;
temp_model::enabled = enabled;
temp_model::data.flag_bits.uninitialized = true;
temp_model::reinitialize();
}

bool temp_model_enabled()
Expand Down Expand Up @@ -2584,7 +2591,7 @@ void temp_model_reset_settings()
temp_model::data.err = TEMP_MODEL_E;
temp_model::warn_beep = true;
temp_model::enabled = true;
temp_model::data.flag_bits.uninitialized = true;
temp_model::reinitialize();
}

void temp_model_load_settings()
Expand Down

0 comments on commit 5020981

Please sign in to comment.