@ -56,13 +56,15 @@
# include "../feature/host_actions.h"
# endif
# define TEMP_SENSOR_IS_ANY_MAX_TC(n) (ENABLED(TEMP_SENSOR_##n##_IS_MAX_TC) || (ENABLED(TEMP_SENSOR_REDUNDANT_IS_MAX_TC) && ENABLED(TEMP_SENSOR_REDUNDANT_SOURCE) && TEMP_SENSOR_REDUNDANT_SOURCE == n))
// LIB_MAX31855 can be added to the build_flags in platformio.ini to use a user-defined library
# if LIB_USR_MAX31855
# include <Adafruit_MAX31855.h>
# if PIN_EXISTS(MAX31855_MISO) && PIN_EXISTS(MAX31855_SCK)
# define MAX31855_USES_SW_SPI 1
# endif
# if TEMP_SENSOR_ 0_ IS_MAX31855 && PIN_EXISTS(MAX31855_CS)
# if TEMP_SENSOR_ IS_MAX(0, MAX 31855) && PIN_EXISTS(MAX31855_CS)
# define HAS_MAX31855_TEMP 1
Adafruit_MAX31855 max31855_0 = Adafruit_MAX31855 ( MAX31855_CS_PIN
# if MAX31855_USES_SW_SPI
@ -73,7 +75,7 @@
# endif
) ;
# endif
# if TEMP_SENSOR_ 1_ IS_MAX31855 && PIN_EXISTS(MAX31855_CS2)
# if TEMP_SENSOR_ IS_MAX(1, MAX 31855) && PIN_EXISTS(MAX31855_CS2)
# define HAS_MAX31855_TEMP 1
Adafruit_MAX31855 max31855_1 = Adafruit_MAX31855 ( MAX31855_CS2_PIN
# if MAX31855_USES_SW_SPI
@ -96,7 +98,7 @@
# if PIN_EXISTS(MAX31865_MISO) && PIN_EXISTS(MAX31865_SCK)
# define MAX31865_USES_SW_SPI 1
# endif
# if TEMP_SENSOR_ 0_ IS_MAX31865 && PIN_EXISTS(MAX31865_CS)
# if TEMP_SENSOR_ IS_MAX(0, MAX 31865) && PIN_EXISTS(MAX31865_CS)
# define HAS_MAX31865_TEMP 1
Adafruit_MAX31865 max31865_0 = Adafruit_MAX31865 ( MAX31865_CS_PIN
# if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI)
@ -107,7 +109,7 @@
# endif
) ;
# endif
# if TEMP_SENSOR_ 1_ IS_MAX31865 && PIN_EXISTS(MAX31865_CS2)
# if TEMP_SENSOR_ IS_MAX(1, MAX 31865) && PIN_EXISTS(MAX31865_CS2)
# define HAS_MAX31865_TEMP 1
Adafruit_MAX31865 max31865_1 = Adafruit_MAX31865 ( MAX31865_CS2_PIN
# if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI)
@ -126,7 +128,7 @@
# if PIN_EXISTS(MAX6675_MISO) && PIN_EXISTS(MAX6675_SCK)
# define MAX6675_USES_SW_SPI 1
# endif
# if TEMP_SENSOR_ 0_ IS_MAX6675 && PIN_EXISTS(MAX6675_CS)
# if TEMP_SENSOR_ IS_MAX(0, MAX 6675) && PIN_EXISTS(MAX6675_CS)
# define HAS_MAX6675_TEMP 1
MAX6675 max6675_0 = MAX6675 ( MAX6675_CS_PIN
# if MAX6675_USES_SW_SPI
@ -137,7 +139,7 @@
# endif
) ;
# endif
# if TEMP_SENSOR_ 1_ IS_MAX6675 && PIN_EXISTS(MAX6675_CS2)
# if TEMP_SENSOR_ IS_MAX(1, MAX 6675) && PIN_EXISTS(MAX6675_CS2)
# define HAS_MAX6675_TEMP 1
MAX6675 max6675_1 = MAX6675 ( MAX6675_CS2_PIN
# if MAX6675_USES_SW_SPI
@ -154,7 +156,7 @@
# define NO_THERMO_TEMPS 1
# endif
# if (TEMP_SENSOR_0_IS_MAX_TC || TEMP_SENSOR_1_IS_MAX_TC ) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && NO_THERMO_TEMPS
# if (TEMP_SENSOR_0_IS_MAX_TC || TEMP_SENSOR_1_IS_MAX_TC || TEMP_SENSOR_REDUNDANT_IS_MAX_TC ) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && NO_THERMO_TEMPS
# define THERMO_SEPARATE_SPI 1
# endif
@ -210,15 +212,10 @@
# endif
# if HAS_HOTEND_THERMISTOR
# if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
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) ,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
# 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
Temperature thermalManager ;
@ -257,13 +254,14 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
# if HAS_HOTEND
hotend_info_t Temperature : : temp_hotend [ HOTENDS ] ;
# if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
temp_info_t Temperature : : temp_redundant ;
# endif
# define _HMT(N) HEATER_##N##_MAXTEMP,
const celsius_t Temperature : : hotend_maxtemp [ HOTENDS ] = ARRAY_BY_HOTENDS ( HEATER_0_MAXTEMP , HEATER_1_MAXTEMP , HEATER_2_MAXTEMP , HEATER_3_MAXTEMP , HEATER_4_MAXTEMP , HEATER_5_MAXTEMP , HEATER_6_MAXTEMP , HEATER_7_MAXTEMP ) ;
# endif
# if HAS_TEMP_REDUNDANT
redundant_temp_info_t Temperature : : temp_redundant ;
# endif
# if ENABLED(AUTO_POWER_E_FANS)
uint8_t Temperature : : autofan_speed [ HOTENDS ] ; // = { 0 }
# endif
@ -1219,8 +1217,12 @@ void Temperature::manage_heater() {
if ( degHotend ( 0 ) < _MAX ( HEATER_0_MINTEMP , TEMP_SENSOR_0_MAX_TC_TMIN + .01 ) ) min_temp_error ( H_E0 ) ;
# endif
# if TEMP_SENSOR_1_IS_MAX_TC
if ( TERN ( TEMP_SENSOR_1_AS_REDUNDANT , degHotendRedundant ( ) , degHotend ( 1 ) ) > _MIN ( HEATER_1_MAXTEMP , TEMP_SENSOR_1_MAX_TC_TMAX - 1.0 ) ) max_temp_error ( H_E1 ) ;
if ( TERN ( TEMP_SENSOR_1_AS_REDUNDANT , degHotendRedundant ( ) , degHotend ( 1 ) ) < _MAX ( HEATER_1_MINTEMP , TEMP_SENSOR_1_MAX_TC_TMIN + .01 ) ) min_temp_error ( H_E1 ) ;
if ( degHotend ( 1 ) > _MIN ( HEATER_1_MAXTEMP , TEMP_SENSOR_1_MAX_TC_TMAX - 1.0 ) ) max_temp_error ( H_E1 ) ;
if ( degHotend ( 1 ) < _MAX ( HEATER_1_MINTEMP , TEMP_SENSOR_1_MAX_TC_TMIN + .01 ) ) min_temp_error ( H_E1 ) ;
# endif
# if TEMP_SENSOR_REDUNDANT_IS_MAX_TC
if ( degRedundant ( ) > TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX - 1.0 ) max_temp_error ( H_REDUNDANT ) ;
if ( degRedundant ( ) < TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + .01 ) min_temp_error ( H_REDUNDANT ) ;
# endif
# endif
@ -1254,16 +1256,16 @@ void Temperature::manage_heater() {
}
# endif
# if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
// Make sure measured temperatures are close together
if ( ABS ( degHotend ( 0 ) - degHotendRedundant ( ) ) > MAX_REDUNDANT_TEMP_SENSOR_DIFF )
_temp_error ( H_E0 , PSTR ( STR_REDUNDANCY ) , GET_TEXT ( MSG_ERR_REDUNDANT_TEMP ) ) ;
# endif
} // HOTEND_LOOP
# endif // HAS_HOTEND
# if HAS_TEMP_REDUNDANT
// Make sure measured temperatures are close together
if ( ABS ( degRedundantTarget ( ) - degRedundant ( ) ) > TEMP_SENSOR_REDUNDANT_MAX_DIFF )
_temp_error ( ( heater_id_t ) TEMP_SENSOR_REDUNDANT_TARGET , PSTR ( STR_REDUNDANCY ) , GET_TEXT ( MSG_ERR_REDUNDANT_TEMP ) ) ;
# endif
# if HAS_AUTO_FAN
if ( ELAPSED ( ms , next_auto_fan_check_ms ) ) { // only need to check fan state very infrequently
checkExtruderAutoFans ( ) ;
@ -1613,13 +1615,16 @@ void Temperature::manage_heater() {
{ true , 0 , 0 , BED_PULLUP_RESISTOR_OHMS , BED_RESISTANCE_25C_OHMS , 0 , 0 , BED_BETA , 0 } ,
# endif
# if TEMP_SENSOR_CHAMBER_IS_CUSTOM
{ true , 0 , 0 , CHAMBER_PULLUP_RESISTOR_OHMS , CHAMBER_RESISTANCE_25C_OHMS , 0 , 0 , CHAMBER_BETA , 0 }
{ true , 0 , 0 , CHAMBER_PULLUP_RESISTOR_OHMS , CHAMBER_RESISTANCE_25C_OHMS , 0 , 0 , CHAMBER_BETA , 0 } ,
# endif
# if TEMP_SENSOR_COOLER_IS_CUSTOM
{ true , 0 , 0 , COOLER_PULLUP_RESISTOR_OHMS , COOLER_RESISTANCE_25C_OHMS , 0 , 0 , COOLER_BETA , 0 }
{ true , 0 , 0 , COOLER_PULLUP_RESISTOR_OHMS , COOLER_RESISTANCE_25C_OHMS , 0 , 0 , COOLER_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 }
{ true , 0 , 0 , PROBE_PULLUP_RESISTOR_OHMS , PROBE_RESISTANCE_25C_OHMS , 0 , 0 , PROBE_BETA , 0 } ,
# endif
# if TEMP_SENSOR_REDUNDANT_IS_CUSTOM
{ true , 0 , 0 , REDUNDANT_PULLUP_RESISTOR_OHMS , REDUNDANT_RESISTANCE_25C_OHMS , 0 , 0 , REDUNDANT_BETA , 0 } ,
# endif
} ;
COPY ( user_thermistor , default_user_thermistor ) ;
@ -1653,6 +1658,7 @@ void Temperature::manage_heater() {
TERN_ ( TEMP_SENSOR_CHAMBER_IS_CUSTOM , t_index = = CTI_CHAMBER ? PSTR ( " CHAMBER " ) : )
TERN_ ( TEMP_SENSOR_COOLER_IS_CUSTOM , t_index = = CTI_COOLER ? PSTR ( " COOLER " ) : )
TERN_ ( TEMP_SENSOR_PROBE_IS_CUSTOM , t_index = = CTI_PROBE ? PSTR ( " PROBE " ) : )
TERN_ ( TEMP_SENSOR_REDUNDANT_IS_CUSTOM , t_index = = CTI_REDUNDANT ? PSTR ( " REDUNDANT " ) : )
nullptr
) ;
SERIAL_EOL ( ) ;
@ -1708,7 +1714,7 @@ void Temperature::manage_heater() {
// Derived from RepRap FiveD extruder::getTemperature()
// For hot end temperature measurement.
celsius_float_t Temperature : : analog_to_celsius_hotend ( const int16_t raw , const uint8_t e ) {
if ( e > = HOTENDS + ENABLED ( TEMP_SENSOR_1_AS_REDUNDANT ) ) {
if ( e > = HOTENDS ) {
SERIAL_ERROR_START ( ) ;
SERIAL_ECHO ( e ) ;
SERIAL_ECHOLNPGM ( STR_INVALID_EXTRUDER_NUM ) ;
@ -1886,6 +1892,28 @@ void Temperature::manage_heater() {
}
# endif // HAS_TEMP_PROBE
# if HAS_TEMP_REDUNDANT
// For redundant temperature measurement.
celsius_float_t Temperature : : analog_to_celsius_redundant ( const int16_t raw ) {
# if TEMP_SENSOR_REDUNDANT_IS_CUSTOM
return user_thermistor_to_deg_c ( CTI_REDUNDANT , raw ) ;
# elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 0
return TERN ( TEMP_SENSOR_REDUNDANT_IS_MAX31865 , max31865_0 . temperature ( MAX31865_SENSOR_OHMS_0 , MAX31865_CALIBRATION_OHMS_0 ) , raw * 0.25 ) ;
# elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 1
return TERN ( TEMP_SENSOR_REDUNDANT_IS_MAX31865 , max31865_1 . temperature ( MAX31865_SENSOR_OHMS_1 , MAX31865_CALIBRATION_OHMS_1 ) , raw * 0.25 ) ;
# elif TEMP_SENSOR_REDUNDANT_IS_THERMISTOR
SCAN_THERMISTOR_TABLE ( TEMPTABLE_REDUNDANT , TEMPTABLE_REDUNDANT_LEN ) ;
# elif TEMP_SENSOR_REDUNDANT_IS_AD595
return TEMP_AD595 ( raw ) ;
# elif TEMP_SENSOR_REDUNDANT_IS_AD8495
return TEMP_AD8495 ( raw ) ;
# else
UNUSED ( raw ) ;
return 0 ;
# endif
}
# endif // HAS_TEMP_REDUNDANT
/**
* Convert the raw sensor readings into actual Celsius temperatures and
* validate raw temperatures . Bad readings generate min / maxtemp errors .
@ -1903,26 +1931,34 @@ void Temperature::updateTemperaturesFromRawValues() {
watchdog_refresh ( ) ; // Reset because raw_temps_ready was set by the interrupt
TERN_ ( TEMP_SENSOR_0_IS_MAX_TC , temp_hotend [ 0 ] . raw = READ_MAX_TC ( 0 ) ) ;
TERN_ ( TEMP_SENSOR_1_IS_MAX_TC , TERN ( TEMP_SENSOR_1_AS_REDUNDANT , temp_redundant , temp_hotend [ 1 ] ) . raw = READ_MAX_TC ( 1 ) ) ;
TERN_ ( TEMP_SENSOR_1_IS_MAX_TC , temp_hotend [ 1 ] . raw = READ_MAX_TC ( 1 ) ) ;
TERN_ ( TEMP_SENSOR_REDUNDANT_IS_MAX_TC , temp_redundant . raw = READ_MAX_TC ( TEMP_SENSOR_REDUNDANT_SOURCE ) ) ;
# if HAS_HOTEND
HOTEND_LOOP ( ) temp_hotend [ e ] . celsius = analog_to_celsius_hotend ( temp_hotend [ e ] . raw , e ) ;
# endif
TERN_ ( TEMP_SENSOR_1_AS_REDUNDANT , temp_redundant . celsius = analog_to_celsius_hotend ( temp_redundant . raw , 1 ) ) ;
TERN_ ( HAS_HEATED_BED , temp_bed . celsius = analog_to_celsius_bed ( temp_bed . raw ) ) ;
TERN_ ( HAS_TEMP_CHAMBER , temp_chamber . celsius = analog_to_celsius_chamber ( temp_chamber . raw ) ) ;
TERN_ ( HAS_TEMP_COOLER , temp_cooler . celsius = analog_to_celsius_cooler ( temp_cooler . raw ) ) ;
TERN_ ( HAS_TEMP_PROBE , temp_probe . celsius = analog_to_celsius_probe ( temp_probe . raw ) ) ;
TERN_ ( HAS_HEATED_BED , temp_bed . celsius = analog_to_celsius_bed ( temp_bed . raw ) ) ;
TERN_ ( HAS_TEMP_CHAMBER , temp_chamber . celsius = analog_to_celsius_chamber ( temp_chamber . raw ) ) ;
TERN_ ( HAS_TEMP_COOLER , temp_cooler . celsius = analog_to_celsius_cooler ( temp_cooler . raw ) ) ;
TERN_ ( HAS_TEMP_PROBE , temp_probe . celsius = analog_to_celsius_probe ( temp_probe . raw ) ) ;
TERN_ ( HAS_TEMP_REDUNDANT , temp_redundant . celsius = analog_to_celsius_redundant ( temp_redundant . raw ) ) ;
TERN_ ( FILAMENT_WIDTH_SENSOR , filwidth . update_measured_mm ( ) ) ;
TERN_ ( HAS_POWER_MONITOR , power_monitor . capture_values ( ) ) ;
# if HAS_HOTEND
static constexpr int8_t temp_dir [ ] = {
TERN ( TEMP_SENSOR_0_IS_MAX_TC , 0 , TEMPDIR ( 0 ) )
# if TEMP_SENSOR_IS_ANY_MAX_TC(0)
0
# else
TEMPDIR ( 0 )
# endif
# if HAS_MULTI_HOTEND
, TERN ( TEMP_SENSOR_1_IS_MAX_TC , 0 , TEMPDIR ( 1 ) )
# if TEMP_SENSOR_IS_ANY_MAX_TC(1)
, 0
# else
, TEMPDIR ( 1 )
# endif
# if HOTENDS > 2
# define _TEMPDIR(N) , TEMPDIR(N)
REPEAT_S ( 2 , HOTENDS , _TEMPDIR )
@ -2031,42 +2067,42 @@ void Temperature::init() {
# endif
// Init (and disable) SPI thermocouples
# if TEMP_SENSOR_ 0_ IS_MAX6675 && PIN_EXISTS(MAX6675_CS)
# if TEMP_SENSOR_ IS_MAX(0, MAX 6675) && PIN_EXISTS(MAX6675_CS)
OUT_WRITE ( MAX6675_CS_PIN , HIGH ) ;
# endif
# if TEMP_SENSOR_ 1_ IS_MAX6675 && PIN_EXISTS(MAX6675_CS2)
# if TEMP_SENSOR_ IS_MAX(1, MAX 6675) && PIN_EXISTS(MAX6675_CS2)
OUT_WRITE ( MAX6675_CS2_PIN , HIGH ) ;
# endif
# if TEMP_SENSOR_ 0_ IS_MAX6675 && PIN_EXISTS(MAX31855_CS)
# if TEMP_SENSOR_ IS_MAX(0, MAX 6675) && PIN_EXISTS(MAX31855_CS)
OUT_WRITE ( MAX31855_CS_PIN , HIGH ) ;
# endif
# if TEMP_SENSOR_ 1_ IS_MAX6675 && PIN_EXISTS(MAX31855_CS2)
# if TEMP_SENSOR_ IS_MAX(1, MAX 6675) && PIN_EXISTS(MAX31855_CS2)
OUT_WRITE ( MAX31855_CS2_PIN , HIGH ) ;
# endif
# if TEMP_SENSOR_ 0_ IS_MAX6675 && PIN_EXISTS(MAX31865_CS)
# if TEMP_SENSOR_ IS_MAX(0, MAX 6675) && PIN_EXISTS(MAX31865_CS)
OUT_WRITE ( MAX31865_CS_PIN , HIGH ) ;
# endif
# if TEMP_SENSOR_ 1_ IS_MAX6675 && PIN_EXISTS(MAX31865_CS2)
# if TEMP_SENSOR_ IS_MAX(1, MAX 6675) && PIN_EXISTS(MAX31865_CS2)
OUT_WRITE ( MAX31865_CS2_PIN , HIGH ) ;
# endif
# if HAS_MAX31865_TEMP
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 ) ) ;
TERN_ ( TEMP_SENSOR_ IS_MAX( 0 , MAX 31865) , max31865_0 . begin ( MAX31865_2WIRE ) ) ; // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE
TERN_ ( TEMP_SENSOR_ IS_MAX( 1 , MAX 31865) , max31865_1 . begin ( MAX31865_2WIRE ) ) ;
# endif
# if HAS_MAX31855_TEMP
TERN_ ( TEMP_SENSOR_ 0_ IS_MAX31855, max31855_0 . begin ( ) ) ;
TERN_ ( TEMP_SENSOR_ 1_ IS_MAX31855, max31855_1 . begin ( ) ) ;
TERN_ ( TEMP_SENSOR_ IS_MAX( 0 , MAX 31855) , max31855_0 . begin ( ) ) ;
TERN_ ( TEMP_SENSOR_ IS_MAX( 1 , MAX 31855) , max31855_1 . begin ( ) ) ;
# endif
# if HAS_MAX6675_TEMP
TERN_ ( TEMP_SENSOR_ 0_ IS_MAX6675, max6675_0 . begin ( ) ) ;
TERN_ ( TEMP_SENSOR_ 1_ IS_MAX6675, max6675_1 . begin ( ) ) ;
TERN_ ( TEMP_SENSOR_ IS_MAX( 0 , MAX 6675) , max6675_0 . begin ( ) ) ;
TERN_ ( TEMP_SENSOR_ IS_MAX( 1 , MAX 6675) , max6675_1 . begin ( ) ) ;
# endif
# if MB(RUMBA)
// Disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector
# define _AD(N) (TEMP_SENSOR_##N##_IS_AD595 || TEMP_SENSOR_##N##_IS_AD8495)
# if _AD(0) || _AD(1) || _AD(2) || _AD(BED) || _AD(CHAMBER)
# if _AD(0) || _AD(1) || _AD(2) || _AD(BED) || _AD(CHAMBER) || _AD(REDUNDANT)
MCUCR = _BV ( JTD ) ;
MCUCR = _BV ( JTD ) ;
# endif
@ -2074,10 +2110,22 @@ void Temperature::init() {
// Thermistor activation by MCU pin
# if PIN_EXISTS(TEMP_0_TR_ENABLE)
OUT_WRITE ( TEMP_0_TR_ENABLE_PIN , ENABLED ( TEMP_SENSOR_0_IS_MAX_TC ) ) ;
OUT_WRITE ( TEMP_0_TR_ENABLE_PIN ,
# if TEMP_SENSOR_IS_ANY_MAX_TC(0)
1
# else
0
# endif
) ;
# endif
# if PIN_EXISTS(TEMP_1_TR_ENABLE)
OUT_WRITE ( TEMP_1_TR_ENABLE_PIN , ENABLED ( TEMP_SENSOR_1_IS_MAX_TC ) ) ;
OUT_WRITE ( TEMP_1_TR_ENABLE_PIN ,
# if TEMP_SENSOR_IS_ANY_MAX_TC(1)
1
# else
0
# endif
) ;
# endif
# if HAS_HEATER_0
@ -2206,6 +2254,9 @@ void Temperature::init() {
# if HAS_TEMP_ADC_PROBE
HAL_ANALOG_SELECT ( TEMP_PROBE_PIN ) ;
# endif
# if HAS_TEMP_ADC_REDUNDANT
HAL_ANALOG_SELECT ( TEMP_REDUNDANT_PIN ) ;
# endif
# if ENABLED(FILAMENT_WIDTH_SENSOR)
HAL_ANALOG_SELECT ( FILWIDTH_PIN ) ;
# endif
@ -2268,7 +2319,7 @@ void Temperature::init() {
temp_range [ NR ] . raw_max - = TEMPDIR ( NR ) * ( OVERSAMPLENR ) ; \
} while ( 0 )
# 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))
# define _MINMAX_TEST(N,M) (HOTENDS > N && TEMP_SENSOR_ ##N > 0 && TEMP_SENSOR_##N != 998 && TEMP_SENSOR_##N != 999 && defined(HEATER_##N##_##M##TEMP))
# if _MINMAX_TEST(0, MIN)
_TEMP_MIN_E ( 0 ) ;
@ -2335,6 +2386,22 @@ void Temperature::init() {
while ( analog_to_celsius_cooler ( mintemp_raw_COOLER ) > COOLER_MINTEMP ) mintemp_raw_COOLER + = TEMPDIR ( COOLER ) * ( OVERSAMPLENR ) ;
while ( analog_to_celsius_cooler ( maxtemp_raw_COOLER ) < COOLER_MAXTEMP ) maxtemp_raw_COOLER - = TEMPDIR ( COOLER ) * ( OVERSAMPLENR ) ;
# endif
# if HAS_TEMP_REDUNDANT
temp_redundant . target = & (
# if TEMP_SENSOR_REDUNDANT_TARGET == -5 && HAS_TEMP_COOLER
temp_cooler
# elif TEMP_SENSOR_REDUNDANT_TARGET == -4 && HAS_TEMP_PROBE
temp_probe
# elif TEMP_SENSOR_REDUNDANT_TARGET == -2 && HAS_TEMP_CHAMBER
temp_chamber
# elif TEMP_SENSOR_REDUNDANT_TARGET == -1 && HAS_TEMP_BED
temp_bed
# else
temp_hotend [ TEMP_SENSOR_REDUNDANT_TARGET ]
# endif
) ;
# endif
}
# if HAS_THERMAL_PROTECTION
@ -2373,7 +2440,7 @@ void Temperature::init() {
, " ; Idle Timeout: " , heater_idle [ idle_index ] . timed_out
# endif
) ;
//*/
*/
# if HEATER_IDLE_HANDLER
// If the heater idle timeout expires, restart
@ -2570,12 +2637,12 @@ void Temperature::disable_all_heaters() {
# else
constexpr uint8_t hindex = 0 ;
# define THERMO_TEMP(I) max_tc_temp
# if TEMP_SENSOR_ 1_IS_MAX31865
# if TEMP_SENSOR_ IS_ANY_MAX_TC(1)
# define THERMO_SEL(A,B) B
# else
# define THERMO_SEL(A,B) A
# endif
# if TEMP_SENSOR_ 0_ IS_MAX6675
# if TEMP_SENSOR_ IS_MAX(0, MAX 6675)
# define MAX6675_WRITE(V) WRITE(MAX6675_SS_PIN, V)
# define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS_PIN)
# else
@ -2723,12 +2790,12 @@ void Temperature::update_raw_temperatures() {
temp_hotend [ 0 ] . update ( ) ;
# endif
# if HAS_TEMP_ADC_1
# if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
temp_redundant . update ( ) ;
# elif !TEMP_SENSOR_1_IS_MAX_TC
temp_hotend [ 1 ] . update ( ) ;
# endif
# if HAS_TEMP_ADC_1 && !TEMP_SENSOR_1_IS_MAX_TC
temp_hotend [ 1 ] . update ( ) ;
# endif
# if HAS_TEMP_ADC_REDUNDANT && !TEMP_SENSOR_REDUNDANT_IS_MAX_TC
temp_redundant . update ( ) ;
# endif
TERN_ ( HAS_TEMP_ADC_2 , temp_hotend [ 2 ] . update ( ) ) ;
@ -2764,13 +2831,13 @@ void Temperature::readings_ready() {
# if HAS_HOTEND
HOTEND_LOOP ( ) temp_hotend [ e ] . reset ( ) ;
TERN_ ( TEMP_SENSOR_1_AS_REDUNDANT , temp_redundant . reset ( ) ) ;
# endif
TERN_ ( HAS_HEATED_BED , temp_bed . reset ( ) ) ;
TERN_ ( HAS_TEMP_CHAMBER , temp_chamber . reset ( ) ) ;
TERN_ ( HAS_TEMP_PROBE , temp_probe . reset ( ) ) ;
TERN_ ( HAS_TEMP_COOLER , temp_cooler . reset ( ) ) ;
TERN_ ( HAS_TEMP_REDUNDANT , temp_redundant . reset ( ) ) ;
TERN_ ( HAS_JOY_ADC_X , joystick . x . reset ( ) ) ;
TERN_ ( HAS_JOY_ADC_Y , joystick . y . reset ( ) ) ;
@ -3196,9 +3263,14 @@ void Temperature::isr() {
case MeasureTemp_PROBE : ACCUMULATE_ADC ( temp_probe ) ; break ;
# endif
# if HAS_TEMP_ADC_REDUNDANT
case PrepareTemp_REDUNDANT : HAL_START_ADC ( TEMP_REDUNDANT_PIN ) ; break ;
case MeasureTemp_REDUNDANT : ACCUMULATE_ADC ( temp_redundant ) ; break ;
# endif
# if HAS_TEMP_ADC_1
case PrepareTemp_1 : HAL_START_ADC ( TEMP_1_PIN ) ; break ;
case MeasureTemp_1 : ACCUMULATE_ADC ( TERN ( TEMP_SENSOR_1_AS_REDUNDANT , temp_redundant , temp_hotend [ 1 ] ) ) ; break ;
case MeasureTemp_1 : ACCUMULATE_ADC ( temp_hotend[ 1 ] ) ; break ;
# endif
# if HAS_TEMP_ADC_2
@ -3332,6 +3404,7 @@ void Temperature::isr() {
* Chamber : " C:nnn.nn /nnn.nn "
* Probe : " P:nnn.nn /nnn.nn "
* Cooler : " L:nnn.nn /nnn.nn "
* Redundant : " R:nnn.nn /nnn.nn "
* Extruder : " T0:nnn.nn /nnn.nn "
* With ADC : " T0:nnn.nn /nnn.nn (nnn.nn) "
*/
@ -3356,7 +3429,7 @@ void Temperature::isr() {
# if HAS_TEMP_COOLER
case H_COOLER : k = ' L ' ; break ;
# endif
# if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
# if HAS_TEMP_REDUNDANT
case H_REDUNDANT : k = ' R ' ; break ;
# endif
}
@ -3382,13 +3455,10 @@ void Temperature::isr() {
}
void Temperature : : print_heater_states ( const uint8_t target_extruder
OPTARG ( TEMP_SENSOR_1_AS _REDUNDANT, const bool include_r /*=false*/ )
OPTARG ( HAS_ TEMP_REDUNDANT, const bool include_r /*=false*/ )
) {
# if HAS_TEMP_HOTEND
print_heater_state ( H_NONE , degHotend ( target_extruder ) , degTargetHotend ( target_extruder ) OPTARG ( SHOW_TEMP_ADC_VALUES , rawHotendTemp ( target_extruder ) ) ) ;
# if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
if ( include_r ) print_heater_state ( H_REDUNDANT , degHotendRedundant ( ) , degTargetHotend ( 0 ) OPTARG ( SHOW_TEMP_ADC_VALUES , rawHotendTempRedundant ( ) ) ) ;
# endif
# endif
# if HAS_HEATED_BED
print_heater_state ( H_BED , degBed ( ) , degTargetBed ( ) OPTARG ( SHOW_TEMP_ADC_VALUES , rawBedTemp ( ) ) ) ;
@ -3402,6 +3472,9 @@ void Temperature::isr() {
# if HAS_TEMP_PROBE
print_heater_state ( H_PROBE , degProbe ( ) , 0 OPTARG ( SHOW_TEMP_ADC_VALUES , rawProbeTemp ( ) ) ) ;
# endif
# if HAS_TEMP_REDUNDANT
if ( include_r ) print_heater_state ( H_REDUNDANT , degRedundant ( ) , degRedundantTarget ( ) OPTARG ( SHOW_TEMP_ADC_VALUES , rawRedundantTemp ( ) ) ) ;
# endif
# if HAS_MULTI_HOTEND
HOTEND_LOOP ( ) print_heater_state ( ( heater_id_t ) e , degHotend ( e ) , degTargetHotend ( e ) OPTARG ( SHOW_TEMP_ADC_VALUES , rawHotendTemp ( e ) ) ) ;
# endif