From 66139b659cfecde331e9892e8d484f76cc3baad9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 31 Dec 2021 07:08:07 -0600 Subject: [PATCH] fix code structure, say "malfunction" --- Marlin/Configuration_adv.h | 5 +--- Marlin/src/core/language.h | 2 +- Marlin/src/lcd/language/language_el.h | 2 +- Marlin/src/lcd/language/language_en.h | 2 +- Marlin/src/module/temperature.cpp | 36 +++++++++++---------------- Marlin/src/module/temperature.h | 7 +++--- 6 files changed, 22 insertions(+), 32 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index aababb50fb0e5..6e91ac377b315 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -350,10 +350,7 @@ #endif #if ANY(THERMAL_PROTECTION_HOTENDS, THERMAL_PROTECTION_BED, THERMAL_PROTECTION_CHAMBER, THERMAL_PROTECTION_COOLER) - /** - * Detect malfunctions in temperature updating mechanism. - */ - #define THERMAL_PROTECTION_VARIANCE_MONITOR + #define THERMAL_PROTECTION_VARIANCE_MONITOR // Detect a malfunctions preventing temperature updates #endif #if ENABLED(PIDTEMP) diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index 256737453cf05..707296b3574be 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -240,7 +240,7 @@ #define STR_REDUNDANCY "Heater switched off. Temperature difference between temp sensors is too high !" #define STR_T_HEATING_FAILED "Heating failed" #define STR_T_THERMAL_RUNAWAY "Thermal Runaway" -#define STR_T_TEMP_NOT_UPDATING "Temperature not updating" +#define STR_T_MALFUNCTION "Thermal Malfunction" #define STR_T_MAXTEMP "MAXTEMP triggered" #define STR_T_MINTEMP "MINTEMP triggered" #define STR_ERR_PROBING_FAILED "Probing Failed" diff --git a/Marlin/src/lcd/language/language_el.h b/Marlin/src/lcd/language/language_el.h index 63595e06da44c..265e02c0ef0aa 100644 --- a/Marlin/src/lcd/language/language_el.h +++ b/Marlin/src/lcd/language/language_el.h @@ -202,7 +202,7 @@ namespace Language_el { LSTR MSG_HEATING_FAILED_LCD = _UxGT("Αποτυχία θέρμανσης"); LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("ΠΛΕΟΝΑΖΟΥΣΑ ΘΕΡΜΟΤΗΤΑ"); LSTR MSG_THERMAL_RUNAWAY = _UxGT("ΘΕΡΜΙΚΗ ΔΙΑΦΥΓΗ"); - LSTR MSG_TEMP_NOT_UPDATING = _UxGT("ΜΗ ΕΝΗΜΕΡΩΣΗ ΘΕΡΜΟΚΡ."); + LSTR MSG_TEMP_MALFUNCTION = _UxGT("ΘΕΡΜΙΚΗ ΔΥΣΛΕΙΤΟΥΡΓΙΑ"); LSTR MSG_ERR_MAXTEMP = _UxGT("ΠΕΡΙΤΤΗ ΘΕΡΜΟΚΡΑΣΙΑ"); LSTR MSG_ERR_MINTEMP = _UxGT("ΑΝΕΠΑΡΚΗΣ ΘΕΡΜΟΚΡΑΣΙΑ"); LSTR MSG_HALTED = _UxGT("Εκτυπωτής διεκόπη"); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index b2ee4566ea9db..f1beb62e07029 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -533,7 +533,7 @@ namespace Language_en { LSTR MSG_HEATING_FAILED_LCD = _UxGT("Heating Failed"); LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("Err: REDUNDANT TEMP"); LSTR MSG_THERMAL_RUNAWAY = _UxGT("THERMAL RUNAWAY"); - LSTR MSG_TEMP_NOT_UPDATING = _UxGT("TEMP NOT UPDATING"); + LSTR MSG_TEMP_MALFUNCTION = _UxGT("TEMP MALFUNCTION"); LSTR MSG_THERMAL_RUNAWAY_BED = _UxGT("BED THERMAL RUNAWAY"); LSTR MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("CHAMBER T. RUNAWAY"); LSTR MSG_THERMAL_RUNAWAY_COOLER = _UxGT("Cooler Runaway"); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 38ea339ce5462..b2063f5162e10 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -196,7 +196,7 @@ Temperature thermalManager; PGMSTR(str_t_thermal_runaway, STR_T_THERMAL_RUNAWAY); -PGMSTR(str_t_temp_not_updating, STR_T_TEMP_NOT_UPDATING); +PGMSTR(str_t_temp_malfunction, STR_T_MALFUNCTION); PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); /** @@ -2572,7 +2572,7 @@ void Temperature::init() { */ #if ENABLED(THERMAL_PROTECTION_VARIANCE_MONITOR) - if (state == TRTempNotUpdating) { // temperature invariance may continue, regardless of heater state + if (state == TRMalfunction) { // temperature invariance may continue, regardless of heater state variance += ABS(current - last_temp); // no need for detection window now, a single change in variance is enough last_temp = current; if (!NEAR_ZERO(variance)) { @@ -2581,30 +2581,22 @@ void Temperature::init() { state = TRStable; // resume from where we detected the problem } } - - if (state == TRTempNotUpdating) { - } else #endif - #if HEATER_IDLE_HANDLER + + if (TERN1(THERMAL_PROTECTION_VARIANCE_MONITOR, state != TRMalfunction)) { // If the heater idle timeout expires, restart - if (heater_idle[idle_index].timed_out) { + if (TERN0(HEATER_IDLE_HANDLER, heater_idle[idle_index].timed_out)) { state = TRInactive; running_temp = 0; TERN_(THERMAL_PROTECTION_VARIANCE_MONITOR, variance_timer = 0); } - else - #endif - { - // If the target temperature changes, restart - if (running_temp != target) { + else if (running_temp != target) { // If the target temperature changes, restart running_temp = target; state = target > 0 ? TRFirstHeating : TRInactive; TERN_(THERMAL_PROTECTION_VARIANCE_MONITOR, variance_timer = 0); } } - millis_t now; - switch (state) { // Inactive state waits for a target temperature to be set case TRInactive: break; @@ -2615,7 +2607,7 @@ void Temperature::init() { state = TRStable; // While the temperature is stable watch for a bad temperature - case TRStable: + case TRStable: { #if ENABLED(ADAPTIVE_FAN_SLOWING) if (adaptive_fan_slowing && heater_id >= 0) { @@ -2632,8 +2624,8 @@ void Temperature::init() { fan_speed_scaler[fan_index] = 0; } #endif - - now = millis(); + + const millis_t now = millis(); #if ENABLED(THERMAL_PROTECTION_VARIANCE_MONITOR) if (PENDING(now, variance_timer)) { @@ -2641,8 +2633,8 @@ void Temperature::init() { last_temp = current; } else { - if (NEAR_ZERO(variance) && variance_timer > 0) { // valid variance monitoring window - state = TRTempNotUpdating; + if (NEAR_ZERO(variance) && variance_timer) { // valid variance monitoring window + state = TRMalfunction; break; } variance_timer = now + SEC_TO_MS(period_seconds); @@ -2658,14 +2650,16 @@ void Temperature::init() { else if (PENDING(now, timer)) break; state = TRRunaway; + } // fall through + case TRRunaway: TERN_(HAS_DWIN_E3V2_BASIC, DWIN_Popup_Temperature(0)); _temp_error(heater_id, FPSTR(str_t_thermal_runaway), GET_TEXT_F(MSG_THERMAL_RUNAWAY)); #if ENABLED(THERMAL_PROTECTION_VARIANCE_MONITOR) - case TRTempNotUpdating: + case TRMalfunction: TERN_(HAS_DWIN_E3V2_BASIC, DWIN_Popup_Temperature(0)); - _temp_error(heater_id, FPSTR(str_t_temp_not_updating), GET_TEXT_F(MSG_TEMP_NOT_UPDATING)); + _temp_error(heater_id, FPSTR(str_t_temp_malfunction), GET_TEXT_F(MSG_TEMP_MALFUNCTION)); #endif } } diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index a75d9fbb6cac2..10ab85d345ada 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -1035,8 +1035,8 @@ class Temperature { return (RunawayIndex)_MAX(heater_id, 0); } - enum TRState : char { TRInactive, TRFirstHeating, TRStable, TRRunaway - OPTARG(THERMAL_PROTECTION_VARIANCE_MONITOR, TRTempNotUpdating) + enum TRState : char { TRInactive, TRFirstHeating, TRStable, TRRunaway + OPTARG(THERMAL_PROTECTION_VARIANCE_MONITOR, TRMalfunction) }; typedef struct { @@ -1045,8 +1045,7 @@ class Temperature { float running_temp; #if ENABLED(THERMAL_PROTECTION_VARIANCE_MONITOR) millis_t variance_timer = 0; - celsius_float_t last_temp = 0.0; - celsius_float_t variance = 0.0; + celsius_float_t last_temp = 0.0, variance = 0.0; #endif void run(const_celsius_float_t current, const_celsius_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc); } tr_state_machine_t;