From 5a89f6934a9db2987ef2c8af24649470391e1ccf Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Fri, 30 Dec 2022 13:49:21 +0100 Subject: [PATCH] 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. --- Firmware/temperature.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index a74acea0..f4d7817d 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -2371,11 +2371,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() @@ -2506,7 +2513,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() @@ -2586,7 +2593,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()