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.
This commit is contained in:
Yuri D'Elia 2022-06-09 11:43:46 +02:00
parent 8220d0196b
commit 690affe5a2

View File

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