Browse Source

Further enhance thermal error priorities

When triggering a thermal error, allow higher-priority errors to
override the initial error source.

This allows a fatal error such as maxtemp to trigger to a full stop even
if thermal runaway has already been triggered.

Reorder error types according to their priority.
Yuri D'Elia 2 years ago
parent
commit
690affe5a2
1 changed files with 4 additions and 3 deletions
  1. 4 3
      Firmware/temperature.cpp

+ 4 - 3
Firmware/temperature.cpp

@@ -447,10 +447,11 @@ enum class TempErrorSource : uint8_t
     ambient,
 };
 
+// thermal error type (in order of decreasing priority!)
 enum class TempErrorType : uint8_t
 {
-    min,
     max,
+    min,
     preheat,
     runaway,
     model,
@@ -485,8 +486,8 @@ void set_temp_error(TempErrorSource source, uint8_t index, TempErrorType type)
     }
 #endif
 
-    // set the initial error source
-    if(!temp_error_state.error) {
+    // set the initial error source to the highest priority error
+    if(!temp_error_state.error || (uint8_t)type < temp_error_state.type) {
         temp_error_state.source = (uint8_t)source;
         temp_error_state.index = index;
         temp_error_state.type = (uint8_t)type;