From 8220d0196b3c981e5c39e789b7a1d7b034e5afab Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Thu, 9 Jun 2022 11:08:54 +0200 Subject: [PATCH] Lock onto the first error source until cleared Do not overwrite the error source if the error flag is already set. As checks are performed in priority order, this ensures min/maxtemp user-level handlers are triggered even if the thermal model can detect an issue in the same cycle. This restores MAXTEMP handling, which was simply shadowed. --- Firmware/temperature.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 4033f2c9e..49da6fab5 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -485,12 +485,16 @@ void set_temp_error(TempErrorSource source, uint8_t index, TempErrorType type) } #endif - // set the error state + // set the initial error source + if(!temp_error_state.error) { + temp_error_state.source = (uint8_t)source; + temp_error_state.index = index; + temp_error_state.type = (uint8_t)type; + } + + // always set the error state temp_error_state.error = true; temp_error_state.assert = true; - temp_error_state.source = (uint8_t)source; - temp_error_state.index = index; - temp_error_state.type = (uint8_t)type; } void handle_temp_error();