From 3e8f9ecd1c5845f40a9c7ccc16bea92e70cc1c11 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 8 Aug 2016 22:21:01 -0700 Subject: [PATCH 1/3] Extend min/max_temp_error for the bed --- Marlin/temperature.cpp | 24 ++++++++++++++++-------- Marlin/temperature.h | 4 ++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 13a70bb85..cf78ad1aa 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) { 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 From d3ba878f703dd3e97186c6ebd1bb73bda50d404c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 8 Aug 2016 22:21:32 -0700 Subject: [PATCH 2/3] Drop intermediate float in HEATER_0_USES_MAX6675 test --- Marlin/temperature.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index cf78ad1aa..159a732b3 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -683,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 From b7b5b50a84714780857c1dc3c85a7e7bcfc9732c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 8 Aug 2016 22:22:18 -0700 Subject: [PATCH 3/3] Throw bed min temp error only if heating --- Marlin/temperature.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 159a732b3..3bcfe3928 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -1822,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