Browse Source

TM: Also clear the status flags when disabling the model

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.
Yuri D'Elia 2 years ago
parent
commit
50209815ea
1 changed files with 10 additions and 3 deletions
  1. 10 3
      Firmware/temperature.cpp

+ 10 - 3
Firmware/temperature.cpp

@@ -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);
     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
 // verify calibration status and trigger a model reset if valid
 void setup()
 void setup()
 {
 {
     if(!calibrated()) enabled = false;
     if(!calibrated()) enabled = false;
-    data.flag_bits.uninitialized = true;
+    reinitialize();
 }
 }
 
 
 bool calibrated()
 bool calibrated()
@@ -2504,7 +2511,7 @@ static void temp_model_reset_enabled(bool enabled)
 {
 {
     TempMgrGuard temp_mgr_guard;
     TempMgrGuard temp_mgr_guard;
     temp_model::enabled = enabled;
     temp_model::enabled = enabled;
-    temp_model::data.flag_bits.uninitialized = true;
+    temp_model::reinitialize();
 }
 }
 
 
 bool temp_model_enabled()
 bool temp_model_enabled()
@@ -2584,7 +2591,7 @@ void temp_model_reset_settings()
     temp_model::data.err = TEMP_MODEL_E;
     temp_model::data.err = TEMP_MODEL_E;
     temp_model::warn_beep = true;
     temp_model::warn_beep = true;
     temp_model::enabled = true;
     temp_model::enabled = true;
-    temp_model::data.flag_bits.uninitialized = true;
+    temp_model::reinitialize();
 }
 }
 
 
 void temp_model_load_settings()
 void temp_model_load_settings()