🐛 Redundant Temp Sensor followup (#22173)

This commit is contained in:
Katelyn Schiesser 2021-06-19 11:44:28 -07:00 committed by Scott Lahteine
parent 927a1a1738
commit 4f8191b481
2 changed files with 103 additions and 82 deletions

View File

@ -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

View File

@ -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)