Fix TEMP_0_TR_ENABLE, rename temp conditions (#21016)

This commit is contained in:
Scott Lahteine 2021-02-07 16:58:06 -06:00
parent 80c1be919f
commit 47b872f5d0
9 changed files with 525 additions and 493 deletions

View file

@ -113,6 +113,12 @@
#define CHAMBER_BETA 3950 // Beta value
#endif
#if TEMP_SENSOR_PROBE == 1000
#define PROBE_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
#define PROBE_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
#define PROBE_BETA 3950 // Beta value
#endif
//
// Hephestos 2 24V heated bed upgrade kit.
// https://store.bq.com/en/heated-bed-kit-hephestos2
@ -331,7 +337,7 @@
* High Temperature Thermistor Support
*
* Thermistors able to support high temperature tend to have a hard time getting
* good readings at room and lower temperatures. This means HEATER_X_RAW_LO_TEMP
* good readings at room and lower temperatures. This means TEMP_SENSOR_X_RAW_LO_TEMP
* will probably be caught when the heating element first turns on during the
* preheating process, which will trigger a min_temp_error as a safety measure
* and force stop everything.

View file

@ -938,10 +938,10 @@ void setup() {
SETUP_RUN(HAL_init());
// Init and disable SPI thermocouples
#if HEATER_0_USES_MAX6675
#if TEMP_SENSOR_0_IS_MAX6675
OUT_WRITE(MAX6675_SS_PIN, HIGH); // Disable
#endif
#if HEATER_1_USES_MAX6675
#if TEMP_SENSOR_1_IS_MAX6675
OUT_WRITE(MAX6675_SS2_PIN, HIGH); // Disable
#endif

View file

@ -404,30 +404,33 @@
#endif
#if TEMP_SENSOR_0 == -5 || TEMP_SENSOR_0 == -3 || TEMP_SENSOR_0 == -2
#define HEATER_0_USES_MAX6675 1
#define TEMP_SENSOR_0_IS_MAX_TC 1
#define HAS_MAX_TC 1
#if TEMP_SENSOR_0 == -3
#define HEATER_0_MAX6675_TMIN -270
#define HEATER_0_MAX6675_TMAX 1800
#define TEMP_SENSOR_0_MAX_TC_TMIN -270
#define TEMP_SENSOR_0_MAX_TC_TMAX 1800
#else
#define HEATER_0_MAX6675_TMIN 0
#define HEATER_0_MAX6675_TMAX 1024
#define TEMP_SENSOR_0_MAX_TC_TMIN 0
#define TEMP_SENSOR_0_MAX_TC_TMAX 1024
#endif
#if TEMP_SENSOR_0 == -5
#define MAX6675_0_IS_MAX31865 1
#define TEMP_SENSOR_0_IS_MAX31865 1
#elif TEMP_SENSOR_0 == -3
#define MAX6675_0_IS_MAX31855 1
#define TEMP_SENSOR_0_IS_MAX31855 1
#elif TEMP_SENSOR_0 == -2
#define TEMP_SENSOR_0_IS_MAX6675 1
#endif
#elif TEMP_SENSOR_0 == -4
#define HEATER_0_USES_AD8495 1
#define TEMP_SENSOR_0_IS_AD8495 1
#elif TEMP_SENSOR_0 == -1
#define HEATER_0_USES_AD595 1
#define TEMP_SENSOR_0_IS_AD595 1
#elif TEMP_SENSOR_0 > 0
#define THERMISTOR_HEATER_0 TEMP_SENSOR_0
#define HEATER_0_USES_THERMISTOR 1
#define TEMP_SENSOR_0_THERMISTOR_ID TEMP_SENSOR_0
#define TEMP_SENSOR_0_IS_THERMISTOR 1
#if TEMP_SENSOR_0 == 1000
#define HEATER_0_USER_THERMISTOR 1
#define TEMP_SENSOR_0_IS_CUSTOM 1
#elif TEMP_SENSOR_0 == 998 || TEMP_SENSOR_0 == 999
#define HEATER_0_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_0_IS_DUMMY 1
#endif
#else
#undef HEATER_0_MINTEMP
@ -435,18 +438,21 @@
#endif
#if TEMP_SENSOR_1 == -5 || TEMP_SENSOR_1 == -3 || TEMP_SENSOR_1 == -2
#define HEATER_1_USES_MAX6675 1
#define TEMP_SENSOR_1_IS_MAX_TC 1
#define HAS_MAX_TC 1
#if TEMP_SENSOR_1 == -3
#define HEATER_1_MAX6675_TMIN -270
#define HEATER_1_MAX6675_TMAX 1800
#define TEMP_SENSOR_1_MAX_TC_TMIN -270
#define TEMP_SENSOR_1_MAX_TC_TMAX 1800
#else
#define HEATER_1_MAX6675_TMIN 0
#define HEATER_1_MAX6675_TMAX 1024
#define TEMP_SENSOR_1_MAX_TC_TMIN 0
#define TEMP_SENSOR_1_MAX_TC_TMAX 1024
#endif
#if TEMP_SENSOR_1 == -5
#define MAX6675_1_IS_MAX31865 1
#define TEMP_SENSOR_1_IS_MAX31865 1
#elif TEMP_SENSOR_1 == -3
#define MAX6675_1_IS_MAX31855 1
#define TEMP_SENSOR_1_IS_MAX31855 1
#elif TEMP_SENSOR_1 == -2
#define TEMP_SENSOR_1_IS_MAX6675 1
#endif
#if TEMP_SENSOR_1 != TEMP_SENSOR_0
#if TEMP_SENSOR_1 == -5
@ -458,37 +464,47 @@
#endif
#endif
#elif TEMP_SENSOR_1 == -4
#define HEATER_1_USES_AD8495 1
#define TEMP_SENSOR_1_IS_AD8495 1
#elif TEMP_SENSOR_1 == -1
#define HEATER_1_USES_AD595 1
#define TEMP_SENSOR_1_IS_AD595 1
#elif TEMP_SENSOR_1 > 0
#define THERMISTOR_HEATER_1 TEMP_SENSOR_1
#define HEATER_1_USES_THERMISTOR 1
#define TEMP_SENSOR_1_THERMISTOR_ID TEMP_SENSOR_1
#define TEMP_SENSOR_1_IS_THERMISTOR 1
#if TEMP_SENSOR_1 == 1000
#define HEATER_1_USER_THERMISTOR 1
#define TEMP_SENSOR_1_IS_CUSTOM 1
#elif TEMP_SENSOR_1 == 998 || TEMP_SENSOR_1 == 999
#define HEATER_1_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_1_IS_DUMMY 1
#endif
#else
#undef HEATER_1_MINTEMP
#undef HEATER_1_MAXTEMP
#endif
#if TEMP_SENSOR_0_IS_MAX31855 || TEMP_SENSOR_1_IS_MAX31855
#define HAS_MAX31855 1
#endif
#if TEMP_SENSOR_0_IS_MAX31865 || TEMP_SENSOR_1_IS_MAX31865
#define HAS_MAX31865 1
#endif
#if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675
#define HAS_MAX6675 1
#endif
#if TEMP_SENSOR_2 == -4
#define HEATER_2_USES_AD8495 1
#define TEMP_SENSOR_2_IS_AD8495 1
#elif TEMP_SENSOR_2 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_2."
#elif TEMP_SENSOR_2 == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_2."
#elif TEMP_SENSOR_2 == -1
#define HEATER_2_USES_AD595 1
#define TEMP_SENSOR_2_IS_AD595 1
#elif TEMP_SENSOR_2 > 0
#define THERMISTOR_HEATER_2 TEMP_SENSOR_2
#define HEATER_2_USES_THERMISTOR 1
#define TEMP_SENSOR_2_THERMISTOR_ID TEMP_SENSOR_2
#define TEMP_SENSOR_2_IS_THERMISTOR 1
#if TEMP_SENSOR_2 == 1000
#define HEATER_2_USER_THERMISTOR 1
#define TEMP_SENSOR_2_IS_CUSTOM 1
#elif TEMP_SENSOR_2 == 998 || TEMP_SENSOR_2 == 999
#define HEATER_2_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_2_IS_DUMMY 1
#endif
#else
#undef HEATER_2_MINTEMP
@ -496,20 +512,20 @@
#endif
#if TEMP_SENSOR_3 == -4
#define HEATER_3_USES_AD8495 1
#define TEMP_SENSOR_3_IS_AD8495 1
#elif TEMP_SENSOR_3 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_3."
#elif TEMP_SENSOR_3 == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_3."
#elif TEMP_SENSOR_3 == -1
#define HEATER_3_USES_AD595 1
#define TEMP_SENSOR_3_IS_AD595 1
#elif TEMP_SENSOR_3 > 0
#define THERMISTOR_HEATER_3 TEMP_SENSOR_3
#define HEATER_3_USES_THERMISTOR 1
#define TEMP_SENSOR_3_THERMISTOR_ID TEMP_SENSOR_3
#define TEMP_SENSOR_3_IS_THERMISTOR 1
#if TEMP_SENSOR_3 == 1000
#define HEATER_3_USER_THERMISTOR 1
#define TEMP_SENSOR_3_IS_CUSTOM 1
#elif TEMP_SENSOR_3 == 998 || TEMP_SENSOR_3 == 999
#define HEATER_3_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_3_IS_DUMMY 1
#endif
#else
#undef HEATER_3_MINTEMP
@ -517,20 +533,20 @@
#endif
#if TEMP_SENSOR_4 == -4
#define HEATER_4_USES_AD8495 1
#define TEMP_SENSOR_4_IS_AD8495 1
#elif TEMP_SENSOR_4 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_4."
#elif TEMP_SENSOR_4 == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_4."
#elif TEMP_SENSOR_4 == -1
#define HEATER_4_USES_AD595 1
#define TEMP_SENSOR_4_IS_AD595 1
#elif TEMP_SENSOR_4 > 0
#define THERMISTOR_HEATER_4 TEMP_SENSOR_4
#define HEATER_4_USES_THERMISTOR 1
#define TEMP_SENSOR_4_THERMISTOR_ID TEMP_SENSOR_4
#define TEMP_SENSOR_4_IS_THERMISTOR 1
#if TEMP_SENSOR_4 == 1000
#define HEATER_4_USER_THERMISTOR 1
#define TEMP_SENSOR_4_IS_CUSTOM 1
#elif TEMP_SENSOR_4 == 998 || TEMP_SENSOR_4 == 999
#define HEATER_4_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_4_IS_DUMMY 1
#endif
#else
#undef HEATER_4_MINTEMP
@ -538,20 +554,20 @@
#endif
#if TEMP_SENSOR_5 == -4
#define HEATER_5_USES_AD8495 1
#define TEMP_SENSOR_5_IS_AD8495 1
#elif TEMP_SENSOR_5 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_5."
#elif TEMP_SENSOR_5 == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_5."
#elif TEMP_SENSOR_5 == -1
#define HEATER_5_USES_AD595 1
#define TEMP_SENSOR_5_IS_AD595 1
#elif TEMP_SENSOR_5 > 0
#define THERMISTOR_HEATER_5 TEMP_SENSOR_5
#define HEATER_5_USES_THERMISTOR 1
#define TEMP_SENSOR_5_THERMISTOR_ID TEMP_SENSOR_5
#define TEMP_SENSOR_5_IS_THERMISTOR 1
#if TEMP_SENSOR_5 == 1000
#define HEATER_5_USER_THERMISTOR 1
#define TEMP_SENSOR_5_IS_CUSTOM 1
#elif TEMP_SENSOR_5 == 998 || TEMP_SENSOR_5 == 999
#define HEATER_5_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_5_IS_DUMMY 1
#endif
#else
#undef HEATER_5_MINTEMP
@ -559,20 +575,20 @@
#endif
#if TEMP_SENSOR_6 == -4
#define HEATER_6_USES_AD8495 1
#define TEMP_SENSOR_6_IS_AD8495 1
#elif TEMP_SENSOR_6 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_6."
#elif TEMP_SENSOR_6 == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_6."
#elif TEMP_SENSOR_6 == -1
#define HEATER_6_USES_AD595 1
#define TEMP_SENSOR_6_IS_AD595 1
#elif TEMP_SENSOR_6 > 0
#define THERMISTOR_HEATER_6 TEMP_SENSOR_6
#define HEATER_6_USES_THERMISTOR 1
#define TEMP_SENSOR_6_THERMISTOR_ID TEMP_SENSOR_6
#define TEMP_SENSOR_6_IS_THERMISTOR 1
#if TEMP_SENSOR_6 == 1000
#define HEATER_6_USER_THERMISTOR 1
#define TEMP_SENSOR_6_IS_CUSTOM 1
#elif TEMP_SENSOR_6 == 998 || TEMP_SENSOR_6 == 999
#define HEATER_6_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_6_IS_DUMMY 1
#endif
#else
#undef HEATER_6_MINTEMP
@ -580,20 +596,20 @@
#endif
#if TEMP_SENSOR_7 == -4
#define HEATER_7_USES_AD8495 1
#define TEMP_SENSOR_7_IS_AD8495 1
#elif TEMP_SENSOR_7 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_7."
#elif TEMP_SENSOR_7 == -2
#error "MAX7775 Thermocouples (-2) not supported for TEMP_SENSOR_7."
#elif TEMP_SENSOR_7 == -1
#define HEATER_7_USES_AD595 1
#define TEMP_SENSOR_7_IS_AD595 1
#elif TEMP_SENSOR_7 > 0
#define THERMISTOR_HEATER_7 TEMP_SENSOR_7
#define HEATER_7_USES_THERMISTOR 1
#define TEMP_SENSOR_7_THERMISTOR_ID TEMP_SENSOR_7
#define TEMP_SENSOR_7_IS_THERMISTOR 1
#if TEMP_SENSOR_7 == 1000
#define HEATER_7_USER_THERMISTOR 1
#define TEMP_SENSOR_7_IS_CUSTOM 1
#elif TEMP_SENSOR_7 == 998 || TEMP_SENSOR_7 == 999
#define HEATER_7_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_7_IS_DUMMY 1
#endif
#else
#undef HEATER_7_MINTEMP
@ -601,20 +617,20 @@
#endif
#if TEMP_SENSOR_BED == -4
#define HEATER_BED_USES_AD8495 1
#define TEMP_SENSOR_BED_IS_AD8495 1
#elif TEMP_SENSOR_BED == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_BED."
#elif TEMP_SENSOR_BED == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_BED."
#elif TEMP_SENSOR_BED == -1
#define HEATER_BED_USES_AD595 1
#define TEMP_SENSOR_BED_IS_AD595 1
#elif TEMP_SENSOR_BED > 0
#define THERMISTORBED TEMP_SENSOR_BED
#define HEATER_BED_USES_THERMISTOR 1
#define TEMP_SENSOR_BED_THERMISTOR_ID TEMP_SENSOR_BED
#define TEMP_SENSOR_BED_IS_THERMISTOR 1
#if TEMP_SENSOR_BED == 1000
#define HEATER_BED_USER_THERMISTOR 1
#define TEMP_SENSOR_BED_IS_CUSTOM 1
#elif TEMP_SENSOR_BED == 998 || TEMP_SENSOR_BED == 999
#define HEATER_BED_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_BED_IS_DUMMY 1
#endif
#else
#undef BED_MINTEMP
@ -622,20 +638,20 @@
#endif
#if TEMP_SENSOR_CHAMBER == -4
#define HEATER_CHAMBER_USES_AD8495 1
#define TEMP_SENSOR_CHAMBER_IS_AD8495 1
#elif TEMP_SENSOR_CHAMBER == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_CHAMBER."
#elif TEMP_SENSOR_CHAMBER == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_CHAMBER."
#elif TEMP_SENSOR_CHAMBER == -1
#define HEATER_CHAMBER_USES_AD595 1
#define TEMP_SENSOR_CHAMBER_IS_AD595 1
#elif TEMP_SENSOR_CHAMBER > 0
#define THERMISTORCHAMBER TEMP_SENSOR_CHAMBER
#define HEATER_CHAMBER_USES_THERMISTOR 1
#define TEMP_SENSOR_CHAMBER_THERMISTOR_ID TEMP_SENSOR_CHAMBER
#define TEMP_SENSOR_CHAMBER_IS_THERMISTOR 1
#if TEMP_SENSOR_CHAMBER == 1000
#define HEATER_CHAMBER_USER_THERMISTOR 1
#define TEMP_SENSOR_CHAMBER_IS_CUSTOM 1
#elif TEMP_SENSOR_CHAMBER == 998 || TEMP_SENSOR_CHAMBER == 999
#define HEATER_CHAMBER_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_CHAMBER_IS_DUMMY 1
#endif
#else
#undef CHAMBER_MINTEMP
@ -643,20 +659,20 @@
#endif
#if TEMP_SENSOR_PROBE == -4
#define HEATER_PROBE_USES_AD8495 1
#define TEMP_SENSOR_PROBE_IS_AD8495 1
#elif TEMP_SENSOR_PROBE == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_PROBE."
#elif TEMP_SENSOR_PROBE == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_PROBE."
#elif TEMP_SENSOR_PROBE == -1
#define HEATER_PROBE_USES_AD595 1
#define TEMP_SENSOR_PROBE_IS_AD595 1
#elif TEMP_SENSOR_PROBE > 0
#define THERMISTORPROBE TEMP_SENSOR_PROBE
#define HEATER_PROBE_USES_THERMISTOR 1
#define TEMP_SENSOR_PROBE_THERMISTOR_ID TEMP_SENSOR_PROBE
#define TEMP_SENSOR_PROBE_IS_THERMISTOR 1
#if TEMP_SENSOR_PROBE == 1000
#define HEATER_PROBE_USER_THERMISTOR 1
#define TEMP_SENSOR_PROBE_IS_CUSTOM 1
#elif TEMP_SENSOR_PROBE == 998 || TEMP_SENSOR_PROBE == 999
#define HEATER_PROBE_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_PROBE_IS_DUMMY 1
#endif
#endif
@ -1792,7 +1808,7 @@
//
// ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface)
//
#define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && NONE(HEATER_##P##_USES_MAX6675, HEATER_##P##_DUMMY_THERMISTOR))
#define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && NONE(TEMP_SENSOR_##P##_IS_MAX_TC, TEMP_SENSOR_##P##_IS_DUMMY))
#if HAS_ADC_TEST(0)
#define HAS_TEMP_ADC_0 1
#endif
@ -1827,7 +1843,7 @@
#define HAS_TEMP_ADC_CHAMBER 1
#endif
#define HAS_TEMP(N) ANY(HAS_TEMP_ADC_##N, HEATER_##N##_USES_MAX6675, HEATER_##N##_DUMMY_THERMISTOR)
#define HAS_TEMP(N) ANY(HAS_TEMP_ADC_##N, TEMP_SENSOR_##N##_IS_MAX_TC, TEMP_SENSOR_##N##_IS_DUMMY)
#if HAS_HOTEND && HAS_TEMP(0)
#define HAS_TEMP_HOTEND 1
#endif

View file

@ -1698,46 +1698,48 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
/**
* Required custom thermistor settings
*/
#if HEATER_0_USER_THERMISTOR && !(defined(HOTEND0_PULLUP_RESISTOR_OHMS) && defined(HOTEND0_RESISTANCE_25C_OHMS) && defined(HOTEND0_BETA))
#if TEMP_SENSOR_0_IS_CUSTOM && !(defined(HOTEND0_PULLUP_RESISTOR_OHMS) && defined(HOTEND0_RESISTANCE_25C_OHMS) && defined(HOTEND0_BETA))
#error "TEMP_SENSOR_0 1000 requires HOTEND0_PULLUP_RESISTOR_OHMS, HOTEND0_RESISTANCE_25C_OHMS and HOTEND0_BETA in Configuration_adv.h."
#elif HEATER_1_USER_THERMISTOR && !(defined(HOTEND1_PULLUP_RESISTOR_OHMS) && defined(HOTEND1_RESISTANCE_25C_OHMS) && defined(HOTEND1_BETA))
#elif TEMP_SENSOR_1_IS_CUSTOM && !(defined(HOTEND1_PULLUP_RESISTOR_OHMS) && defined(HOTEND1_RESISTANCE_25C_OHMS) && defined(HOTEND1_BETA))
#error "TEMP_SENSOR_1 1000 requires HOTEND1_PULLUP_RESISTOR_OHMS, HOTEND1_RESISTANCE_25C_OHMS and HOTEND1_BETA in Configuration_adv.h."
#elif HEATER_2_USER_THERMISTOR && !(defined(HOTEND2_PULLUP_RESISTOR_OHMS) && defined(HOTEND2_RESISTANCE_25C_OHMS) && defined(HOTEND2_BETA))
#elif TEMP_SENSOR_2_IS_CUSTOM && !(defined(HOTEND2_PULLUP_RESISTOR_OHMS) && defined(HOTEND2_RESISTANCE_25C_OHMS) && defined(HOTEND2_BETA))
#error "TEMP_SENSOR_2 1000 requires HOTEND2_PULLUP_RESISTOR_OHMS, HOTEND2_RESISTANCE_25C_OHMS and HOTEND2_BETA in Configuration_adv.h."
#elif HEATER_3_USER_THERMISTOR && !(defined(HOTEND3_PULLUP_RESISTOR_OHMS) && defined(HOTEND3_RESISTANCE_25C_OHMS) && defined(HOTEND3_BETA))
#elif TEMP_SENSOR_3_IS_CUSTOM && !(defined(HOTEND3_PULLUP_RESISTOR_OHMS) && defined(HOTEND3_RESISTANCE_25C_OHMS) && defined(HOTEND3_BETA))
#error "TEMP_SENSOR_3 1000 requires HOTEND3_PULLUP_RESISTOR_OHMS, HOTEND3_RESISTANCE_25C_OHMS and HOTEND3_BETA in Configuration_adv.h."
#elif HEATER_4_USER_THERMISTOR && !(defined(HOTEND4_PULLUP_RESISTOR_OHMS) && defined(HOTEND4_RESISTANCE_25C_OHMS) && defined(HOTEND4_BETA))
#elif TEMP_SENSOR_4_IS_CUSTOM && !(defined(HOTEND4_PULLUP_RESISTOR_OHMS) && defined(HOTEND4_RESISTANCE_25C_OHMS) && defined(HOTEND4_BETA))
#error "TEMP_SENSOR_4 1000 requires HOTEND4_PULLUP_RESISTOR_OHMS, HOTEND4_RESISTANCE_25C_OHMS and HOTEND4_BETA in Configuration_adv.h."
#elif HEATER_5_USER_THERMISTOR && !(defined(HOTEND5_PULLUP_RESISTOR_OHMS) && defined(HOTEND5_RESISTANCE_25C_OHMS) && defined(HOTEND5_BETA))
#elif TEMP_SENSOR_5_IS_CUSTOM && !(defined(HOTEND5_PULLUP_RESISTOR_OHMS) && defined(HOTEND5_RESISTANCE_25C_OHMS) && defined(HOTEND5_BETA))
#error "TEMP_SENSOR_5 1000 requires HOTEND5_PULLUP_RESISTOR_OHMS, HOTEND5_RESISTANCE_25C_OHMS and HOTEND5_BETA in Configuration_adv.h."
#elif HEATER_6_USER_THERMISTOR && !(defined(HOTEND6_PULLUP_RESISTOR_OHMS) && defined(HOTEND6_RESISTANCE_25C_OHMS) && defined(HOTEND6_BETA))
#elif TEMP_SENSOR_6_IS_CUSTOM && !(defined(HOTEND6_PULLUP_RESISTOR_OHMS) && defined(HOTEND6_RESISTANCE_25C_OHMS) && defined(HOTEND6_BETA))
#error "TEMP_SENSOR_6 1000 requires HOTEND6_PULLUP_RESISTOR_OHMS, HOTEND6_RESISTANCE_25C_OHMS and HOTEND6_BETA in Configuration_adv.h."
#elif HEATER_7_USER_THERMISTOR && !(defined(HOTEND7_PULLUP_RESISTOR_OHMS) && defined(HOTEND7_RESISTANCE_25C_OHMS) && defined(HOTEND7_BETA))
#elif TEMP_SENSOR_7_IS_CUSTOM && !(defined(HOTEND7_PULLUP_RESISTOR_OHMS) && defined(HOTEND7_RESISTANCE_25C_OHMS) && defined(HOTEND7_BETA))
#error "TEMP_SENSOR_7 1000 requires HOTEND7_PULLUP_RESISTOR_OHMS, HOTEND7_RESISTANCE_25C_OHMS and HOTEND7_BETA in Configuration_adv.h."
#elif HEATER_BED_USER_THERMISTOR && !(defined(BED_PULLUP_RESISTOR_OHMS) && defined(BED_RESISTANCE_25C_OHMS) && defined(BED_BETA))
#elif TEMP_SENSOR_BED_IS_CUSTOM && !(defined(BED_PULLUP_RESISTOR_OHMS) && defined(BED_RESISTANCE_25C_OHMS) && defined(BED_BETA))
#error "TEMP_SENSOR_BED 1000 requires BED_PULLUP_RESISTOR_OHMS, BED_RESISTANCE_25C_OHMS and BED_BETA in Configuration_adv.h."
#elif HEATER_CHAMBER_USER_THERMISTOR && !(defined(CHAMBER_PULLUP_RESISTOR_OHMS) && defined(CHAMBER_RESISTANCE_25C_OHMS) && defined(CHAMBER_BETA))
#elif TEMP_SENSOR_CHAMBER_IS_CUSTOM && !(defined(CHAMBER_PULLUP_RESISTOR_OHMS) && defined(CHAMBER_RESISTANCE_25C_OHMS) && defined(CHAMBER_BETA))
#error "TEMP_SENSOR_CHAMBER 1000 requires CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS and CHAMBER_BETA in Configuration_adv.h."
#elif TEMP_SENSOR_PROBE_IS_CUSTOM && !(defined(PROBE_PULLUP_RESISTOR_OHMS) && defined(PROBE_RESISTANCE_25C_OHMS) && defined(PROBE_BETA))
#error "TEMP_SENSOR_PROBE 1000 requires PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS and PROBE_BETA in Configuration_adv.h."
#endif
/**
* Pins and Sensor IDs must be set for each heater
*/
#if HEATER_0_USES_MAX6675 && !PIN_EXISTS(MAX6675_SS)
#error "MAX6675_SS_PIN (required for TEMP_SENSOR_0) not defined for this board."
#elif HAS_HOTEND && !HAS_TEMP_HOTEND && !HEATER_0_DUMMY_THERMISTOR
#if TEMP_SENSOR_0_IS_MAX6675 && !ANY_PIN(MAX6675_SS, MAX31855_CS, MAX31865_CS, MAX6675_CS)
#error "TEMP_SENSOR_0 requires a MAX6675_SS_PIN, MAX6675_CS_PIN, MAX31855_CS_PIN, or MAX31865_CS_PIN."
#elif HAS_HOTEND && !HAS_TEMP_HOTEND && !TEMP_SENSOR_0_IS_DUMMY
#error "TEMP_0_PIN (required for TEMP_SENSOR_0) not defined for this board."
#elif EITHER(HAS_MULTI_HOTEND, HEATERS_PARALLEL) && !HAS_HEATER_1
#error "HEATER_1_PIN is not defined. TEMP_SENSOR_1 might not be set, or the board (not EEB / EEF?) doesn't define a pin."
#endif
#if HAS_MULTI_HOTEND
#if HEATER_1_USES_MAX6675 && !PIN_EXISTS(MAX6675_SS2)
#error "MAX6675_SS2_PIN (required for TEMP_SENSOR_1) not defined for this board."
#if TEMP_SENSOR_1_IS_MAX6675 && !ANY_PIN(MAX6675_SS2, MAX31855_CS2, MAX31865_CS2, MAX6675_CS2)
#error "TEMP_SENSOR_1 requires a MAX6675_SS2_PIN, MAX6675_CS2_PIN, MAX31855_CS2_PIN, or MAX31865_CS2_PIN."
#elif TEMP_SENSOR_1 == 0
#error "TEMP_SENSOR_1 is required with 2 or more HOTENDS."
#elif !ANY_PIN(TEMP_1, MAX6675_SS2) && !HEATER_1_DUMMY_THERMISTOR
#error "TEMP_1_PIN not defined for this board."
#elif !ANY_PIN(TEMP_1, MAX6675_SS2) && !TEMP_SENSOR_1_IS_DUMMY
#error "TEMP_1_PIN or MAX6675_SS2_PIN not defined for this board."
#elif ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
#error "HOTENDS must be 1 with TEMP_SENSOR_1_AS_REDUNDANT."
#endif
@ -1746,7 +1748,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
#error "TEMP_SENSOR_2 is required with 3 or more HOTENDS."
#elif !HAS_HEATER_2
#error "HEATER_2_PIN not defined for this board."
#elif !PIN_EXISTS(TEMP_2) && !HEATER_2_DUMMY_THERMISTOR
#elif !PIN_EXISTS(TEMP_2) && !TEMP_SENSOR_2_IS_DUMMY
#error "TEMP_2_PIN not defined for this board."
#endif
#if HOTENDS > 3
@ -1754,7 +1756,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
#error "TEMP_SENSOR_3 is required with 4 or more HOTENDS."
#elif !HAS_HEATER_3
#error "HEATER_3_PIN not defined for this board."
#elif !PIN_EXISTS(TEMP_3) && !HEATER_3_DUMMY_THERMISTOR
#elif !PIN_EXISTS(TEMP_3) && !TEMP_SENSOR_3_IS_DUMMY
#error "TEMP_3_PIN not defined for this board."
#endif
#if HOTENDS > 4
@ -1762,7 +1764,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
#error "TEMP_SENSOR_4 is required with 5 or more HOTENDS."
#elif !HAS_HEATER_4
#error "HEATER_4_PIN not defined for this board."
#elif !PIN_EXISTS(TEMP_4) && !HEATER_4_DUMMY_THERMISTOR
#elif !PIN_EXISTS(TEMP_4) && !TEMP_SENSOR_4_IS_DUMMY
#error "TEMP_4_PIN not defined for this board."
#endif
#if HOTENDS > 5
@ -1770,7 +1772,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
#error "TEMP_SENSOR_5 is required with 6 HOTENDS."
#elif !HAS_HEATER_5
#error "HEATER_5_PIN not defined for this board."
#elif !PIN_EXISTS(TEMP_5) && !HEATER_5_DUMMY_THERMISTOR
#elif !PIN_EXISTS(TEMP_5) && !TEMP_SENSOR_5_IS_DUMMY
#error "TEMP_5_PIN not defined for this board."
#endif
#if HOTENDS > 6
@ -1778,7 +1780,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
#error "TEMP_SENSOR_6 is required with 6 HOTENDS."
#elif !HAS_HEATER_6
#error "HEATER_6_PIN not defined for this board."
#elif !PIN_EXISTS(TEMP_6) && !HEATER_6_DUMMY_THERMISTOR
#elif !PIN_EXISTS(TEMP_6) && !TEMP_SENSOR_6_IS_DUMMY
#error "TEMP_6_PIN not defined for this board."
#endif
#if HOTENDS > 7
@ -1786,7 +1788,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
#error "TEMP_SENSOR_7 is required with 7 HOTENDS."
#elif !HAS_HEATER_7
#error "HEATER_7_PIN not defined for this board."
#elif !PIN_EXISTS(TEMP_7) && !HEATER_7_DUMMY_THERMISTOR
#elif !PIN_EXISTS(TEMP_7) && !TEMP_SENSOR_7_IS_DUMMY
#error "TEMP_7_PIN not defined for this board."
#endif
#elif TEMP_SENSOR_7 != 0
@ -1895,9 +1897,9 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
#error "TEMP_SENSOR_1 is required with TEMP_SENSOR_1_AS_REDUNDANT."
#endif
#if MAX6675_0_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_0) && defined(MAX31865_CALIBRATION_OHMS_0))
#if TEMP_SENSOR_0_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_0) && defined(MAX31865_CALIBRATION_OHMS_0))
#error "MAX31865_SENSOR_OHMS_0 and MAX31865_CALIBRATION_OHMS_0 must be set if TEMP_SENSOR_0 is MAX31865."
#elif MAX6675_1_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_1) && defined(MAX31865_CALIBRATION_OHMS_1))
#elif TEMP_SENSOR_1_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_1) && defined(MAX31865_CALIBRATION_OHMS_1))
#error "MAX31865_SENSOR_OHMS_1 and MAX31865_CALIBRATION_OHMS_1 must be set if TEMP_SENSOR_1 is MAX31865."
#endif

View file

@ -47,12 +47,12 @@
#include "../lcd/extui/ui_api.h"
#endif
#if MAX6675_0_IS_MAX31865 || MAX6675_1_IS_MAX31865
#if HAS_MAX31865
#include <Adafruit_MAX31865.h>
#if MAX6675_0_IS_MAX31865 && !defined(MAX31865_CS_PIN) && PIN_EXISTS(MAX6675_SS)
#if TEMP_SENSOR_0_IS_MAX31865 && !defined(MAX31865_CS_PIN) && PIN_EXISTS(MAX6675_SS)
#define MAX31865_CS_PIN MAX6675_SS_PIN
#endif
#if MAX6675_1_IS_MAX31865 && !defined(MAX31865_CS2_PIN) && PIN_EXISTS(MAX6675_SS2)
#if TEMP_SENSOR_1_IS_MAX31865 && !defined(MAX31865_CS2_PIN) && PIN_EXISTS(MAX6675_SS2)
#define MAX31865_CS2_PIN MAX6675_SS2_PIN
#endif
#ifndef MAX31865_MOSI_PIN
@ -64,16 +64,16 @@
#ifndef MAX31865_SCK_PIN
#define MAX31865_SCK_PIN MAX6675_SCK_PIN
#endif
#if MAX6675_0_IS_MAX31865 && PIN_EXISTS(MAX31865_CS)
#define HAS_MAX31865 1
#if TEMP_SENSOR_0_IS_MAX31865 && PIN_EXISTS(MAX31865_CS)
#define HAS_MAX31865_TEMP 1
Adafruit_MAX31865 max31865_0 = Adafruit_MAX31865(MAX31865_CS_PIN
#if MAX31865_CS_PIN != MAX6675_SS_PIN
, MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK
#endif
);
#endif
#if MAX6675_1_IS_MAX31865 && PIN_EXISTS(MAX31865_CS2)
#define HAS_MAX31865 1
#if TEMP_SENSOR_1_IS_MAX31865 && PIN_EXISTS(MAX31865_CS2)
#define HAS_MAX31865_TEMP 1
Adafruit_MAX31865 max31865_1 = Adafruit_MAX31865(MAX31865_CS2_PIN
#if MAX31865_CS2_PIN != MAX6675_SS2_PIN
, MAX31865_MOSI_PIN, MAX31865_MISO_PIN, MAX31865_SCK_PIN // For software SPI also set MOSI/MISO/SCK
@ -82,11 +82,11 @@
#endif
#endif
#if EITHER(HEATER_0_USES_MAX6675, HEATER_1_USES_MAX6675) && PINS_EXIST(MAX6675_SCK, MAX6675_DO)
#define MAX6675_SEPARATE_SPI 1
#if (TEMP_SENSOR_0_IS_MAX_TC || TEMP_SENSOR_1_IS_MAX_TC) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && NO_THERMO_TEMPS
#define THERMO_SEPARATE_SPI 1
#endif
#if MAX6675_SEPARATE_SPI
#if THERMO_SEPARATE_SPI
#include "../libs/private_spi.h"
#endif
@ -132,20 +132,20 @@
#include "./servo.h"
#endif
#if ANY(HEATER_0_USES_THERMISTOR, HEATER_1_USES_THERMISTOR, HEATER_2_USES_THERMISTOR, HEATER_3_USES_THERMISTOR, \
HEATER_4_USES_THERMISTOR, HEATER_5_USES_THERMISTOR, HEATER_6_USES_THERMISTOR, HEATER_7_USES_THERMISTOR )
#if ANY(TEMP_SENSOR_0_IS_THERMISTOR, TEMP_SENSOR_1_IS_THERMISTOR, TEMP_SENSOR_2_IS_THERMISTOR, TEMP_SENSOR_3_IS_THERMISTOR, \
TEMP_SENSOR_4_IS_THERMISTOR, TEMP_SENSOR_5_IS_THERMISTOR, TEMP_SENSOR_6_IS_THERMISTOR, TEMP_SENSOR_7_IS_THERMISTOR )
#define HAS_HOTEND_THERMISTOR 1
#endif
#if HAS_HOTEND_THERMISTOR
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
static const temp_entry_t* heater_ttbl_map[2] = { HEATER_0_TEMPTABLE, HEATER_1_TEMPTABLE };
static constexpr uint8_t heater_ttbllen_map[2] = { HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN };
static const temp_entry_t* heater_ttbl_map[2] = { TEMPTABLE_0, TEMPTABLE_1 };
static constexpr uint8_t heater_ttbllen_map[2] = { TEMPTABLE_0_LEN, TEMPTABLE_1_LEN };
#else
#define NEXT_TEMPTABLE(N) ,HEATER_##N##_TEMPTABLE
#define NEXT_TEMPTABLE_LEN(N) ,HEATER_##N##_TEMPTABLE_LEN
static const temp_entry_t* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_TEMPTABLE REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE));
static constexpr uint8_t heater_ttbllen_map[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_TEMPTABLE_LEN REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE_LEN));
#define NEXT_TEMPTABLE(N) ,TEMPTABLE_##N
#define NEXT_TEMPTABLE_LEN(N) ,TEMPTABLE_##N##_LEN
static const temp_entry_t* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS(TEMPTABLE_0 REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE));
static constexpr uint8_t heater_ttbllen_map[HOTENDS] = ARRAY_BY_HOTENDS(TEMPTABLE_0_LEN REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE_LEN));
#endif
#endif
@ -285,10 +285,10 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
bed_info_t Temperature::temp_bed; // = { 0 }
// Init min and max temp with extreme values to prevent false errors during startup
#ifdef BED_MINTEMP
int16_t Temperature::mintemp_raw_BED = HEATER_BED_RAW_LO_TEMP;
int16_t Temperature::mintemp_raw_BED = TEMP_SENSOR_BED_RAW_LO_TEMP;
#endif
#ifdef BED_MAXTEMP
int16_t Temperature::maxtemp_raw_BED = HEATER_BED_RAW_HI_TEMP;
int16_t Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP;
#endif
TERN_(WATCH_BED, bed_watch_t Temperature::watch_bed); // = { 0 }
IF_DISABLED(PIDTEMPBED, millis_t Temperature::next_bed_check_ms);
@ -303,10 +303,10 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
millis_t next_cool_check_ms_2 = 0;
float old_temp = 9999;
#ifdef CHAMBER_MINTEMP
int16_t Temperature::mintemp_raw_CHAMBER = HEATER_CHAMBER_RAW_LO_TEMP;
int16_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP;
#endif
#ifdef CHAMBER_MAXTEMP
int16_t Temperature::maxtemp_raw_CHAMBER = HEATER_CHAMBER_RAW_HI_TEMP;
int16_t Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP;
#endif
#if WATCH_CHAMBER
chamber_watch_t Temperature::watch_chamber{0};
@ -347,18 +347,18 @@ volatile bool Temperature::raw_temps_ready = false;
lpq_ptr_t Temperature::lpq_ptr = 0;
#endif
#define TEMPDIR(N) ((HEATER_##N##_RAW_LO_TEMP) < (HEATER_##N##_RAW_HI_TEMP) ? 1 : -1)
#define TEMPDIR(N) ((TEMP_SENSOR_##N##_RAW_LO_TEMP) < (TEMP_SENSOR_##N##_RAW_HI_TEMP) ? 1 : -1)
#if HAS_HOTEND
// Init mintemp and maxtemp with extreme values to prevent false errors during startup
constexpr temp_range_t sensor_heater_0 { HEATER_0_RAW_LO_TEMP, HEATER_0_RAW_HI_TEMP, 0, 16383 },
sensor_heater_1 { HEATER_1_RAW_LO_TEMP, HEATER_1_RAW_HI_TEMP, 0, 16383 },
sensor_heater_2 { HEATER_2_RAW_LO_TEMP, HEATER_2_RAW_HI_TEMP, 0, 16383 },
sensor_heater_3 { HEATER_3_RAW_LO_TEMP, HEATER_3_RAW_HI_TEMP, 0, 16383 },
sensor_heater_4 { HEATER_4_RAW_LO_TEMP, HEATER_4_RAW_HI_TEMP, 0, 16383 },
sensor_heater_5 { HEATER_5_RAW_LO_TEMP, HEATER_5_RAW_HI_TEMP, 0, 16383 },
sensor_heater_6 { HEATER_6_RAW_LO_TEMP, HEATER_6_RAW_HI_TEMP, 0, 16383 },
sensor_heater_7 { HEATER_7_RAW_LO_TEMP, HEATER_7_RAW_HI_TEMP, 0, 16383 };
constexpr temp_range_t sensor_heater_0 { TEMP_SENSOR_0_RAW_LO_TEMP, TEMP_SENSOR_0_RAW_HI_TEMP, 0, 16383 },
sensor_heater_1 { TEMP_SENSOR_1_RAW_LO_TEMP, TEMP_SENSOR_1_RAW_HI_TEMP, 0, 16383 },
sensor_heater_2 { TEMP_SENSOR_2_RAW_LO_TEMP, TEMP_SENSOR_2_RAW_HI_TEMP, 0, 16383 },
sensor_heater_3 { TEMP_SENSOR_3_RAW_LO_TEMP, TEMP_SENSOR_3_RAW_HI_TEMP, 0, 16383 },
sensor_heater_4 { TEMP_SENSOR_4_RAW_LO_TEMP, TEMP_SENSOR_4_RAW_HI_TEMP, 0, 16383 },
sensor_heater_5 { TEMP_SENSOR_5_RAW_LO_TEMP, TEMP_SENSOR_5_RAW_HI_TEMP, 0, 16383 },
sensor_heater_6 { TEMP_SENSOR_6_RAW_LO_TEMP, TEMP_SENSOR_6_RAW_HI_TEMP, 0, 16383 },
sensor_heater_7 { TEMP_SENSOR_7_RAW_LO_TEMP, TEMP_SENSOR_7_RAW_HI_TEMP, 0, 16383 };
temp_range_t Temperature::temp_range[HOTENDS] = ARRAY_BY_HOTENDS(sensor_heater_0, sensor_heater_1, sensor_heater_2, sensor_heater_3, sensor_heater_4, sensor_heater_5, sensor_heater_6, sensor_heater_7);
#endif
@ -1083,13 +1083,13 @@ void Temperature::manage_heater() {
updateTemperaturesFromRawValues(); // also resets the watchdog
#if DISABLED(IGNORE_THERMOCOUPLE_ERRORS)
#if HEATER_0_USES_MAX6675
if (temp_hotend[0].celsius > _MIN(HEATER_0_MAXTEMP, HEATER_0_MAX6675_TMAX - 1.0)) max_temp_error(H_E0);
if (temp_hotend[0].celsius < _MAX(HEATER_0_MINTEMP, HEATER_0_MAX6675_TMIN + .01)) min_temp_error(H_E0);
#if TEMP_SENSOR_0_IS_MAX_TC
if (temp_hotend[0].celsius > _MIN(HEATER_0_MAXTEMP, TEMP_SENSOR_0_MAX_TC_TMAX - 1.0)) max_temp_error(H_E0);
if (temp_hotend[0].celsius < _MAX(HEATER_0_MINTEMP, TEMP_SENSOR_0_MAX_TC_TMIN + .01)) min_temp_error(H_E0);
#endif
#if HEATER_1_USES_MAX6675
if (temp_hotend[1].celsius > _MIN(HEATER_1_MAXTEMP, HEATER_1_MAX6675_TMAX - 1.0)) max_temp_error(H_E1);
if (temp_hotend[1].celsius < _MAX(HEATER_1_MINTEMP, HEATER_1_MAX6675_TMIN + .01)) min_temp_error(H_E1);
#if TEMP_SENSOR_1_IS_MAX_TC
if (temp_hotend[1].celsius > _MIN(HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0)) max_temp_error(H_E1);
if (temp_hotend[1].celsius < _MAX(HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01)) min_temp_error(H_E1);
#endif
#endif
@ -1373,36 +1373,39 @@ void Temperature::manage_heater() {
void Temperature::reset_user_thermistors() {
user_thermistor_t default_user_thermistor[USER_THERMISTORS] = {
#if HEATER_0_USER_THERMISTOR
#if TEMP_SENSOR_0_IS_CUSTOM
{ true, 0, 0, HOTEND0_PULLUP_RESISTOR_OHMS, HOTEND0_RESISTANCE_25C_OHMS, 0, 0, HOTEND0_BETA, 0 },
#endif
#if HEATER_1_USER_THERMISTOR
#if TEMP_SENSOR_1_IS_CUSTOM
{ true, 0, 0, HOTEND1_PULLUP_RESISTOR_OHMS, HOTEND1_RESISTANCE_25C_OHMS, 0, 0, HOTEND1_BETA, 0 },
#endif
#if HEATER_2_USER_THERMISTOR
#if TEMP_SENSOR_2_IS_CUSTOM
{ true, 0, 0, HOTEND2_PULLUP_RESISTOR_OHMS, HOTEND2_RESISTANCE_25C_OHMS, 0, 0, HOTEND2_BETA, 0 },
#endif
#if HEATER_3_USER_THERMISTOR
#if TEMP_SENSOR_3_IS_CUSTOM
{ true, 0, 0, HOTEND3_PULLUP_RESISTOR_OHMS, HOTEND3_RESISTANCE_25C_OHMS, 0, 0, HOTEND3_BETA, 0 },
#endif
#if HEATER_4_USER_THERMISTOR
#if TEMP_SENSOR_4_IS_CUSTOM
{ true, 0, 0, HOTEND4_PULLUP_RESISTOR_OHMS, HOTEND4_RESISTANCE_25C_OHMS, 0, 0, HOTEND4_BETA, 0 },
#endif
#if HEATER_5_USER_THERMISTOR
#if TEMP_SENSOR_5_IS_CUSTOM
{ true, 0, 0, HOTEND5_PULLUP_RESISTOR_OHMS, HOTEND5_RESISTANCE_25C_OHMS, 0, 0, HOTEND5_BETA, 0 },
#endif
#if HEATER_6_USER_THERMISTOR
#if TEMP_SENSOR_6_IS_CUSTOM
{ true, 0, 0, HOTEND6_PULLUP_RESISTOR_OHMS, HOTEND6_RESISTANCE_25C_OHMS, 0, 0, HOTEND6_BETA, 0 },
#endif
#if HEATER_7_USER_THERMISTOR
#if TEMP_SENSOR_7_IS_CUSTOM
{ true, 0, 0, HOTEND7_PULLUP_RESISTOR_OHMS, HOTEND7_RESISTANCE_25C_OHMS, 0, 0, HOTEND7_BETA, 0 },
#endif
#if HEATER_BED_USER_THERMISTOR
#if TEMP_SENSOR_BED_IS_CUSTOM
{ true, 0, 0, BED_PULLUP_RESISTOR_OHMS, BED_RESISTANCE_25C_OHMS, 0, 0, BED_BETA, 0 },
#endif
#if HEATER_CHAMBER_USER_THERMISTOR
#if TEMP_SENSOR_CHAMBER_IS_CUSTOM
{ true, 0, 0, CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS, 0, 0, CHAMBER_BETA, 0 }
#endif
#if TEMP_SENSOR_PROBE_IS_CUSTOM
{ true, 0, 0, PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS, 0, 0, PROBE_BETA, 0 }
#endif
};
COPY(user_thermistor, default_user_thermistor);
}
@ -1423,16 +1426,17 @@ void Temperature::manage_heater() {
SERIAL_ECHOPAIR_F_P(SP_C_STR, t.sh_c_coeff, 9);
SERIAL_ECHOPGM(" ; ");
serialprintPGM(
TERN_(HEATER_0_USER_THERMISTOR, t_index == CTI_HOTEND_0 ? PSTR("HOTEND 0") :)
TERN_(HEATER_1_USER_THERMISTOR, t_index == CTI_HOTEND_1 ? PSTR("HOTEND 1") :)
TERN_(HEATER_2_USER_THERMISTOR, t_index == CTI_HOTEND_2 ? PSTR("HOTEND 2") :)
TERN_(HEATER_3_USER_THERMISTOR, t_index == CTI_HOTEND_3 ? PSTR("HOTEND 3") :)
TERN_(HEATER_4_USER_THERMISTOR, t_index == CTI_HOTEND_4 ? PSTR("HOTEND 4") :)
TERN_(HEATER_5_USER_THERMISTOR, t_index == CTI_HOTEND_5 ? PSTR("HOTEND 5") :)
TERN_(HEATER_6_USER_THERMISTOR, t_index == CTI_HOTEND_6 ? PSTR("HOTEND 6") :)
TERN_(HEATER_7_USER_THERMISTOR, t_index == CTI_HOTEND_7 ? PSTR("HOTEND 7") :)
TERN_(HEATER_BED_USER_THERMISTOR, t_index == CTI_BED ? PSTR("BED") :)
TERN_(HEATER_CHAMBER_USER_THERMISTOR, t_index == CTI_CHAMBER ? PSTR("CHAMBER") :)
TERN_(TEMP_SENSOR_0_IS_CUSTOM, t_index == CTI_HOTEND_0 ? PSTR("HOTEND 0") :)
TERN_(TEMP_SENSOR_1_IS_CUSTOM, t_index == CTI_HOTEND_1 ? PSTR("HOTEND 1") :)
TERN_(TEMP_SENSOR_2_IS_CUSTOM, t_index == CTI_HOTEND_2 ? PSTR("HOTEND 2") :)
TERN_(TEMP_SENSOR_3_IS_CUSTOM, t_index == CTI_HOTEND_3 ? PSTR("HOTEND 3") :)
TERN_(TEMP_SENSOR_4_IS_CUSTOM, t_index == CTI_HOTEND_4 ? PSTR("HOTEND 4") :)
TERN_(TEMP_SENSOR_5_IS_CUSTOM, t_index == CTI_HOTEND_5 ? PSTR("HOTEND 5") :)
TERN_(TEMP_SENSOR_6_IS_CUSTOM, t_index == CTI_HOTEND_6 ? PSTR("HOTEND 6") :)
TERN_(TEMP_SENSOR_7_IS_CUSTOM, t_index == CTI_HOTEND_7 ? PSTR("HOTEND 7") :)
TERN_(TEMP_SENSOR_BED_IS_CUSTOM, t_index == CTI_BED ? PSTR("BED") :)
TERN_(TEMP_SENSOR_CHAMBER_IS_CUSTOM, t_index == CTI_CHAMBER ? PSTR("CHAMBER") :)
TERN_(TEMP_SENSOR_PROBE_IS_CUSTOM, t_index == CTI_PROBE ? PSTR("PROBE") :)
nullptr
);
SERIAL_EOL();
@ -1498,85 +1502,85 @@ void Temperature::manage_heater() {
switch (e) {
case 0:
#if HEATER_0_USER_THERMISTOR
#if TEMP_SENSOR_0_IS_CUSTOM
return user_thermistor_to_deg_c(CTI_HOTEND_0, raw);
#elif HEATER_0_USES_MAX6675
return TERN(MAX6675_0_IS_MAX31865, max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0), raw * 0.25);
#elif HEATER_0_USES_AD595
#elif TEMP_SENSOR_0_IS_MAX_TC
return TERN(TEMP_SENSOR_0_IS_MAX31865, max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0), raw * 0.25);
#elif TEMP_SENSOR_0_IS_AD595
return TEMP_AD595(raw);
#elif HEATER_0_USES_AD8495
#elif TEMP_SENSOR_0_IS_AD8495
return TEMP_AD8495(raw);
#else
break;
#endif
case 1:
#if HEATER_1_USER_THERMISTOR
#if TEMP_SENSOR_1_IS_CUSTOM
return user_thermistor_to_deg_c(CTI_HOTEND_1, raw);
#elif HEATER_1_USES_MAX6675
return TERN(MAX6675_1_IS_MAX31865, max31865_1.temperature(MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1), raw * 0.25);
#elif HEATER_1_USES_AD595
#elif TEMP_SENSOR_1_IS_MAX_TC
return TERN(TEMP_SENSOR_1_IS_MAX31865, max31865_1.temperature(MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1), raw * 0.25);
#elif TEMP_SENSOR_1_IS_AD595
return TEMP_AD595(raw);
#elif HEATER_1_USES_AD8495
#elif TEMP_SENSOR_1_IS_AD8495
return TEMP_AD8495(raw);
#else
break;
#endif
case 2:
#if HEATER_2_USER_THERMISTOR
#if TEMP_SENSOR_2_IS_CUSTOM
return user_thermistor_to_deg_c(CTI_HOTEND_2, raw);
#elif HEATER_2_USES_AD595
#elif TEMP_SENSOR_2_IS_AD595
return TEMP_AD595(raw);
#elif HEATER_2_USES_AD8495
#elif TEMP_SENSOR_2_IS_AD8495
return TEMP_AD8495(raw);
#else
break;
#endif
case 3:
#if HEATER_3_USER_THERMISTOR
#if TEMP_SENSOR_3_IS_CUSTOM
return user_thermistor_to_deg_c(CTI_HOTEND_3, raw);
#elif HEATER_3_USES_AD595
#elif TEMP_SENSOR_3_IS_AD595
return TEMP_AD595(raw);
#elif HEATER_3_USES_AD8495
#elif TEMP_SENSOR_3_IS_AD8495
return TEMP_AD8495(raw);
#else
break;
#endif
case 4:
#if HEATER_4_USER_THERMISTOR
#if TEMP_SENSOR_4_IS_CUSTOM
return user_thermistor_to_deg_c(CTI_HOTEND_4, raw);
#elif HEATER_4_USES_AD595
#elif TEMP_SENSOR_4_IS_AD595
return TEMP_AD595(raw);
#elif HEATER_4_USES_AD8495
#elif TEMP_SENSOR_4_IS_AD8495
return TEMP_AD8495(raw);
#else
break;
#endif
case 5:
#if HEATER_5_USER_THERMISTOR
#if TEMP_SENSOR_5_IS_CUSTOM
return user_thermistor_to_deg_c(CTI_HOTEND_5, raw);
#elif HEATER_5_USES_AD595
#elif TEMP_SENSOR_5_IS_AD595
return TEMP_AD595(raw);
#elif HEATER_5_USES_AD8495
#elif TEMP_SENSOR_5_IS_AD8495
return TEMP_AD8495(raw);
#else
break;
#endif
case 6:
#if HEATER_6_USER_THERMISTOR
#if TEMP_SENSOR_6_IS_CUSTOM
return user_thermistor_to_deg_c(CTI_HOTEND_6, raw);
#elif HEATER_6_USES_AD595
#elif TEMP_SENSOR_6_IS_AD595
return TEMP_AD595(raw);
#elif HEATER_6_USES_AD8495
#elif TEMP_SENSOR_6_IS_AD8495
return TEMP_AD8495(raw);
#else
break;
#endif
case 7:
#if HEATER_7_USER_THERMISTOR
#if TEMP_SENSOR_7_IS_CUSTOM
return user_thermistor_to_deg_c(CTI_HOTEND_7, raw);
#elif HEATER_7_USES_AD595
#elif TEMP_SENSOR_7_IS_AD595
return TEMP_AD595(raw);
#elif HEATER_7_USES_AD8495
#elif TEMP_SENSOR_7_IS_AD8495
return TEMP_AD8495(raw);
#else
break;
@ -1598,13 +1602,13 @@ void Temperature::manage_heater() {
// Derived from RepRap FiveD extruder::getTemperature()
// For bed temperature measurement.
float Temperature::analog_to_celsius_bed(const int raw) {
#if HEATER_BED_USER_THERMISTOR
#if TEMP_SENSOR_BED_IS_CUSTOM
return user_thermistor_to_deg_c(CTI_BED, raw);
#elif HEATER_BED_USES_THERMISTOR
SCAN_THERMISTOR_TABLE(BED_TEMPTABLE, BED_TEMPTABLE_LEN);
#elif HEATER_BED_USES_AD595
#elif TEMP_SENSOR_BED_IS_THERMISTOR
SCAN_THERMISTOR_TABLE(TEMPTABLE_BED, TEMPTABLE_BED_LEN);
#elif TEMP_SENSOR_BED_IS_AD595
return TEMP_AD595(raw);
#elif HEATER_BED_USES_AD8495
#elif TEMP_SENSOR_BED_IS_AD8495
return TEMP_AD8495(raw);
#else
UNUSED(raw);
@ -1617,13 +1621,13 @@ void Temperature::manage_heater() {
// Derived from RepRap FiveD extruder::getTemperature()
// For chamber temperature measurement.
float Temperature::analog_to_celsius_chamber(const int raw) {
#if HEATER_CHAMBER_USER_THERMISTOR
#if TEMP_SENSOR_CHAMBER_IS_CUSTOM
return user_thermistor_to_deg_c(CTI_CHAMBER, raw);
#elif HEATER_CHAMBER_USES_THERMISTOR
SCAN_THERMISTOR_TABLE(CHAMBER_TEMPTABLE, CHAMBER_TEMPTABLE_LEN);
#elif HEATER_CHAMBER_USES_AD595
#elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR
SCAN_THERMISTOR_TABLE(TEMPTABLE_CHAMBER, TEMPTABLE_CHAMBER_LEN);
#elif TEMP_SENSOR_CHAMBER_IS_AD595
return TEMP_AD595(raw);
#elif HEATER_CHAMBER_USES_AD8495
#elif TEMP_SENSOR_CHAMBER_IS_AD8495
return TEMP_AD8495(raw);
#else
UNUSED(raw);
@ -1636,13 +1640,13 @@ void Temperature::manage_heater() {
// Derived from RepRap FiveD extruder::getTemperature()
// For probe temperature measurement.
float Temperature::analog_to_celsius_probe(const int raw) {
#if HEATER_PROBE_USER_THERMISTOR
#if TEMP_SENSOR_PROBE_IS_CUSTOM
return user_thermistor_to_deg_c(CTI_PROBE, raw);
#elif HEATER_PROBE_USES_THERMISTOR
SCAN_THERMISTOR_TABLE(PROBE_TEMPTABLE, PROBE_TEMPTABLE_LEN);
#elif HEATER_PROBE_USES_AD595
#elif TEMP_SENSOR_PROBE_IS_THERMISTOR
SCAN_THERMISTOR_TABLE(TEMPTABLE_PROBE, TEMPTABLE_PROBE_LEN);
#elif TEMP_SENSOR_PROBE_IS_AD595
return TEMP_AD595(raw);
#elif HEATER_PROBE_USES_AD8495
#elif TEMP_SENSOR_PROBE_IS_AD8495
return TEMP_AD8495(raw);
#else
UNUSED(raw);
@ -1658,8 +1662,8 @@ void Temperature::manage_heater() {
* as it would block the stepper routine.
*/
void Temperature::updateTemperaturesFromRawValues() {
TERN_(HEATER_0_USES_MAX6675, temp_hotend[0].raw = READ_MAX6675(0));
TERN_(HEATER_1_USES_MAX6675, temp_hotend[1].raw = READ_MAX6675(1));
TERN_(TEMP_SENSOR_0_IS_MAX_TC, temp_hotend[0].raw = READ_MAX_TC(0));
TERN_(TEMP_SENSOR_1_IS_MAX_TC, temp_hotend[1].raw = READ_MAX_TC(1));
#if HAS_HOTEND
HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].raw, e);
#endif
@ -1676,9 +1680,9 @@ void Temperature::updateTemperaturesFromRawValues() {
raw_temps_ready = false;
}
#if MAX6675_SEPARATE_SPI
#if THERMO_SEPARATE_SPI
template<uint8_t MisoPin, uint8_t MosiPin, uint8_t SckPin> SoftSPI<MisoPin, MosiPin, SckPin> SPIclass<MisoPin, MosiPin, SckPin>::softSPI;
SPIclass<MAX6675_DO_PIN, SD_MOSI_PIN, MAX6675_SCK_PIN> max6675_spi;
SPIclass<MAX6675_DO_PIN, SD_MOSI_PIN, MAX6675_SCK_PIN> max_tc_spi;
#endif
// Init fans according to whether they're native PWM or Software PWM
@ -1715,8 +1719,8 @@ void Temperature::updateTemperaturesFromRawValues() {
*/
void Temperature::init() {
TERN_(MAX6675_0_IS_MAX31865, max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE
TERN_(MAX6675_1_IS_MAX31865, max31865_1.begin(MAX31865_2WIRE));
TERN_(TEMP_SENSOR_0_IS_MAX31865, max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE
TERN_(TEMP_SENSOR_1_IS_MAX31865, max31865_1.begin(MAX31865_2WIRE));
#if EARLY_WATCHDOG
// Flag that the thermalManager should be running
@ -1726,7 +1730,7 @@ void Temperature::init() {
#if MB(RUMBA)
// Disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector
#define _AD(N) (HEATER_##N##_USES_AD595 || HEATER_##N##_USES_AD8495)
#define _AD(N) (TEMP_SENSOR_##N##_IS_AD595 || TEMP_SENSOR_##N##_IS_AD8495)
#if _AD(0) || _AD(1) || _AD(2) || _AD(BED) || _AD(CHAMBER)
MCUCR = _BV(JTD);
MCUCR = _BV(JTD);
@ -1734,11 +1738,11 @@ void Temperature::init() {
#endif
// Thermistor activation by MCU pin
#if PIN_EXISTS(TEMP_0_TR_ENABLE_PIN)
OUT_WRITE(TEMP_0_TR_ENABLE_PIN, ENABLED(HEATER_0_USES_MAX6675));
#if PIN_EXISTS(TEMP_0_TR_ENABLE)
OUT_WRITE(TEMP_0_TR_ENABLE_PIN, ENABLED(TEMP_SENSOR_0_IS_MAX_TC));
#endif
#if PIN_EXISTS(TEMP_1_TR_ENABLE_PIN)
OUT_WRITE(TEMP_1_TR_ENABLE_PIN, ENABLED(HEATER_1_USES_MAX6675));
#if PIN_EXISTS(TEMP_1_TR_ENABLE)
OUT_WRITE(TEMP_1_TR_ENABLE_PIN, ENABLED(TEMP_SENSOR_1_IS_MAX_TC));
#endif
#if BOTH(PIDTEMP, PID_EXTRUSION_SCALING)
@ -1815,7 +1819,7 @@ void Temperature::init() {
INIT_FAN_PIN(CONTROLLER_FAN_PIN);
#endif
TERN_(MAX6675_SEPARATE_SPI, max6675_spi.init());
TERN_(THERMO_SEPARATE_SPI, max_tc_spi.init());
HAL_adc_init();
@ -1914,19 +1918,19 @@ void Temperature::init() {
#if HAS_HOTEND
#define _TEMP_MIN_E(NR) do{ \
const int16_t tmin = _MAX(HEATER_ ##NR## _MINTEMP, TERN(HEATER_##NR##_USER_THERMISTOR, 0, (int16_t)pgm_read_word(&HEATER_ ##NR## _TEMPTABLE[HEATER_ ##NR## _SENSOR_MINTEMP_IND].celsius))); \
const int16_t tmin = _MAX(HEATER_##NR##_MINTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 0, (int16_t)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MINTEMP_IND].celsius))); \
temp_range[NR].mintemp = tmin; \
while (analog_to_celsius_hotend(temp_range[NR].raw_min, NR) < tmin) \
temp_range[NR].raw_min += TEMPDIR(NR) * (OVERSAMPLENR); \
}while(0)
#define _TEMP_MAX_E(NR) do{ \
const int16_t tmax = _MIN(HEATER_ ##NR## _MAXTEMP, TERN(HEATER_##NR##_USER_THERMISTOR, 2000, (int16_t)pgm_read_word(&HEATER_ ##NR## _TEMPTABLE[HEATER_ ##NR## _SENSOR_MAXTEMP_IND].celsius) - 1)); \
const int16_t tmax = _MIN(HEATER_##NR##_MAXTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 2000, (int16_t)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MAXTEMP_IND].celsius) - 1)); \
temp_range[NR].maxtemp = tmax; \
while (analog_to_celsius_hotend(temp_range[NR].raw_max, NR) > tmax) \
temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \
}while(0)
#define _MINMAX_TEST(N,M) (HOTENDS > N && THERMISTOR_HEATER_##N && THERMISTOR_HEATER_##N != 998 && THERMISTOR_HEATER_##N != 999 && defined(HEATER_##N##_##M##TEMP))
#define _MINMAX_TEST(N,M) (HOTENDS > N && TEMP_SENSOR_ ##N## THERMISTOR_ID && TEMP_SENSOR_ ##N## THERMISTOR_ID != 998 && TEMP_SENSOR_ ##N## THERMISTOR_ID != 999 && defined(HEATER_##N##_##M##TEMP))
#if _MINMAX_TEST(0, MIN)
_TEMP_MIN_E(0);
@ -2221,105 +2225,106 @@ void Temperature::disable_all_heaters() {
#endif
#if HAS_MAX6675
#if HAS_MAX_TC
#ifndef THERMOCOUPLE_MAX_ERRORS
#define THERMOCOUPLE_MAX_ERRORS 15
#endif
int Temperature::read_max6675(TERN_(HAS_MULTI_6675, const uint8_t hindex/*=0*/)) {
int Temperature::read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex/*=0*/)) {
#define MAX6675_HEAT_INTERVAL 250UL
#if MAX6675_0_IS_MAX31855 || MAX6675_1_IS_MAX31855
static uint32_t max6675_temp = 2000;
#define MAX6675_ERROR_MASK 7
#define MAX6675_DISCARD_BITS 18
#define MAX6675_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64
#elif HAS_MAX31865
static uint16_t max6675_temp = 2000; // From datasheet 16 bits D15-D0
#define MAX6675_ERROR_MASK 1 // D0 Bit not used
#define MAX6675_DISCARD_BITS 1 // Data is in D15-D1
#define MAX6675_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64
#if HAS_MAX31855
static uint32_t max_tc_temp = 2000;
#define MAX_TC_ERROR_MASK 7
#define MAX_TC_DISCARD_BITS 18
#define MAX_TC_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64
#elif HAS_MAX31865_TEMP
static uint16_t max_tc_temp = 2000; // From datasheet 16 bits D15-D0
#define MAX_TC_ERROR_MASK 1 // D0 Bit not used
#define MAX_TC_DISCARD_BITS 1 // Data is in D15-D1
#define MAX_TC_SPEED_BITS 3 // (_BV(SPR1)) // clock ÷ 64
#else
static uint16_t max6675_temp = 2000;
#define MAX6675_ERROR_MASK 4
#define MAX6675_DISCARD_BITS 3
#define MAX6675_SPEED_BITS 2 // (_BV(SPR0)) // clock ÷ 16
static uint16_t max_tc_temp = 2000;
#define MAX_TC_ERROR_MASK 4
#define MAX_TC_DISCARD_BITS 3
#define MAX_TC_SPEED_BITS 2 // (_BV(SPR0)) // clock ÷ 16
#endif
#if HAS_MULTI_6675
#if HAS_MULTI_MAX_TC
// Needed to return the correct temp when this is called between readings
static uint16_t max6675_temp_previous[COUNT_6675] = { 0 };
#define MAX6675_TEMP(I) max6675_temp_previous[I]
#define MAX6675_SEL(A,B) (hindex ? (B) : (A))
static uint16_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 };
#define THERMO_TEMP(I) max_tc_temp_previous[I]
#define THERMO_SEL(A,B) (hindex ? (B) : (A))
#define MAX6675_WRITE(V) do{ switch (hindex) { case 1: WRITE(MAX6675_SS2_PIN, V); break; default: WRITE(MAX6675_SS_PIN, V); } }while(0)
#define MAX6675_SET_OUTPUT() do{ switch (hindex) { case 1: SET_OUTPUT(MAX6675_SS2_PIN); break; default: SET_OUTPUT(MAX6675_SS_PIN); } }while(0)
#else
constexpr uint8_t hindex = 0;
#define MAX6675_TEMP(I) max6675_temp
#if MAX6675_1_IS_MAX31865
#define MAX6675_SEL(A,B) B
#define THERMO_TEMP(I) max_tc_temp
#if TEMP_SENSOR_1_IS_MAX31865
#define THERMO_SEL(A,B) B
#else
#define MAX6675_SEL(A,B) A
#define THERMO_SEL(A,B) A
#endif
#if HEATER_0_USES_MAX6675
#if TEMP_SENSOR_0_IS_MAX6675
#define MAX6675_WRITE(V) WRITE(MAX6675_SS_PIN, V)
#define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS_PIN)
#else
#define MAX6675_WRITE(V) WRITE(MAX6675_SS2_PIN, V)
#define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS2_PIN)
#endif
#endif
static uint8_t max6675_errors[COUNT_6675] = { 0 };
static uint8_t max_tc_errors[MAX_TC_COUNT] = { 0 };
// Return last-read value between readings
static millis_t next_max6675_ms[COUNT_6675] = { 0 };
static millis_t next_max_tc_ms[MAX_TC_COUNT] = { 0 };
millis_t ms = millis();
if (PENDING(ms, next_max6675_ms[hindex])) return int(MAX6675_TEMP(hindex));
next_max6675_ms[hindex] = ms + MAX6675_HEAT_INTERVAL;
if (PENDING(ms, next_max_tc_ms[hindex])) return int(THERMO_TEMP(hindex));
next_max_tc_ms[hindex] = ms + MAX6675_HEAT_INTERVAL;
#if HAS_MAX31865
Adafruit_MAX31865 &maxref = MAX6675_SEL(max31865_0, max31865_1);
const uint16_t max31865_ohms = (uint32_t(maxref.readRTD()) * MAX6675_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16;
#if HAS_MAX31865_TEMP
Adafruit_MAX31865 &maxref = THERMO_SEL(max31865_0, max31865_1);
const uint16_t max31865_ohms = (uint32_t(maxref.readRTD()) * THERMO_SEL(MAX31865_CALIBRATION_OHMS_0, MAX31865_CALIBRATION_OHMS_1)) >> 16;
#endif
//
// TODO: spiBegin, spiRec and spiInit doesn't work when soft spi is used.
//
#if !MAX6675_SEPARATE_SPI
#if !THERMO_SEPARATE_SPI
spiBegin();
spiInit(MAX6675_SPEED_BITS);
spiInit(MAX_TC_SPEED_BITS);
#endif
MAX6675_WRITE(LOW); // enable TT_MAX6675
DELAY_NS(100); // Ensure 100ns delay
MAX6675_WRITE(LOW); // enable TT_MAX6675
DELAY_NS(100); // Ensure 100ns delay
// Read a big-endian temperature value
max6675_temp = 0;
for (uint8_t i = sizeof(max6675_temp); i--;) {
max6675_temp |= TERN(MAX6675_SEPARATE_SPI, max6675_spi.receive(), spiRec());
if (i > 0) max6675_temp <<= 8; // shift left if not the last byte
max_tc_temp = 0;
for (uint8_t i = sizeof(max_tc_temp); i--;) {
max_tc_temp |= TERN(THERMO_SEPARATE_SPI, max_tc_spi.receive(), spiRec());
if (i > 0) max_tc_temp <<= 8; // shift left if not the last byte
}
MAX6675_WRITE(HIGH); // disable TT_MAX6675
const uint8_t fault_31865 = TERN1(HAS_MAX31865, maxref.readFault());
const uint8_t fault_31865 = TERN1(HAS_MAX31865_TEMP, maxref.readFault());
if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max6675_temp & MAX6675_ERROR_MASK) && fault_31865) {
max6675_errors[hindex]++;
if (max6675_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) {
if (DISABLED(IGNORE_THERMOCOUPLE_ERRORS) && (max_tc_temp & MAX_TC_ERROR_MASK) && fault_31865) {
max_tc_errors[hindex]++;
if (max_tc_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) {
SERIAL_ERROR_START();
SERIAL_ECHOPGM("Temp measurement error! ");
#if MAX6675_ERROR_MASK == 7
#if MAX_TC_ERROR_MASK == 7
SERIAL_ECHOPGM("MAX31855 ");
if (max6675_temp & 1)
if (max_tc_temp & 1)
SERIAL_ECHOLNPGM("Open Circuit");
else if (max6675_temp & 2)
else if (max_tc_temp & 2)
SERIAL_ECHOLNPGM("Short to GND");
else if (max6675_temp & 4)
else if (max_tc_temp & 4)
SERIAL_ECHOLNPGM("Short to VCC");
#elif HAS_MAX31865
#elif HAS_MAX31865_TEMP
if (fault_31865) {
maxref.clearFault();
SERIAL_ECHOPAIR("MAX31865 Fault :(", fault_31865, ") >>");
@ -2341,43 +2346,43 @@ void Temperature::disable_all_heaters() {
#endif
// Thermocouple open
max6675_temp = 4 * MAX6675_SEL(HEATER_0_MAX6675_TMAX, HEATER_1_MAX6675_TMAX);
max_tc_temp = 4 * THERMO_SEL(TEMP_SENSOR_0_MAX_TC_TMAX, TEMP_SENSOR_1_MAX_TC_TMAX);
}
else
max6675_temp >>= MAX6675_DISCARD_BITS;
max_tc_temp >>= MAX_TC_DISCARD_BITS;
}
else {
max6675_temp >>= MAX6675_DISCARD_BITS;
max6675_errors[hindex] = 0;
max_tc_temp >>= MAX_TC_DISCARD_BITS;
max_tc_errors[hindex] = 0;
}
#if MAX6675_0_IS_MAX31855 || MAX6675_1_IS_MAX31855
if (max6675_temp & 0x00002000) max6675_temp |= 0xFFFFC000; // Support negative temperature
#if HAS_MAX31855
if (max_tc_temp & 0x00002000) max_tc_temp |= 0xFFFFC000; // Support negative temperature
#endif
// Return the RTD resistance for MAX31865 for display in SHOW_TEMP_ADC_VALUES
TERN_(HAS_MAX31865, max6675_temp = max31865_ohms);
TERN_(HAS_MAX31865_TEMP, max_tc_temp = max31865_ohms);
MAX6675_TEMP(hindex) = max6675_temp;
THERMO_TEMP(hindex) = max_tc_temp;
return int(max6675_temp);
return int(max_tc_temp);
}
#endif // HAS_MAX6675
#endif // HAS_MAX_TC
/**
* Update raw temperatures
*/
void Temperature::update_raw_temperatures() {
#if HAS_TEMP_ADC_0 && !HEATER_0_USES_MAX6675
#if HAS_TEMP_ADC_0 && !TEMP_SENSOR_0_IS_MAX_TC
temp_hotend[0].update();
#endif
#if HAS_TEMP_ADC_1
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
redundant_temperature_raw = temp_hotend[1].acc;
#elif !HEATER_1_USES_MAX6675
#elif !TEMP_SENSOR_1_IS_MAX_TC
temp_hotend[1].update();
#endif
#endif
@ -2423,9 +2428,9 @@ void Temperature::readings_ready() {
#if HAS_HOTEND
static constexpr int8_t temp_dir[] = {
TERN(HEATER_0_USES_MAX6675, 0, TEMPDIR(0))
TERN(TEMP_SENSOR_0_IS_MAX_TC, 0, TEMPDIR(0))
#if HAS_MULTI_HOTEND
, TERN(HEATER_1_USES_MAX6675, 0, TEMPDIR(1))
, TERN(TEMP_SENSOR_1_IS_MAX_TC, 0, TEMPDIR(1))
#if HOTENDS > 2
#define _TEMPDIR(N) , TEMPDIR(N)
REPEAT_S(2, HOTENDS, _TEMPDIR)

View file

@ -257,31 +257,31 @@ typedef struct { int16_t raw_min, raw_max, mintemp, maxtemp; } temp_range_t;
#if HAS_USER_THERMISTORS
enum CustomThermistorIndex : uint8_t {
#if HEATER_0_USER_THERMISTOR
#if TEMP_SENSOR_0_IS_CUSTOM
CTI_HOTEND_0,
#endif
#if HEATER_1_USER_THERMISTOR
#if TEMP_SENSOR_1_IS_CUSTOM
CTI_HOTEND_1,
#endif
#if HEATER_2_USER_THERMISTOR
#if TEMP_SENSOR_2_IS_CUSTOM
CTI_HOTEND_2,
#endif
#if HEATER_3_USER_THERMISTOR
#if TEMP_SENSOR_3_IS_CUSTOM
CTI_HOTEND_3,
#endif
#if HEATER_4_USER_THERMISTOR
#if TEMP_SENSOR_4_IS_CUSTOM
CTI_HOTEND_4,
#endif
#if HEATER_5_USER_THERMISTOR
#if TEMP_SENSOR_5_IS_CUSTOM
CTI_HOTEND_5,
#endif
#if HEATER_BED_USER_THERMISTOR
#if TEMP_SENSOR_BED_IS_CUSTOM
CTI_BED,
#endif
#if HEATER_PROBE_USER_THERMISTOR
#if TEMP_SENSOR_PROBE_IS_CUSTOM
CTI_PROBE,
#endif
#if HEATER_CHAMBER_USER_THERMISTOR
#if TEMP_SENSOR_CHAMBER_IS_CUSTOM
CTI_CHAMBER,
#endif
USER_THERMISTORS
@ -813,16 +813,15 @@ class Temperature {
static void update_raw_temperatures();
static void updateTemperaturesFromRawValues();
#define HAS_MAX6675 EITHER(HEATER_0_USES_MAX6675, HEATER_1_USES_MAX6675)
#if HAS_MAX6675
#define COUNT_6675 1 + BOTH(HEATER_0_USES_MAX6675, HEATER_1_USES_MAX6675)
#if COUNT_6675 > 1
#define HAS_MULTI_6675 1
#define READ_MAX6675(N) read_max6675(N)
#if HAS_MAX_TC
#define MAX_TC_COUNT 1 + BOTH(TEMP_SENSOR_0_IS_MAX_TC, TEMP_SENSOR_1_IS_MAX_TC)
#if MAX_TC_COUNT > 1
#define HAS_MULTI_MAX_TC 1
#define READ_MAX_TC(N) read_max_tc(N)
#else
#define READ_MAX6675(N) read_max6675()
#define READ_MAX_TC(N) read_max_tc()
#endif
static int read_max6675(TERN_(HAS_MULTI_6675, const uint8_t hindex=0));
static int read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex=0));
#endif
static void checkExtruderAutoFans();

View file

@ -42,7 +42,7 @@
#define OV_SCALE(N) (N)
#define OV(N) int16_t(OV_SCALE(N) * (OVERSAMPLENR) * (THERMISTOR_TABLE_SCALE))
#define ANY_THERMISTOR_IS(n) (THERMISTOR_HEATER_0 == n || THERMISTOR_HEATER_1 == n || THERMISTOR_HEATER_2 == n || THERMISTOR_HEATER_3 == n || THERMISTOR_HEATER_4 == n || THERMISTOR_HEATER_5 == n || THERMISTOR_HEATER_6 == n || THERMISTOR_HEATER_7 == n || THERMISTORBED == n || THERMISTORCHAMBER == n || THERMISTORPROBE == n)
#define ANY_THERMISTOR_IS(n) (TEMP_SENSOR_0_THERMISTOR_ID == n || TEMP_SENSOR_1_THERMISTOR_ID == n || TEMP_SENSOR_2_THERMISTOR_ID == n || TEMP_SENSOR_3_THERMISTOR_ID == n || TEMP_SENSOR_4_THERMISTOR_ID == n || TEMP_SENSOR_5_THERMISTOR_ID == n || TEMP_SENSOR_6_THERMISTOR_ID == n || TEMP_SENSOR_7_THERMISTOR_ID == n || TEMP_SENSOR_BED_THERMISTOR_ID == n || TEMP_SENSOR_CHAMBER_THERMISTOR_ID == n || TEMP_SENSOR_PROBE_THERMISTOR_ID == n)
typedef struct { int16_t value, celsius; } temp_entry_t;
@ -205,121 +205,121 @@ typedef struct { int16_t value, celsius; } temp_entry_t;
#define TT_NAME(_N) _TT_NAME(_N)
#if THERMISTOR_HEATER_0
#define HEATER_0_TEMPTABLE TT_NAME(THERMISTOR_HEATER_0)
#define HEATER_0_TEMPTABLE_LEN COUNT(HEATER_0_TEMPTABLE)
#elif HEATER_0_USES_THERMISTOR
#if TEMP_SENSOR_0_THERMISTOR_ID
#define TEMPTABLE_0 TT_NAME(TEMP_SENSOR_0_THERMISTOR_ID)
#define TEMPTABLE_0_LEN COUNT(TEMPTABLE_0)
#elif TEMP_SENSOR_0_IS_THERMISTOR
#error "No heater 0 thermistor table specified"
#else
#define HEATER_0_TEMPTABLE nullptr
#define HEATER_0_TEMPTABLE_LEN 0
#define TEMPTABLE_0 nullptr
#define TEMPTABLE_0_LEN 0
#endif
#if THERMISTOR_HEATER_1
#define HEATER_1_TEMPTABLE TT_NAME(THERMISTOR_HEATER_1)
#define HEATER_1_TEMPTABLE_LEN COUNT(HEATER_1_TEMPTABLE)
#elif HEATER_1_USES_THERMISTOR
#if TEMP_SENSOR_1_THERMISTOR_ID
#define TEMPTABLE_1 TT_NAME(TEMP_SENSOR_1_THERMISTOR_ID)
#define TEMPTABLE_1_LEN COUNT(TEMPTABLE_1)
#elif TEMP_SENSOR_1_IS_THERMISTOR
#error "No heater 1 thermistor table specified"
#else
#define HEATER_1_TEMPTABLE nullptr
#define HEATER_1_TEMPTABLE_LEN 0
#define TEMPTABLE_1 nullptr
#define TEMPTABLE_1_LEN 0
#endif
#if THERMISTOR_HEATER_2
#define HEATER_2_TEMPTABLE TT_NAME(THERMISTOR_HEATER_2)
#define HEATER_2_TEMPTABLE_LEN COUNT(HEATER_2_TEMPTABLE)
#elif HEATER_2_USES_THERMISTOR
#if TEMP_SENSOR_2_THERMISTOR_ID
#define TEMPTABLE_2 TT_NAME(TEMP_SENSOR_2_THERMISTOR_ID)
#define TEMPTABLE_2_LEN COUNT(TEMPTABLE_2)
#elif TEMP_SENSOR_2_IS_THERMISTOR
#error "No heater 2 thermistor table specified"
#else
#define HEATER_2_TEMPTABLE nullptr
#define HEATER_2_TEMPTABLE_LEN 0
#define TEMPTABLE_2 nullptr
#define TEMPTABLE_2_LEN 0
#endif
#if THERMISTOR_HEATER_3
#define HEATER_3_TEMPTABLE TT_NAME(THERMISTOR_HEATER_3)
#define HEATER_3_TEMPTABLE_LEN COUNT(HEATER_3_TEMPTABLE)
#elif HEATER_3_USES_THERMISTOR
#if TEMP_SENSOR_3_THERMISTOR_ID
#define TEMPTABLE_3 TT_NAME(TEMP_SENSOR_3_THERMISTOR_ID)
#define TEMPTABLE_3_LEN COUNT(TEMPTABLE_3)
#elif TEMP_SENSOR_3_IS_THERMISTOR
#error "No heater 3 thermistor table specified"
#else
#define HEATER_3_TEMPTABLE nullptr
#define HEATER_3_TEMPTABLE_LEN 0
#define TEMPTABLE_3 nullptr
#define TEMPTABLE_3_LEN 0
#endif
#if THERMISTOR_HEATER_4
#define HEATER_4_TEMPTABLE TT_NAME(THERMISTOR_HEATER_4)
#define HEATER_4_TEMPTABLE_LEN COUNT(HEATER_4_TEMPTABLE)
#elif HEATER_4_USES_THERMISTOR
#if TEMP_SENSOR_4_THERMISTOR_ID
#define TEMPTABLE_4 TT_NAME(TEMP_SENSOR_4_THERMISTOR_ID)
#define TEMPTABLE_4_LEN COUNT(TEMPTABLE_4)
#elif TEMP_SENSOR_4_IS_THERMISTOR
#error "No heater 4 thermistor table specified"
#else
#define HEATER_4_TEMPTABLE nullptr
#define HEATER_4_TEMPTABLE_LEN 0
#define TEMPTABLE_4 nullptr
#define TEMPTABLE_4_LEN 0
#endif
#if THERMISTOR_HEATER_5
#define HEATER_5_TEMPTABLE TT_NAME(THERMISTOR_HEATER_5)
#define HEATER_5_TEMPTABLE_LEN COUNT(HEATER_5_TEMPTABLE)
#elif HEATER_5_USES_THERMISTOR
#if TEMP_SENSOR_5_THERMISTOR_ID
#define TEMPTABLE_5 TT_NAME(TEMP_SENSOR_5_THERMISTOR_ID)
#define TEMPTABLE_5_LEN COUNT(TEMPTABLE_5)
#elif TEMP_SENSOR_5_IS_THERMISTOR
#error "No heater 5 thermistor table specified"
#else
#define HEATER_5_TEMPTABLE nullptr
#define HEATER_5_TEMPTABLE_LEN 0
#define TEMPTABLE_5 nullptr
#define TEMPTABLE_5_LEN 0
#endif
#if THERMISTOR_HEATER_6
#define HEATER_6_TEMPTABLE TT_NAME(THERMISTOR_HEATER_6)
#define HEATER_6_TEMPTABLE_LEN COUNT(HEATER_6_TEMPTABLE)
#elif HEATER_6_USES_THERMISTOR
#if TEMP_SENSOR_6_THERMISTOR_ID
#define TEMPTABLE_6 TT_NAME(TEMP_SENSOR_6_THERMISTOR_ID)
#define TEMPTABLE_6_LEN COUNT(TEMPTABLE_6)
#elif TEMP_SENSOR_6_IS_THERMISTOR
#error "No heater 6 thermistor table specified"
#else
#define HEATER_6_TEMPTABLE nullptr
#define HEATER_6_TEMPTABLE_LEN 0
#define TEMPTABLE_6 nullptr
#define TEMPTABLE_6_LEN 0
#endif
#if THERMISTOR_HEATER_7
#define HEATER_7_TEMPTABLE TT_NAME(THERMISTOR_HEATER_7)
#define HEATER_7_TEMPTABLE_LEN COUNT(HEATER_7_TEMPTABLE)
#elif HEATER_7_USES_THERMISTOR
#if TEMP_SENSOR_7_THERMISTOR_ID
#define TEMPTABLE_7 TT_NAME(TEMP_SENSOR_7_THERMISTOR_ID)
#define TEMPTABLE_7_LEN COUNT(TEMPTABLE_7)
#elif TEMP_SENSOR_7_IS_THERMISTOR
#error "No heater 7 thermistor table specified"
#else
#define HEATER_7_TEMPTABLE nullptr
#define HEATER_7_TEMPTABLE_LEN 0
#define TEMPTABLE_7 nullptr
#define TEMPTABLE_7_LEN 0
#endif
#ifdef THERMISTORBED
#define BED_TEMPTABLE TT_NAME(THERMISTORBED)
#define BED_TEMPTABLE_LEN COUNT(BED_TEMPTABLE)
#elif HEATER_BED_USES_THERMISTOR
#ifdef TEMP_SENSOR_BED_THERMISTOR_ID
#define TEMPTABLE_BED TT_NAME(TEMP_SENSOR_BED_THERMISTOR_ID)
#define TEMPTABLE_BED_LEN COUNT(TEMPTABLE_BED)
#elif TEMP_SENSOR_BED_IS_THERMISTOR
#error "No bed thermistor table specified"
#else
#define BED_TEMPTABLE_LEN 0
#define TEMPTABLE_BED_LEN 0
#endif
#ifdef THERMISTORCHAMBER
#define CHAMBER_TEMPTABLE TT_NAME(THERMISTORCHAMBER)
#define CHAMBER_TEMPTABLE_LEN COUNT(CHAMBER_TEMPTABLE)
#elif HEATER_CHAMBER_USES_THERMISTOR
#ifdef TEMP_SENSOR_CHAMBER_THERMISTOR_ID
#define TEMPTABLE_CHAMBER TT_NAME(TEMP_SENSOR_CHAMBER_THERMISTOR_ID)
#define TEMPTABLE_CHAMBER_LEN COUNT(TEMPTABLE_CHAMBER)
#elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR
#error "No chamber thermistor table specified"
#else
#define CHAMBER_TEMPTABLE_LEN 0
#define TEMPTABLE_CHAMBER_LEN 0
#endif
#ifdef THERMISTORPROBE
#define PROBE_TEMPTABLE TT_NAME(THERMISTORPROBE)
#define PROBE_TEMPTABLE_LEN COUNT(PROBE_TEMPTABLE)
#elif HEATER_PROBE_USES_THERMISTOR
#ifdef TEMP_SENSOR_PROBE_THERMISTOR_ID
#define TEMPTABLE_PROBE TT_NAME(TEMP_SENSOR_PROBE_THERMISTOR_ID)
#define TEMPTABLE_PROBE_LEN COUNT(TEMPTABLE_PROBE)
#elif TEMP_SENSOR_PROBE_IS_THERMISTOR
#error "No probe thermistor table specified"
#else
#define PROBE_TEMPTABLE_LEN 0
#define TEMPTABLE_PROBE_LEN 0
#endif
// The SCAN_THERMISTOR_TABLE macro needs alteration?
static_assert(
HEATER_0_TEMPTABLE_LEN < 256 && HEATER_1_TEMPTABLE_LEN < 256
&& HEATER_2_TEMPTABLE_LEN < 256 && HEATER_3_TEMPTABLE_LEN < 256
&& HEATER_4_TEMPTABLE_LEN < 256 && HEATER_5_TEMPTABLE_LEN < 256
&& HEATER_6_TEMPTABLE_LEN < 256 && HEATER_7_TEMPTABLE_LEN < 256
&& BED_TEMPTABLE_LEN < 256 && CHAMBER_TEMPTABLE_LEN < 256
&& PROBE_TEMPTABLE_LEN < 256,
TEMPTABLE_0_LEN < 256 && TEMPTABLE_1_LEN < 256
&& TEMPTABLE_2_LEN < 256 && TEMPTABLE_3_LEN < 256
&& TEMPTABLE_4_LEN < 256 && TEMPTABLE_5_LEN < 256
&& TEMPTABLE_6_LEN < 256 && TEMPTABLE_7_LEN < 256
&& TEMPTABLE_BED_LEN < 256 && TEMPTABLE_CHAMBER_LEN < 256
&& TEMPTABLE_PROBE_LEN < 256,
"Temperature conversion tables over 255 entries need special consideration."
);
@ -327,181 +327,185 @@ static_assert(
// For thermistors the highest temperature results in the lowest ADC value
// For thermocouples the highest temperature results in the highest ADC value
#define _TT_REV(N) REVERSE_TEMP_SENSOR_RANGE_##N
#define TT_REV(N) _TT_REV(N)
#define _TT_REV(N) REVERSE_TEMP_SENSOR_RANGE_##N
#define TT_REV(N) _TT_REV(TEMP_SENSOR_##N##_THERMISTOR_ID)
#define _TT_REVRAW(N) !TEMP_SENSOR_##N##_IS_THERMISTOR
#define TT_REVRAW(N) (TT_REV(N) || _TT_REVRAW(N))
#ifdef HEATER_0_TEMPTABLE
#if TT_REV(THERMISTOR_HEATER_0)
#define HEATER_0_SENSOR_MINTEMP_IND 0
#define HEATER_0_SENSOR_MAXTEMP_IND HEATER_0_TEMPTABLE_LEN - 1
#ifdef TEMPTABLE_0
#if TT_REV(0)
#define TEMP_SENSOR_0_MINTEMP_IND 0
#define TEMPTABLE_0_MAXTEMP_IND HEATER_0_LEN - 1
#else
#define HEATER_0_SENSOR_MINTEMP_IND HEATER_0_TEMPTABLE_LEN - 1
#define HEATER_0_SENSOR_MAXTEMP_IND 0
#define TEMPTABLE_0_MINTEMP_IND HEATER_0_LEN - 1
#define TEMP_SENSOR_0_MAXTEMP_IND 0
#endif
#endif
#ifdef HEATER_1_TEMPTABLE
#if TT_REV(THERMISTOR_HEATER_1)
#define HEATER_1_SENSOR_MINTEMP_IND 0
#define HEATER_1_SENSOR_MAXTEMP_IND HEATER_1_TEMPTABLE_LEN - 1
#ifdef TEMPTABLE_1
#if TT_REV(1)
#define TEMP_SENSOR_1_MINTEMP_IND 0
#define TEMPTABLE_1_MAXTEMP_IND HEATER_1_LEN - 1
#else
#define HEATER_1_SENSOR_MINTEMP_IND HEATER_1_TEMPTABLE_LEN - 1
#define HEATER_1_SENSOR_MAXTEMP_IND 0
#define TEMPTABLE_1_MINTEMP_IND HEATER_1_LEN - 1
#define TEMP_SENSOR_1_MAXTEMP_IND 0
#endif
#endif
#ifdef HEATER_2_TEMPTABLE
#if TT_REV(THERMISTOR_HEATER_2)
#define HEATER_2_SENSOR_MINTEMP_IND 0
#define HEATER_2_SENSOR_MAXTEMP_IND HEATER_2_TEMPTABLE_LEN - 1
#ifdef TEMPTABLE_2
#if TT_REV(2)
#define TEMP_SENSOR_2_MINTEMP_IND 0
#define TEMPTABLE_2_MAXTEMP_IND HEATER_2_LEN - 1
#else
#define HEATER_2_SENSOR_MINTEMP_IND HEATER_2_TEMPTABLE_LEN - 1
#define HEATER_2_SENSOR_MAXTEMP_IND 0
#define TEMPTABLE_2_MINTEMP_IND HEATER_2_LEN - 1
#define TEMP_SENSOR_2_MAXTEMP_IND 0
#endif
#endif
#ifdef HEATER_3_TEMPTABLE
#if TT_REV(THERMISTOR_HEATER_3)
#define HEATER_3_SENSOR_MINTEMP_IND 0
#define HEATER_3_SENSOR_MAXTEMP_IND HEATER_3_TEMPTABLE_LEN - 1
#ifdef TEMPTABLE_3
#if TT_REV(3)
#define TEMP_SENSOR_3_MINTEMP_IND 0
#define TEMPTABLE_3_MAXTEMP_IND HEATER_3_LEN - 1
#else
#define HEATER_3_SENSOR_MINTEMP_IND HEATER_3_TEMPTABLE_LEN - 1
#define HEATER_3_SENSOR_MAXTEMP_IND 0
#define TEMPTABLE_3_MINTEMP_IND HEATER_3_LEN - 1
#define TEMP_SENSOR_3_MAXTEMP_IND 0
#endif
#endif
#ifdef HEATER_4_TEMPTABLE
#if TT_REV(THERMISTOR_HEATER_4)
#define HEATER_4_SENSOR_MINTEMP_IND 0
#define HEATER_4_SENSOR_MAXTEMP_IND HEATER_4_TEMPTABLE_LEN - 1
#ifdef TEMPTABLE_4
#if TT_REV(4)
#define TEMP_SENSOR_4_MINTEMP_IND 0
#define TEMPTABLE_4_MAXTEMP_IND HEATER_4_LEN - 1
#else
#define HEATER_4_SENSOR_MINTEMP_IND HEATER_4_TEMPTABLE_LEN - 1
#define HEATER_4_SENSOR_MAXTEMP_IND 0
#define TEMPTABLE_4_MINTEMP_IND HEATER_4_LEN - 1
#define TEMP_SENSOR_4_MAXTEMP_IND 0
#endif
#endif
#ifdef HEATER_5_TEMPTABLE
#if TT_REV(THERMISTOR_HEATER_5)
#define HEATER_5_SENSOR_MINTEMP_IND 0
#define HEATER_5_SENSOR_MAXTEMP_IND HEATER_5_TEMPTABLE_LEN - 1
#ifdef TEMPTABLE_5
#if TT_REV(5)
#define TEMP_SENSOR_5_MINTEMP_IND 0
#define TEMPTABLE_5_MAXTEMP_IND HEATER_5_LEN - 1
#else
#define HEATER_5_SENSOR_MINTEMP_IND HEATER_5_TEMPTABLE_LEN - 1
#define HEATER_5_SENSOR_MAXTEMP_IND 0
#define TEMPTABLE_5_MINTEMP_IND HEATER_5_LEN - 1
#define TEMP_SENSOR_5_MAXTEMP_IND 0
#endif
#endif
#ifdef HEATER_6_TEMPTABLE
#if TT_REV(THERMISTOR_HEATER_6)
#define HEATER_6_SENSOR_MINTEMP_IND 0
#define HEATER_6_SENSOR_MAXTEMP_IND HEATER_6_TEMPTABLE_LEN - 1
#ifdef TEMPTABLE_6
#if TT_REV(6)
#define TEMP_SENSOR_6_MINTEMP_IND 0
#define TEMPTABLE_6_MAXTEMP_IND HEATER_6_LEN - 1
#else
#define HEATER_6_SENSOR_MINTEMP_IND HEATER_6_TEMPTABLE_LEN - 1
#define HEATER_6_SENSOR_MAXTEMP_IND 0
#define TEMPTABLE_6_MINTEMP_IND HEATER_6_LEN - 1
#define TEMP_SENSOR_6_MAXTEMP_IND 0
#endif
#endif
#ifdef HEATER_7_TEMPTABLE
#if TT_REV(THERMISTOR_HEATER_7)
#define HEATER_7_SENSOR_MINTEMP_IND 0
#define HEATER_7_SENSOR_MAXTEMP_IND HEATER_7_TEMPTABLE_LEN - 1
#ifdef TEMPTABLE_7
#if TT_REV(7)
#define TEMP_SENSOR_7_MINTEMP_IND 0
#define TEMPTABLE_7_MAXTEMP_IND HEATER_7_LEN - 1
#else
#define HEATER_7_SENSOR_MINTEMP_IND HEATER_7_TEMPTABLE_LEN - 1
#define HEATER_7_SENSOR_MAXTEMP_IND 0
#define TEMPTABLE_7_MINTEMP_IND HEATER_7_LEN - 1
#define TEMP_SENSOR_7_MAXTEMP_IND 0
#endif
#endif
#ifndef HEATER_0_RAW_HI_TEMP
#if TT_REV(THERMISTOR_HEATER_0) || !HEATER_0_USES_THERMISTOR
#define HEATER_0_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define HEATER_0_RAW_LO_TEMP 0
#ifndef TEMP_SENSOR_0_RAW_HI_TEMP
#if TT_REVRAW(0)
#define TEMP_SENSOR_0_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_0_RAW_LO_TEMP 0
#else
#define HEATER_0_RAW_HI_TEMP 0
#define HEATER_0_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_0_RAW_HI_TEMP 0
#define TEMP_SENSOR_0_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#endif
#endif
#ifndef HEATER_1_RAW_HI_TEMP
#if TT_REV(THERMISTOR_HEATER_1) || !HEATER_1_USES_THERMISTOR
#define HEATER_1_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define HEATER_1_RAW_LO_TEMP 0
#ifndef TEMP_SENSOR_1_RAW_HI_TEMP
#if TT_REVRAW(1)
#define TEMP_SENSOR_1_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_1_RAW_LO_TEMP 0
#else
#define HEATER_1_RAW_HI_TEMP 0
#define HEATER_1_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_1_RAW_HI_TEMP 0
#define TEMP_SENSOR_1_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#endif
#endif
#ifndef HEATER_2_RAW_HI_TEMP
#if TT_REV(THERMISTOR_HEATER_2) || !HEATER_2_USES_THERMISTOR
#define HEATER_2_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define HEATER_2_RAW_LO_TEMP 0
#ifndef TEMP_SENSOR_2_RAW_HI_TEMP
#if TT_REVRAW(2)
#define TEMP_SENSOR_2_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_2_RAW_LO_TEMP 0
#else
#define HEATER_2_RAW_HI_TEMP 0
#define HEATER_2_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_2_RAW_HI_TEMP 0
#define TEMP_SENSOR_2_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#endif
#endif
#ifndef HEATER_3_RAW_HI_TEMP
#if TT_REV(THERMISTOR_HEATER_3) || !HEATER_3_USES_THERMISTOR
#define HEATER_3_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define HEATER_3_RAW_LO_TEMP 0
#ifndef TEMP_SENSOR_3_RAW_HI_TEMP
#if TT_REVRAW(3)
#define TEMP_SENSOR_3_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_3_RAW_LO_TEMP 0
#else
#define HEATER_3_RAW_HI_TEMP 0
#define HEATER_3_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_3_RAW_HI_TEMP 0
#define TEMP_SENSOR_3_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#endif
#endif
#ifndef HEATER_4_RAW_HI_TEMP
#if TT_REV(THERMISTOR_HEATER_4) || !HEATER_4_USES_THERMISTOR
#define HEATER_4_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define HEATER_4_RAW_LO_TEMP 0
#ifndef TEMP_SENSOR_4_RAW_HI_TEMP
#if TT_REVRAW(4)
#define TEMP_SENSOR_4_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_4_RAW_LO_TEMP 0
#else
#define HEATER_4_RAW_HI_TEMP 0
#define HEATER_4_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_4_RAW_HI_TEMP 0
#define TEMP_SENSOR_4_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#endif
#endif
#ifndef HEATER_5_RAW_HI_TEMP
#if TT_REV(THERMISTOR_HEATER_5) || !HEATER_5_USES_THERMISTOR
#define HEATER_5_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define HEATER_5_RAW_LO_TEMP 0
#ifndef TEMP_SENSOR_5_RAW_HI_TEMP
#if TT_REVRAW(5)
#define TEMP_SENSOR_5_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_5_RAW_LO_TEMP 0
#else
#define HEATER_5_RAW_HI_TEMP 0
#define HEATER_5_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_5_RAW_HI_TEMP 0
#define TEMP_SENSOR_5_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#endif
#endif
#ifndef HEATER_6_RAW_HI_TEMP
#if TT_REV(THERMISTOR_HEATER_6) || !HEATER_6_USES_THERMISTOR
#define HEATER_6_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define HEATER_6_RAW_LO_TEMP 0
#ifndef TEMP_SENSOR_6_RAW_HI_TEMP
#if TT_REVRAW(6)
#define TEMP_SENSOR_6_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_6_RAW_LO_TEMP 0
#else
#define HEATER_6_RAW_HI_TEMP 0
#define HEATER_6_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_6_RAW_HI_TEMP 0
#define TEMP_SENSOR_6_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#endif
#endif
#ifndef HEATER_7_RAW_HI_TEMP
#if TT_REV(THERMISTOR_HEATER_7) || !HEATER_7_USES_THERMISTOR
#define HEATER_7_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define HEATER_7_RAW_LO_TEMP 0
#ifndef TEMP_SENSOR_7_RAW_HI_TEMP
#if TT_REVRAW(7)
#define TEMP_SENSOR_7_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_7_RAW_LO_TEMP 0
#else
#define HEATER_7_RAW_HI_TEMP 0
#define HEATER_7_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_7_RAW_HI_TEMP 0
#define TEMP_SENSOR_7_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#endif
#endif
#ifndef HEATER_BED_RAW_HI_TEMP
#if TT_REV(THERMISTORBED) || !HEATER_BED_USES_THERMISTOR
#define HEATER_BED_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define HEATER_BED_RAW_LO_TEMP 0
#ifndef TEMP_SENSOR_BED_RAW_HI_TEMP
#if TT_REVRAW(BED)
#define TEMP_SENSOR_BED_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_BED_RAW_LO_TEMP 0
#else
#define HEATER_BED_RAW_HI_TEMP 0
#define HEATER_BED_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_BED_RAW_HI_TEMP 0
#define TEMP_SENSOR_BED_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#endif
#endif
#ifndef HEATER_CHAMBER_RAW_HI_TEMP
#if TT_REV(THERMISTORCHAMBER) || !HEATER_CHAMBER_USES_THERMISTOR
#define HEATER_CHAMBER_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define HEATER_CHAMBER_RAW_LO_TEMP 0
#ifndef TEMP_SENSOR_CHAMBER_RAW_HI_TEMP
#if TT_REVRAW(CHAMBER)
#define TEMP_SENSOR_CHAMBER_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_CHAMBER_RAW_LO_TEMP 0
#else
#define HEATER_CHAMBER_RAW_HI_TEMP 0
#define HEATER_CHAMBER_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_CHAMBER_RAW_HI_TEMP 0
#define TEMP_SENSOR_CHAMBER_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#endif
#endif
#ifndef HEATER_PROBE_RAW_HI_TEMP
#if TT_REV(THERMISTORPROBE) || !HEATER_PROBE_USES_THERMISTOR
#define HEATER_PROBE_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define HEATER_PROBE_RAW_LO_TEMP 0
#ifndef TEMP_SENSOR_PROBE_RAW_HI_TEMP
#if TT_REVRAW(PROBE)
#define TEMP_SENSOR_PROBE_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_PROBE_RAW_LO_TEMP 0
#else
#define HEATER_PROBE_RAW_HI_TEMP 0
#define HEATER_PROBE_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_PROBE_RAW_HI_TEMP 0
#define TEMP_SENSOR_PROBE_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#endif
#endif
#undef _TT_REV
#undef TT_REV
#undef _TT_REVRAW
#undef TT_REVRAW

View file

@ -135,7 +135,7 @@
#define Y_STEP_PIN PE11
#define Y_DIR_PIN PE8
#define Y_ENABLE_PIN PD7
#ifndef Y_CS_PIN
#ifndef Y_CS_PIN
#define Y_CS_PIN PB8
#endif

View file

@ -235,7 +235,7 @@ HAS_L64XX = Arduino-L6470@0.8.0
src_filter=+<src/libs/L64XX> +<src/module/stepper/L64xx.cpp> +<src/gcode/feature/L6470> +<src/HAL/shared/HAL_spi_L6470.cpp>
NEOPIXEL_LED = Adafruit NeoPixel@1.5.0
src_filter=+<src/feature/leds/neopixel.cpp>
MAX6675_._IS_MAX31865 = Adafruit MAX31865 library@~1.1.0
TEMP_.+_IS_MAX31865 = Adafruit MAX31865 library@~1.1.0
USES_LIQUIDCRYSTAL = bitbucket-fmalpartida/LiquidCrystal@1.5.0
USES_LIQUIDCRYSTAL_I2C = marcoschwartz/LiquidCrystal_I2C@1.1.4
USES_LIQUIDTWI2 = LiquidTWI2@1.2.7