From b0eae68f57d25e27405ebc9db84c617d440b3db8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 28 May 2017 11:11:17 -0500 Subject: [PATCH] Prevent bed temperature being set too high --- Marlin/temperature.cpp | 7 +++++-- Marlin/temperature.h | 25 ++++++++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 3cac779d3..376740b9f 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -67,8 +67,11 @@ float Temperature::current_temperature[HOTENDS] = { 0.0 }, Temperature::current_temperature_bed = 0.0; int16_t Temperature::current_temperature_raw[HOTENDS] = { 0 }, Temperature::target_temperature[HOTENDS] = { 0 }, - Temperature::current_temperature_bed_raw = 0, - Temperature::target_temperature_bed = 0; + Temperature::current_temperature_bed_raw = 0; + +#if HAS_HEATER_BED + int16_t Temperature::target_temperature_bed = 0; +#endif #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) float Temperature::redundant_temperature = 0.0; diff --git a/Marlin/temperature.h b/Marlin/temperature.h index 0e911a70c..c75349681 100644 --- a/Marlin/temperature.h +++ b/Marlin/temperature.h @@ -92,6 +92,10 @@ enum ADCSensorState { #define ACTUAL_ADC_SAMPLES max(int(MIN_ADC_ISR_LOOPS), int(SensorsReady)) +#if !HAS_HEATER_BED + constexpr int16_t target_temperature_bed = 0; +#endif + class Temperature { public: @@ -100,8 +104,11 @@ class Temperature { current_temperature_bed; static int16_t current_temperature_raw[HOTENDS], target_temperature[HOTENDS], - current_temperature_bed_raw, - target_temperature_bed; + current_temperature_bed_raw; + + #if HAS_HEATER_BED + static int16_t target_temperature_bed; + #endif static volatile bool in_temp_isr; @@ -382,9 +389,17 @@ class Temperature { } static void setTargetBed(const int16_t celsius) { - target_temperature_bed = celsius; - #if WATCH_THE_BED - start_watching_bed(); + #if HAS_HEATER_BED + target_temperature_bed = + #ifdef BED_MAXTEMP + min(celsius, BED_MAXTEMP) + #else + celsius + #endif + ; + #if WATCH_THE_BED + start_watching_bed(); + #endif #endif }