diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 13a70bb85..3bcfe3928 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -517,17 +517,25 @@ void Temperature::_temp_error(int e, const char* serial_msg, const char* lcd_msg #endif } -void Temperature::max_temp_error(uint8_t e) { - #if HOTENDS == 1 - UNUSED(e); +void Temperature::max_temp_error(int8_t e) { + #if HAS_TEMP_BED + _temp_error(e, PSTR(MSG_T_MAXTEMP), e >= 0 ? PSTR(MSG_ERR_MAXTEMP) : PSTR(MSG_ERR_MAXTEMP_BED)); + #else + _temp_error(HOTEND_INDEX, PSTR(MSG_T_MAXTEMP), PSTR(MSG_ERR_MAXTEMP)); + #if HOTENDS == 1 + UNUSED(e); + #endif #endif - _temp_error(HOTEND_INDEX, PSTR(MSG_T_MAXTEMP), PSTR(MSG_ERR_MAXTEMP)); } -void Temperature::min_temp_error(uint8_t e) { - #if HOTENDS == 1 - UNUSED(e); +void Temperature::min_temp_error(int8_t e) { + #if HAS_TEMP_BED + _temp_error(e, PSTR(MSG_T_MINTEMP), e >= 0 ? PSTR(MSG_ERR_MINTEMP) : PSTR(MSG_ERR_MINTEMP_BED)); + #else + _temp_error(HOTEND_INDEX, PSTR(MSG_T_MINTEMP), PSTR(MSG_ERR_MINTEMP)); + #if HOTENDS == 1 + UNUSED(e); + #endif #endif - _temp_error(HOTEND_INDEX, PSTR(MSG_T_MINTEMP), PSTR(MSG_ERR_MINTEMP)); } float Temperature::get_pid_output(int e) { @@ -675,9 +683,8 @@ void Temperature::manage_heater() { updateTemperaturesFromRawValues(); // also resets the watchdog #if ENABLED(HEATER_0_USES_MAX6675) - float ct = current_temperature[0]; - if (ct > min(HEATER_0_MAXTEMP, 1023)) max_temp_error(0); - if (ct < max(HEATER_0_MINTEMP, 0.01)) min_temp_error(0); + if (current_temperature[0] > min(HEATER_0_MAXTEMP, 1023)) max_temp_error(0); + if (current_temperature[0] < max(HEATER_0_MINTEMP, 0.01)) min_temp_error(0); #endif #if (ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0) || (ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0) || DISABLED(PIDTEMPBED) || HAS_AUTO_FAN @@ -1815,8 +1822,8 @@ void Temperature::isr() { #else #define GEBED >= #endif - if (current_temperature_bed_raw GEBED bed_maxttemp_raw) _temp_error(-1, PSTR(MSG_T_MAXTEMP), PSTR(MSG_ERR_MAXTEMP_BED)); - if (bed_minttemp_raw GEBED current_temperature_bed_raw) _temp_error(-1, PSTR(MSG_T_MINTEMP), PSTR(MSG_ERR_MINTEMP_BED)); + if (current_temperature_bed_raw GEBED bed_maxttemp_raw) max_temp_error(-1); + if (bed_minttemp_raw GEBED current_temperature_bed_raw && target_temperature_bed > 0.0f) min_temp_error(-1); #endif } // temp_count >= OVERSAMPLENR diff --git a/Marlin/temperature.h b/Marlin/temperature.h index ffb47a59f..a66014ac4 100644 --- a/Marlin/temperature.h +++ b/Marlin/temperature.h @@ -437,8 +437,8 @@ class Temperature { #endif static void _temp_error(int e, const char* serial_msg, const char* lcd_msg); - static void min_temp_error(uint8_t e); - static void max_temp_error(uint8_t e); + static void min_temp_error(int8_t e); + static void max_temp_error(int8_t e); #if ENABLED(THERMAL_PROTECTION_HOTENDS) || HAS_THERMALLY_PROTECTED_BED