|
|
@ -437,8 +437,8 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); |
|
|
|
#if HAS_HEATED_BED |
|
|
|
bed_info_t Temperature::temp_bed; // = { 0 }
|
|
|
|
// Init min and max temp with extreme values to prevent false errors during startup
|
|
|
|
int16_t Temperature::mintemp_raw_BED = TEMP_SENSOR_BED_RAW_LO_TEMP, |
|
|
|
Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP; |
|
|
|
raw_adc_t Temperature::mintemp_raw_BED = TEMP_SENSOR_BED_RAW_LO_TEMP, |
|
|
|
Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP; |
|
|
|
TERN_(WATCH_BED, bed_watch_t Temperature::watch_bed); // = { 0 }
|
|
|
|
IF_DISABLED(PIDTEMPBED, millis_t Temperature::next_bed_check_ms); |
|
|
|
#endif |
|
|
@ -448,8 +448,8 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); |
|
|
|
#if HAS_HEATED_CHAMBER |
|
|
|
millis_t next_cool_check_ms_2 = 0; |
|
|
|
celsius_float_t old_temp = 9999; |
|
|
|
int16_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP, |
|
|
|
Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP; |
|
|
|
raw_adc_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP, |
|
|
|
Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP; |
|
|
|
TERN_(WATCH_CHAMBER, chamber_watch_t Temperature::watch_chamber{0}); |
|
|
|
IF_DISABLED(PIDTEMPCHAMBER, millis_t Temperature::next_chamber_check_ms); |
|
|
|
#endif |
|
|
@ -461,8 +461,8 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); |
|
|
|
bool flag_cooler_state; |
|
|
|
//bool flag_cooler_excess = false;
|
|
|
|
celsius_float_t previous_temp = 9999; |
|
|
|
int16_t Temperature::mintemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_LO_TEMP, |
|
|
|
Temperature::maxtemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_HI_TEMP; |
|
|
|
raw_adc_t Temperature::mintemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_LO_TEMP, |
|
|
|
Temperature::maxtemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_HI_TEMP; |
|
|
|
#if WATCH_COOLER |
|
|
|
cooler_watch_t Temperature::watch_cooler{0}; |
|
|
|
#endif |
|
|
@ -477,8 +477,8 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); |
|
|
|
#if HAS_TEMP_BOARD |
|
|
|
board_info_t Temperature::temp_board; // = { 0 }
|
|
|
|
#if ENABLED(THERMAL_PROTECTION_BOARD) |
|
|
|
int16_t Temperature::mintemp_raw_BOARD = TEMP_SENSOR_BOARD_RAW_LO_TEMP, |
|
|
|
Temperature::maxtemp_raw_BOARD = TEMP_SENSOR_BOARD_RAW_HI_TEMP; |
|
|
|
raw_adc_t Temperature::mintemp_raw_BOARD = TEMP_SENSOR_BOARD_RAW_LO_TEMP, |
|
|
|
Temperature::maxtemp_raw_BOARD = TEMP_SENSOR_BOARD_RAW_HI_TEMP; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
@ -508,6 +508,7 @@ volatile bool Temperature::raw_temps_ready = false; |
|
|
|
#endif |
|
|
|
|
|
|
|
#define TEMPDIR(N) ((TEMP_SENSOR_##N##_RAW_LO_TEMP) < (TEMP_SENSOR_##N##_RAW_HI_TEMP) ? 1 : -1) |
|
|
|
#define TP_CMP(S,A,B) (TEMPDIR(S) < 0 ? ((A)<(B)) : ((A)>(B))) |
|
|
|
|
|
|
|
#if HAS_HOTEND |
|
|
|
// Init mintemp and maxtemp with extreme values to prevent false errors during startup
|
|
|
@ -1689,8 +1690,8 @@ void Temperature::manage_heater() { |
|
|
|
m = (l + r) >> 1; \ |
|
|
|
if (!m) return celsius_t(pgm_read_word(&TBL[0].celsius)); \ |
|
|
|
if (m == l || m == r) return celsius_t(pgm_read_word(&TBL[LEN-1].celsius)); \ |
|
|
|
int16_t v00 = pgm_read_word(&TBL[m-1].value), \ |
|
|
|
v10 = pgm_read_word(&TBL[m-0].value); \ |
|
|
|
raw_adc_t v00 = pgm_read_word(&TBL[m-1].value), \ |
|
|
|
v10 = pgm_read_word(&TBL[m-0].value); \ |
|
|
|
if (raw < v00) r = m; \ |
|
|
|
else if (raw > v10) l = m; \ |
|
|
|
else { \ |
|
|
@ -1784,7 +1785,7 @@ void Temperature::manage_heater() { |
|
|
|
SERIAL_EOL(); |
|
|
|
} |
|
|
|
|
|
|
|
celsius_float_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int16_t raw) { |
|
|
|
celsius_float_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const raw_adc_t raw) { |
|
|
|
|
|
|
|
if (!WITHIN(t_index, 0, COUNT(user_thermistor) - 1)) return 25; |
|
|
|
|
|
|
@ -1799,8 +1800,8 @@ void Temperature::manage_heater() { |
|
|
|
} |
|
|
|
|
|
|
|
// maximum adc value .. take into account the over sampling
|
|
|
|
const int adc_max = MAX_RAW_THERMISTOR_VALUE, |
|
|
|
adc_raw = constrain(raw, 1, adc_max - 1); // constrain to prevent divide-by-zero
|
|
|
|
constexpr raw_adc_t adc_max = MAX_RAW_THERMISTOR_VALUE; |
|
|
|
const raw_adc_t adc_raw = constrain(raw, 1, adc_max - 1); // constrain to prevent divide-by-zero
|
|
|
|
|
|
|
|
const float adc_inverse = (adc_max - adc_raw) - 0.5f, |
|
|
|
resistance = t.series_res * (adc_raw + 0.5f) / adc_inverse, |
|
|
@ -1820,7 +1821,7 @@ void Temperature::manage_heater() { |
|
|
|
#if HAS_HOTEND |
|
|
|
// 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) { |
|
|
|
celsius_float_t Temperature::analog_to_celsius_hotend(const raw_adc_t raw, const uint8_t e) { |
|
|
|
if (e >= HOTENDS) { |
|
|
|
SERIAL_ERROR_START(); |
|
|
|
SERIAL_ECHO(e); |
|
|
@ -1836,11 +1837,11 @@ void Temperature::manage_heater() { |
|
|
|
#elif TEMP_SENSOR_0_IS_MAX_TC |
|
|
|
#if TEMP_SENSOR_0_IS_MAX31865 |
|
|
|
return TERN(LIB_INTERNAL_MAX31865, |
|
|
|
max31865_0.temperature((uint16_t)raw), |
|
|
|
max31865_0.temperature(raw), |
|
|
|
max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0) |
|
|
|
); |
|
|
|
#else |
|
|
|
return raw * 0.25; |
|
|
|
return (int16_t)raw * 0.25; |
|
|
|
#endif |
|
|
|
#elif TEMP_SENSOR_0_IS_AD595 |
|
|
|
return TEMP_AD595(raw); |
|
|
@ -1855,11 +1856,11 @@ void Temperature::manage_heater() { |
|
|
|
#elif TEMP_SENSOR_1_IS_MAX_TC |
|
|
|
#if TEMP_SENSOR_0_IS_MAX31865 |
|
|
|
return TERN(LIB_INTERNAL_MAX31865, |
|
|
|
max31865_1.temperature((uint16_t)raw), |
|
|
|
max31865_1.temperature(raw), |
|
|
|
max31865_1.temperature(MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1) |
|
|
|
); |
|
|
|
#else |
|
|
|
return raw * 0.25; |
|
|
|
return (int16_t)raw * 0.25; |
|
|
|
#endif |
|
|
|
#elif TEMP_SENSOR_1_IS_AD595 |
|
|
|
return TEMP_AD595(raw); |
|
|
@ -1943,7 +1944,7 @@ void Temperature::manage_heater() { |
|
|
|
|
|
|
|
#if HAS_HEATED_BED |
|
|
|
// For bed temperature measurement.
|
|
|
|
celsius_float_t Temperature::analog_to_celsius_bed(const int16_t raw) { |
|
|
|
celsius_float_t Temperature::analog_to_celsius_bed(const raw_adc_t raw) { |
|
|
|
#if TEMP_SENSOR_BED_IS_CUSTOM |
|
|
|
return user_thermistor_to_deg_c(CTI_BED, raw); |
|
|
|
#elif TEMP_SENSOR_BED_IS_THERMISTOR |
|
|
@ -1961,7 +1962,7 @@ void Temperature::manage_heater() { |
|
|
|
|
|
|
|
#if HAS_TEMP_CHAMBER |
|
|
|
// For chamber temperature measurement.
|
|
|
|
celsius_float_t Temperature::analog_to_celsius_chamber(const int16_t raw) { |
|
|
|
celsius_float_t Temperature::analog_to_celsius_chamber(const raw_adc_t raw) { |
|
|
|
#if TEMP_SENSOR_CHAMBER_IS_CUSTOM |
|
|
|
return user_thermistor_to_deg_c(CTI_CHAMBER, raw); |
|
|
|
#elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR |
|
|
@ -1979,7 +1980,7 @@ void Temperature::manage_heater() { |
|
|
|
|
|
|
|
#if HAS_TEMP_COOLER |
|
|
|
// For cooler temperature measurement.
|
|
|
|
celsius_float_t Temperature::analog_to_celsius_cooler(const int16_t raw) { |
|
|
|
celsius_float_t Temperature::analog_to_celsius_cooler(const raw_adc_t raw) { |
|
|
|
#if TEMP_SENSOR_COOLER_IS_CUSTOM |
|
|
|
return user_thermistor_to_deg_c(CTI_COOLER, raw); |
|
|
|
#elif TEMP_SENSOR_COOLER_IS_THERMISTOR |
|
|
@ -1997,7 +1998,7 @@ void Temperature::manage_heater() { |
|
|
|
|
|
|
|
#if HAS_TEMP_PROBE |
|
|
|
// For probe temperature measurement.
|
|
|
|
celsius_float_t Temperature::analog_to_celsius_probe(const int16_t raw) { |
|
|
|
celsius_float_t Temperature::analog_to_celsius_probe(const raw_adc_t raw) { |
|
|
|
#if TEMP_SENSOR_PROBE_IS_CUSTOM |
|
|
|
return user_thermistor_to_deg_c(CTI_PROBE, raw); |
|
|
|
#elif TEMP_SENSOR_PROBE_IS_THERMISTOR |
|
|
@ -2015,7 +2016,7 @@ void Temperature::manage_heater() { |
|
|
|
|
|
|
|
#if HAS_TEMP_BOARD |
|
|
|
// For motherboard temperature measurement.
|
|
|
|
celsius_float_t Temperature::analog_to_celsius_board(const int16_t raw) { |
|
|
|
celsius_float_t Temperature::analog_to_celsius_board(const raw_adc_t raw) { |
|
|
|
#if TEMP_SENSOR_BOARD_IS_CUSTOM |
|
|
|
return user_thermistor_to_deg_c(CTI_BOARD, raw); |
|
|
|
#elif TEMP_SENSOR_BOARD_IS_THERMISTOR |
|
|
@ -2033,13 +2034,13 @@ void Temperature::manage_heater() { |
|
|
|
|
|
|
|
#if HAS_TEMP_REDUNDANT |
|
|
|
// For redundant temperature measurement.
|
|
|
|
celsius_float_t Temperature::analog_to_celsius_redundant(const int16_t raw) { |
|
|
|
celsius_float_t Temperature::analog_to_celsius_redundant(const raw_adc_t raw) { |
|
|
|
#if TEMP_SENSOR_REDUNDANT_IS_CUSTOM |
|
|
|
return user_thermistor_to_deg_c(CTI_REDUNDANT, raw); |
|
|
|
#elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E0) |
|
|
|
return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_0.temperature((uint16_t)raw), raw * 0.25); |
|
|
|
return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_0.temperature(raw), (int16_t)raw * 0.25); |
|
|
|
#elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1) |
|
|
|
return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_1.temperature((uint16_t)raw), raw * 0.25); |
|
|
|
return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_1.temperature(raw), (int16_t)raw * 0.25); |
|
|
|
#elif TEMP_SENSOR_REDUNDANT_IS_THERMISTOR |
|
|
|
SCAN_THERMISTOR_TABLE(TEMPTABLE_REDUNDANT, TEMPTABLE_REDUNDANT_LEN); |
|
|
|
#elif TEMP_SENSOR_REDUNDANT_IS_AD595 |
|
|
@ -2069,20 +2070,20 @@ 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, temp_hotend[1].raw = READ_MAX_TC(1)); |
|
|
|
TERN_(TEMP_SENSOR_REDUNDANT_IS_MAX_TC, temp_redundant.raw = READ_MAX_TC(HEATER_ID(TEMP_SENSOR_REDUNDANT_SOURCE))); |
|
|
|
TERN_(TEMP_SENSOR_0_IS_MAX_TC, temp_hotend[0].setraw(READ_MAX_TC(0))); |
|
|
|
TERN_(TEMP_SENSOR_1_IS_MAX_TC, temp_hotend[1].setraw(READ_MAX_TC(1))); |
|
|
|
TERN_(TEMP_SENSOR_REDUNDANT_IS_MAX_TC, temp_redundant.setraw(READ_MAX_TC(HEATER_ID(TEMP_SENSOR_REDUNDANT_SOURCE)))); |
|
|
|
|
|
|
|
#if HAS_HOTEND |
|
|
|
HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].raw, e); |
|
|
|
HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].getraw(), e); |
|
|
|
#endif |
|
|
|
|
|
|
|
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_BOARD, temp_board.celsius = analog_to_celsius_board(temp_board.raw)); |
|
|
|
TERN_(HAS_TEMP_REDUNDANT, temp_redundant.celsius = analog_to_celsius_redundant(temp_redundant.raw)); |
|
|
|
TERN_(HAS_HEATED_BED, temp_bed.celsius = analog_to_celsius_bed(temp_bed.getraw())); |
|
|
|
TERN_(HAS_TEMP_CHAMBER, temp_chamber.celsius = analog_to_celsius_chamber(temp_chamber.getraw())); |
|
|
|
TERN_(HAS_TEMP_COOLER, temp_cooler.celsius = analog_to_celsius_cooler(temp_cooler.getraw())); |
|
|
|
TERN_(HAS_TEMP_PROBE, temp_probe.celsius = analog_to_celsius_probe(temp_probe.getraw())); |
|
|
|
TERN_(HAS_TEMP_BOARD, temp_board.celsius = analog_to_celsius_board(temp_board.getraw())); |
|
|
|
TERN_(HAS_TEMP_REDUNDANT, temp_redundant.celsius = analog_to_celsius_redundant(temp_redundant.getraw())); |
|
|
|
|
|
|
|
TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_measured_mm()); |
|
|
|
TERN_(HAS_POWER_MONITOR, power_monitor.capture_values()); |
|
|
@ -2108,46 +2109,45 @@ void Temperature::updateTemperaturesFromRawValues() { |
|
|
|
}; |
|
|
|
|
|
|
|
LOOP_L_N(e, COUNT(temp_dir)) { |
|
|
|
const int8_t tdir = temp_dir[e]; |
|
|
|
if (tdir) { |
|
|
|
const int16_t rawtemp = temp_hotend[e].raw * tdir; // normal direction, +rawtemp, else -rawtemp
|
|
|
|
if (rawtemp > temp_range[e].raw_max * tdir) max_temp_error((heater_id_t)e); |
|
|
|
|
|
|
|
const bool heater_on = temp_hotend[e].target > 0; |
|
|
|
if (heater_on && rawtemp < temp_range[e].raw_min * tdir && !is_preheating(e)) { |
|
|
|
#if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 |
|
|
|
if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED) |
|
|
|
#endif |
|
|
|
min_temp_error((heater_id_t)e); |
|
|
|
} |
|
|
|
const raw_adc_t r = temp_hotend[e].getraw(); |
|
|
|
const bool neg = temp_dir[e] < 0, pos = temp_dir[e] > 0; |
|
|
|
if ((neg && r < temp_range[e].raw_max) || (pos && r > temp_range[e].raw_max)) |
|
|
|
max_temp_error((heater_id_t)e); |
|
|
|
|
|
|
|
const bool heater_on = temp_hotend[e].target > 0; |
|
|
|
if (heater_on && ((neg && r > temp_range[e].raw_min) || (pos && r < temp_range[e].raw_min))) { |
|
|
|
#if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 |
|
|
|
else |
|
|
|
consecutive_low_temperature_error[e] = 0; |
|
|
|
if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED) |
|
|
|
#endif |
|
|
|
min_temp_error((heater_id_t)e); |
|
|
|
} |
|
|
|
#if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 |
|
|
|
else |
|
|
|
consecutive_low_temperature_error[e] = 0; |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
#endif // HAS_HOTEND
|
|
|
|
|
|
|
|
#define TP_CMP(S,A,B) (TEMPDIR(S) < 0 ? ((A)<(B)) : ((A)>(B))) |
|
|
|
#if ENABLED(THERMAL_PROTECTION_BED) |
|
|
|
if (TP_CMP(BED, temp_bed.raw, maxtemp_raw_BED)) max_temp_error(H_BED); |
|
|
|
if (temp_bed.target > 0 && TP_CMP(BED, mintemp_raw_BED, temp_bed.raw)) min_temp_error(H_BED); |
|
|
|
if (TP_CMP(BED, temp_bed.getraw(), maxtemp_raw_BED)) max_temp_error(H_BED); |
|
|
|
if (temp_bed.target > 0 && TP_CMP(BED, mintemp_raw_BED, temp_bed.getraw())) min_temp_error(H_BED); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if BOTH(HAS_HEATED_CHAMBER, THERMAL_PROTECTION_CHAMBER) |
|
|
|
if (TP_CMP(CHAMBER, temp_chamber.raw, maxtemp_raw_CHAMBER)) max_temp_error(H_CHAMBER); |
|
|
|
if (temp_chamber.target > 0 && TP_CMP(CHAMBER, mintemp_raw_CHAMBER, temp_chamber.raw)) min_temp_error(H_CHAMBER); |
|
|
|
if (TP_CMP(CHAMBER, temp_chamber.getraw(), maxtemp_raw_CHAMBER)) max_temp_error(H_CHAMBER); |
|
|
|
if (temp_chamber.target > 0 && TP_CMP(CHAMBER, mintemp_raw_CHAMBER, temp_chamber.getraw())) min_temp_error(H_CHAMBER); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if BOTH(HAS_COOLER, THERMAL_PROTECTION_COOLER) |
|
|
|
if (cutter.unitPower > 0 && TP_CMP(COOLER, temp_cooler.raw, maxtemp_raw_COOLER)) max_temp_error(H_COOLER); |
|
|
|
if (TP_CMP(COOLER, mintemp_raw_COOLER, temp_cooler.raw)) min_temp_error(H_COOLER); |
|
|
|
if (cutter.unitPower > 0 && TP_CMP(COOLER, temp_cooler.getraw(), maxtemp_raw_COOLER)) max_temp_error(H_COOLER); |
|
|
|
if (TP_CMP(COOLER, mintemp_raw_COOLER, temp_cooler.getraw())) min_temp_error(H_COOLER); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if BOTH(HAS_TEMP_BOARD, THERMAL_PROTECTION_BOARD) |
|
|
|
if (TP_CMP(BOARD, temp_board.raw, maxtemp_raw_BOARD)) max_temp_error(H_BOARD); |
|
|
|
if (TP_CMP(BOARD, mintemp_raw_BOARD, temp_board.raw)) min_temp_error(H_BOARD); |
|
|
|
if (TP_CMP(BOARD, temp_board.getraw(), maxtemp_raw_BOARD)) max_temp_error(H_BOARD); |
|
|
|
if (TP_CMP(BOARD, mintemp_raw_BOARD, temp_board.getraw())) min_temp_error(H_BOARD); |
|
|
|
#endif |
|
|
|
#undef TP_CMP |
|
|
|
|
|
|
@ -2731,7 +2731,7 @@ void Temperature::disable_all_heaters() { |
|
|
|
* @param hindex the hotend we're referencing (if MULTI_MAX_TC) |
|
|
|
* @return integer representing the board's buffer, to be converted later if needed |
|
|
|
*/ |
|
|
|
int16_t Temperature::read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex/*=0*/)) { |
|
|
|
raw_adc_t Temperature::read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex/*=0*/)) { |
|
|
|
#define MAXTC_HEAT_INTERVAL 250UL |
|
|
|
|
|
|
|
#if HAS_MAX31855 |
|
|
@ -2750,7 +2750,7 @@ void Temperature::disable_all_heaters() { |
|
|
|
|
|
|
|
#if HAS_MULTI_MAX_TC |
|
|
|
// Needed to return the correct temp when this is called between readings
|
|
|
|
static int16_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 }; |
|
|
|
static raw_adc_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 MAXTC_CS_WRITE(V) do{ switch (hindex) { case 1: WRITE(TEMP_1_CS_PIN, V); break; default: WRITE(TEMP_0_CS_PIN, V); } }while(0) |
|
|
@ -2779,7 +2779,7 @@ void Temperature::disable_all_heaters() { |
|
|
|
// Return last-read value between readings
|
|
|
|
millis_t ms = millis(); |
|
|
|
if (PENDING(ms, next_max_tc_ms[hindex])) |
|
|
|
return (int16_t)THERMO_TEMP(hindex); |
|
|
|
return THERMO_TEMP(hindex); |
|
|
|
|
|
|
|
next_max_tc_ms[hindex] = ms + MAXTC_HEAT_INTERVAL; |
|
|
|
|
|
|
@ -2876,7 +2876,7 @@ void Temperature::disable_all_heaters() { |
|
|
|
|
|
|
|
THERMO_TEMP(hindex) = max_tc_temp; |
|
|
|
|
|
|
|
return (int16_t)max_tc_temp; |
|
|
|
return max_tc_temp; |
|
|
|
} |
|
|
|
|
|
|
|
#endif // HAS_MAX_TC
|
|
|
@ -3017,7 +3017,7 @@ void Temperature::isr() { |
|
|
|
uint8_t pwm_count_tmp = pwm_count; |
|
|
|
|
|
|
|
#if HAS_ADC_BUTTONS |
|
|
|
static unsigned int raw_ADCKey_value = 0; |
|
|
|
static raw_adc_t raw_ADCKey_value = 0; |
|
|
|
static bool ADCKey_pressed = false; |
|
|
|
#endif |
|
|
|
|
|
|
|