From 4f8191b4818b97bd20eb9db2042dc07c97cce6cc Mon Sep 17 00:00:00 2001 From: Katelyn Schiesser Date: Sat, 19 Jun 2021 11:44:28 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Redundant=20Temp=20Sensor=20foll?= =?UTF-8?q?owup=20(#22173)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Conditionals_post.h | 159 +++++++++++++++-------------- Marlin/src/module/temperature.cpp | 26 +++-- 2 files changed, 103 insertions(+), 82 deletions(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index a5a1070b03..eb215c34eb 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -526,83 +526,90 @@ #undef ANY_TEMP_SENSOR_IS // Usurp a sensor to do redundant readings -#if TEMP_SENSOR_REDUNDANT && !PIN_EXISTS(TEMP_REDUNDANT) - #if TEMP_SENSOR_REDUNDANT_SOURCE == -5 - #if !PIN_EXISTS(TEMP_COOLER) - #error "TEMP_SENSOR_REDUNDANT_SOURCE set to COOLER requires TEMP_COOLER_PIN." - #else - #define TEMP_REDUNDANT_PIN TEMP_COOLER_PIN - #endif - #elif TEMP_SENSOR_REDUNDANT_SOURCE == -4 - #if !PIN_EXISTS(TEMP_PROBE) - #error "TEMP_SENSOR_REDUNDANT_SOURCE set to PROBE requires TEMP_PROBE_PIN." - #else - #define TEMP_REDUNDANT_PIN TEMP_PROBE_PIN - #endif - #elif TEMP_SENSOR_REDUNDANT_SOURCE == -2 - #if !PIN_EXISTS(TEMP_CHAMBER) - #error "TEMP_SENSOR_REDUNDANT_SOURCE set to CHAMBER requires TEMP_CHAMBER_PIN." - #else - #define TEMP_REDUNDANT_PIN TEMP_CHAMBER_PIN - #endif - #elif TEMP_SENSOR_REDUNDANT_SOURCE == -1 - #if !PIN_EXISTS(TEMP_BED) - #error "TEMP_SENSOR_REDUNDANT_SOURCE set to BED requires TEMP_BED_PIN." - #else - #define TEMP_REDUNDANT_PIN TEMP_BED_PIN - #endif - #elif TEMP_SENSOR_REDUNDANT_SOURCE == 0 - #if !PIN_EXISTS(TEMP_0) - #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 0 requires TEMP_0_PIN." - #else - #define TEMP_REDUNDANT_PIN TEMP_0_PIN - #endif - #elif TEMP_SENSOR_REDUNDANT_SOURCE == 1 - #if !PIN_EXISTS(TEMP_1) - #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 1 requires TEMP_1_PIN." - #else - #define TEMP_REDUNDANT_PIN TEMP_1_PIN - #endif - #elif TEMP_SENSOR_REDUNDANT_SOURCE == 2 - #if !PIN_EXISTS(TEMP_2) - #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 2 requires TEMP_2_PIN." - #else - #define TEMP_REDUNDANT_PIN TEMP_2_PIN - #endif - #elif TEMP_SENSOR_REDUNDANT_SOURCE == 3 - #if !PIN_EXISTS(TEMP_3) - #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 3 requires TEMP_3_PIN." - #else - #define TEMP_REDUNDANT_PIN TEMP_3_PIN - #endif - #elif TEMP_SENSOR_REDUNDANT_SOURCE == 4 - #if !PIN_EXISTS(TEMP_4) - #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 4 requires TEMP_4_PIN." - #else - #define TEMP_REDUNDANT_PIN TEMP_4_PIN - #endif - #elif TEMP_SENSOR_REDUNDANT_SOURCE == 5 - #if !PIN_EXISTS(TEMP_5) - #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 5 requires TEMP_5_PIN." - #else - #define TEMP_REDUNDANT_PIN TEMP_5_PIN - #endif - #elif TEMP_SENSOR_REDUNDANT_SOURCE == 6 - #if !PIN_EXISTS(TEMP_6) - #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 6 requires TEMP_6_PIN." - #else - #define TEMP_REDUNDANT_PIN TEMP_6_PIN - #endif - #elif TEMP_SENSOR_REDUNDANT_SOURCE == 7 - #if !PIN_EXISTS(TEMP_7) - #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 7 requires TEMP_7_PIN." - #else - #define TEMP_REDUNDANT_PIN TEMP_7_PIN - #endif +#if TEMP_SENSOR_REDUNDANT + #ifndef TEMP_SENSOR_REDUNDANT_SOURCE + #define TEMP_SENSOR_REDUNDANT_SOURCE 1 #endif - - #ifndef TEMP_SENSOR_REDUNDANT_MAX_DIFF - #define TEMP_SENSOR_REDUNDANT_MAX_DIFF 10 + #ifndef TEMP_SENSOR_REDUNDANT_TARGET + #define TEMP_SENSOR_REDUNDANT_TARGET 0 + #endif + #if !PIN_EXISTS(TEMP_REDUNDANT) + #ifndef TEMP_SENSOR_REDUNDANT_MAX_DIFF + #define TEMP_SENSOR_REDUNDANT_MAX_DIFF 10 + #endif + #if TEMP_SENSOR_REDUNDANT_SOURCE == -5 + #if !PIN_EXISTS(TEMP_COOLER) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to COOLER requires TEMP_COOLER_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_COOLER_PIN + #endif + #elif TEMP_SENSOR_REDUNDANT_SOURCE == -4 + #if !PIN_EXISTS(TEMP_PROBE) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to PROBE requires TEMP_PROBE_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_PROBE_PIN + #endif + #elif TEMP_SENSOR_REDUNDANT_SOURCE == -2 + #if !PIN_EXISTS(TEMP_CHAMBER) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to CHAMBER requires TEMP_CHAMBER_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_CHAMBER_PIN + #endif + #elif TEMP_SENSOR_REDUNDANT_SOURCE == -1 + #if !PIN_EXISTS(TEMP_BED) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to BED requires TEMP_BED_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_BED_PIN + #endif + #elif TEMP_SENSOR_REDUNDANT_SOURCE == 0 + #if !PIN_EXISTS(TEMP_0) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 0 requires TEMP_0_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_0_PIN + #endif + #elif TEMP_SENSOR_REDUNDANT_SOURCE == 1 + #if !PIN_EXISTS(TEMP_1) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 1 requires TEMP_1_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_1_PIN + #endif + #elif TEMP_SENSOR_REDUNDANT_SOURCE == 2 + #if !PIN_EXISTS(TEMP_2) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 2 requires TEMP_2_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_2_PIN + #endif + #elif TEMP_SENSOR_REDUNDANT_SOURCE == 3 + #if !PIN_EXISTS(TEMP_3) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 3 requires TEMP_3_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_3_PIN + #endif + #elif TEMP_SENSOR_REDUNDANT_SOURCE == 4 + #if !PIN_EXISTS(TEMP_4) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 4 requires TEMP_4_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_4_PIN + #endif + #elif TEMP_SENSOR_REDUNDANT_SOURCE == 5 + #if !PIN_EXISTS(TEMP_5) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 5 requires TEMP_5_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_5_PIN + #endif + #elif TEMP_SENSOR_REDUNDANT_SOURCE == 6 + #if !PIN_EXISTS(TEMP_6) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 6 requires TEMP_6_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_6_PIN + #endif + #elif TEMP_SENSOR_REDUNDANT_SOURCE == 7 + #if !PIN_EXISTS(TEMP_7) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 7 requires TEMP_7_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_7_PIN + #endif + #endif #endif #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 9274d0631e..9f32ce933b 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2090,16 +2090,30 @@ void Temperature::init() { #endif #if HAS_MAX31865_TEMP - TERN_(TEMP_SENSOR_IS_MAX(0, MAX31865), max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE - TERN_(TEMP_SENSOR_IS_MAX(1, MAX31865), max31865_1.begin(MAX31865_2WIRE)); + #if TEMP_SENSOR_IS_MAX(0, MAX31865) + max31865_0.begin(MAX31865_2WIRE); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE + #endif + #if TEMP_SENSOR_IS_MAX(1, MAX31865) + max31865_1.begin(MAX31865_2WIRE); + #endif #endif + #if HAS_MAX31855_TEMP - TERN_(TEMP_SENSOR_IS_MAX(0, MAX31855), max31855_0.begin()); - TERN_(TEMP_SENSOR_IS_MAX(1, MAX31855), max31855_1.begin()); + #if TEMP_SENSOR_IS_MAX(0, MAX31855) + max31855_0.begin(MAX31855); + #endif + #if TEMP_SENSOR_IS_MAX(1, MAX31855) + max31855_1.begin(MAX31855); + #endif #endif + #if HAS_MAX6675_TEMP - TERN_(TEMP_SENSOR_IS_MAX(0, MAX6675), max6675_0.begin()); - TERN_(TEMP_SENSOR_IS_MAX(1, MAX6675), max6675_1.begin()); + #if TEMP_SENSOR_IS_MAX(0, MAX6675) + max6675_0.begin(MAX6675); + #endif + #if TEMP_SENSOR_IS_MAX(1, MAX6675) + max6675_1.begin(MAX6675); + #endif #endif #if MB(RUMBA)