From 699310d1d20aa638b0a819051ab6cc101d2d82e8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 2 Apr 2017 11:48:10 -0500 Subject: [PATCH] Fix: Thermal runaway if nonexistent bed's temp is set --- Marlin/Conditionals_post.h | 3 +++ Marlin/temperature.cpp | 14 +++++++------- Marlin/temperature.h | 12 ++++++------ Marlin/ultralcd.cpp | 16 +++++----------- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/Marlin/Conditionals_post.h b/Marlin/Conditionals_post.h index b189af507..ca3678996 100644 --- a/Marlin/Conditionals_post.h +++ b/Marlin/Conditionals_post.h @@ -522,6 +522,9 @@ #define HAS_THERMALLY_PROTECTED_BED (HAS_TEMP_BED && HAS_HEATER_BED && ENABLED(THERMAL_PROTECTION_BED)) + #define WATCH_HOTENDS (ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0) + #define WATCH_THE_BED (HAS_THERMALLY_PROTECTED_BED && WATCH_BED_TEMP_PERIOD > 0) + /** * This setting is also used by M109 when trying to calculate * a ballpark safe margin to prevent wait-forever situation. diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index f3bfc7fa7..5a37c7750 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -104,12 +104,12 @@ uint8_t Temperature::soft_pwm_bed; volatile int Temperature::babystepsTodo[XYZ] = { 0 }; #endif -#if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0 +#if WATCH_HOTENDS int Temperature::watch_target_temp[HOTENDS] = { 0 }; millis_t Temperature::watch_heater_next_ms[HOTENDS] = { 0 }; #endif -#if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0 +#if WATCH_THE_BED int Temperature::watch_target_bed_temp = 0; millis_t Temperature::watch_bed_next_ms = 0; #endif @@ -690,7 +690,7 @@ void Temperature::manage_heater() { if (current_temperature[0] < max(HEATER_0_MINTEMP, MAX6675_TMIN + 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 + #if WATCH_HOTENDS || WATCH_THE_BED || DISABLED(PIDTEMPBED) || HAS_AUTO_FAN millis_t ms = millis(); #endif @@ -707,7 +707,7 @@ void Temperature::manage_heater() { soft_pwm[e] = (current_temperature[e] > minttemp[e] || is_preheating(e)) && current_temperature[e] < maxttemp[e] ? (int)pid_output >> 1 : 0; // Check if the temperature is failing to increase - #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0 + #if WATCH_HOTENDS // Is it time to check this extruder's heater? if (watch_heater_next_ms[e] && ELAPSED(ms, watch_heater_next_ms[e])) { @@ -725,7 +725,7 @@ void Temperature::manage_heater() { #endif // THERMAL_PROTECTION_HOTENDS // Check if the temperature is failing to increase - #if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0 + #if WATCH_THE_BED // Is it time to check the bed? if (watch_bed_next_ms && ELAPSED(ms, watch_bed_next_ms)) { @@ -1157,7 +1157,7 @@ void Temperature::init() { #endif //BED_MAXTEMP } -#if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0 +#if WATCH_HOTENDS /** * Start Heating Sanity Check for hotends that are below * their target temperature by a configurable margin. @@ -1176,7 +1176,7 @@ void Temperature::init() { } #endif -#if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0 +#if WATCH_THE_BED /** * Start Heating Sanity Check for hotends that are below * their target temperature by a configurable margin. diff --git a/Marlin/temperature.h b/Marlin/temperature.h index d6451554f..09cf44bd2 100644 --- a/Marlin/temperature.h +++ b/Marlin/temperature.h @@ -113,12 +113,12 @@ class Temperature { static volatile int babystepsTodo[3]; #endif - #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0 + #if WATCH_HOTENDS static int watch_target_temp[HOTENDS]; static millis_t watch_heater_next_ms[HOTENDS]; #endif - #if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0 + #if WATCH_THE_BED static int watch_target_bed_temp; static millis_t watch_bed_next_ms; #endif @@ -306,11 +306,11 @@ class Temperature { } static float degTargetBed() { return target_temperature_bed; } - #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0 + #if WATCH_HOTENDS static void start_watching_heater(uint8_t e = 0); #endif - #if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0 + #if WATCH_THE_BED static void start_watching_bed(); #endif @@ -325,14 +325,14 @@ class Temperature { start_preheat_time(HOTEND_INDEX); #endif target_temperature[HOTEND_INDEX] = celsius; - #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0 + #if WATCH_HOTENDS start_watching_heater(HOTEND_INDEX); #endif } static void setTargetBed(const float& celsius) { target_temperature_bed = celsius; - #if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0 + #if WATCH_THE_BED start_watching_bed(); #endif } diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 1065d6aa9..3988facf2 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -918,7 +918,7 @@ void kill_screen(const char* lcd_msg) { /** * Watch temperature callbacks */ - #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0 + #if WATCH_HOTENDS #if TEMP_SENSOR_0 != 0 void watch_temp_callback_E0() { thermalManager.start_watching_heater(0); } #endif @@ -946,14 +946,8 @@ void kill_screen(const char* lcd_msg) { #endif // HOTENDS > 3 #endif - #if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0 - #if TEMP_SENSOR_BED != 0 - void watch_temp_callback_bed() { thermalManager.start_watching_bed(); } - #endif - #else - #if TEMP_SENSOR_BED != 0 - void watch_temp_callback_bed() {} - #endif + #if WATCH_THE_BED + void watch_temp_callback_bed() { thermalManager.start_watching_bed(); } #endif #if ENABLED(FILAMENT_CHANGE_FEATURE) @@ -1021,7 +1015,7 @@ void kill_screen(const char* lcd_msg) { // // Bed: // - #if TEMP_SENSOR_BED != 0 + #if WATCH_THE_BED MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_BED, &thermalManager.target_temperature_bed, 0, BED_MAXTEMP - 15, watch_temp_callback_bed); #endif @@ -2180,7 +2174,7 @@ void kill_screen(const char* lcd_msg) { // // Bed: // - #if TEMP_SENSOR_BED != 0 + #if WATCH_THE_BED MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_BED, &thermalManager.target_temperature_bed, 0, BED_MAXTEMP - 15, watch_temp_callback_bed); #endif