Additional temp-oriented improvements

This commit is contained in:
Scott Lahteine 2018-05-01 19:33:41 -05:00
parent e911635fb1
commit 81b632c255
5 changed files with 169 additions and 162 deletions

View File

@ -101,19 +101,19 @@ uint16_t HAL_adc_result;
STM32ADC adc(ADC1); STM32ADC adc(ADC1);
uint8 adc_pins[] = { uint8 adc_pins[] = {
#if HAS_TEMP_0 #if HAS_TEMP_ADC_0
TEMP_0_PIN, TEMP_0_PIN,
#endif #endif
#if HAS_TEMP_1 #if HAS_TEMP_ADC_1
TEMP_1_PIN TEMP_1_PIN
#endif #endif
#if HAS_TEMP_2 #if HAS_TEMP_ADC_2
TEMP_2_PIN, TEMP_2_PIN,
#endif #endif
#if HAS_TEMP_3 #if HAS_TEMP_ADC_3
TEMP_3_PIN, TEMP_3_PIN,
#endif #endif
#if HAS_TEMP_4 #if HAS_TEMP_ADC_4
TEMP_4_PIN, TEMP_4_PIN,
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
@ -125,19 +125,19 @@ uint8 adc_pins[] = {
}; };
enum TEMP_PINS : char { enum TEMP_PINS : char {
#if HAS_TEMP_0 #if HAS_TEMP_ADC_0
TEMP_0, TEMP_0,
#endif #endif
#if HAS_TEMP_1 #if HAS_TEMP_ADC_1
TEMP_1, TEMP_1,
#endif #endif
#if HAS_TEMP_2 #if HAS_TEMP_ADC_2
TEMP_2, TEMP_2,
#endif #endif
#if HAS_TEMP_3 #if HAS_TEMP_ADC_3
TEMP_3, TEMP_3,
#endif #endif
#if HAS_TEMP_4 #if HAS_TEMP_ADC_4
TEMP_4, TEMP_4,
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
@ -247,19 +247,19 @@ void HAL_adc_init(void) {
void HAL_adc_start_conversion(const uint8_t adc_pin) { void HAL_adc_start_conversion(const uint8_t adc_pin) {
TEMP_PINS pin_index; TEMP_PINS pin_index;
switch (adc_pin) { switch (adc_pin) {
#if HAS_TEMP_0 #if HAS_TEMP_ADC_0
case TEMP_0_PIN: pin_index = TEMP_0; break; case TEMP_0_PIN: pin_index = TEMP_0; break;
#endif #endif
#if HAS_TEMP_1 #if HAS_TEMP_ADC_1
case TEMP_1_PIN: pin_index = TEMP_1; break; case TEMP_1_PIN: pin_index = TEMP_1; break;
#endif #endif
#if HAS_TEMP_2 #if HAS_TEMP_ADC_2
case TEMP_2_PIN: pin_index = TEMP_2; break; case TEMP_2_PIN: pin_index = TEMP_2; break;
#endif #endif
#if HAS_TEMP_3 #if HAS_TEMP_ADC_3
case TEMP_3_PIN: pin_index = TEMP_3; break; case TEMP_3_PIN: pin_index = TEMP_3; break;
#endif #endif
#if HAS_TEMP_4 #if HAS_TEMP_ADC_4
case TEMP_4_PIN: pin_index = TEMP_4; break; case TEMP_4_PIN: pin_index = TEMP_4; break;
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED

View File

@ -328,8 +328,10 @@
#if TEMP_SENSOR_1 == -4 #if TEMP_SENSOR_1 == -4
#define HEATER_1_USES_AD8495 #define HEATER_1_USES_AD8495
#elif TEMP_SENSOR_1 <= -2 #elif TEMP_SENSOR_1 == -3
#error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_1" #error "MAX31855 Thermocouples not supported for TEMP_SENSOR_1"
#elif TEMP_SENSOR_1 == -2
#error "MAX6675 Thermocouples not supported for TEMP_SENSOR_1"
#elif TEMP_SENSOR_1 == -1 #elif TEMP_SENSOR_1 == -1
#define HEATER_1_USES_AD595 #define HEATER_1_USES_AD595
#elif TEMP_SENSOR_1 == 0 #elif TEMP_SENSOR_1 == 0
@ -342,8 +344,10 @@
#if TEMP_SENSOR_2 == -4 #if TEMP_SENSOR_2 == -4
#define HEATER_2_USES_AD8495 #define HEATER_2_USES_AD8495
#elif TEMP_SENSOR_2 <= -2 #elif TEMP_SENSOR_2 == -3
#error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_2" #error "MAX31855 Thermocouples not supported for TEMP_SENSOR_2"
#elif TEMP_SENSOR_2 == -2
#error "MAX6675 Thermocouples not supported for TEMP_SENSOR_2"
#elif TEMP_SENSOR_2 == -1 #elif TEMP_SENSOR_2 == -1
#define HEATER_2_USES_AD595 #define HEATER_2_USES_AD595
#elif TEMP_SENSOR_2 == 0 #elif TEMP_SENSOR_2 == 0
@ -356,8 +360,10 @@
#if TEMP_SENSOR_3 == -4 #if TEMP_SENSOR_3 == -4
#define HEATER_3_USES_AD8495 #define HEATER_3_USES_AD8495
#elif TEMP_SENSOR_3 <= -2 #elif TEMP_SENSOR_3 == -3
#error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_3" #error "MAX31855 Thermocouples not supported for TEMP_SENSOR_3"
#elif TEMP_SENSOR_3 == -2
#error "MAX6675 Thermocouples not supported for TEMP_SENSOR_3"
#elif TEMP_SENSOR_3 == -1 #elif TEMP_SENSOR_3 == -1
#define HEATER_3_USES_AD595 #define HEATER_3_USES_AD595
#elif TEMP_SENSOR_3 == 0 #elif TEMP_SENSOR_3 == 0
@ -370,8 +376,10 @@
#if TEMP_SENSOR_4 == -4 #if TEMP_SENSOR_4 == -4
#define HEATER_4_USES_AD8495 #define HEATER_4_USES_AD8495
#elif TEMP_SENSOR_4 <= -2 #elif TEMP_SENSOR_4 == -3
#error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_4" #error "MAX31855 Thermocouples not supported for TEMP_SENSOR_4"
#elif TEMP_SENSOR_4 == -2
#error "MAX6675 Thermocouples not supported for TEMP_SENSOR_4"
#elif TEMP_SENSOR_4 == -1 #elif TEMP_SENSOR_4 == -1
#define HEATER_4_USES_AD595 #define HEATER_4_USES_AD595
#elif TEMP_SENSOR_4 == 0 #elif TEMP_SENSOR_4 == 0
@ -384,8 +392,10 @@
#if TEMP_SENSOR_BED == -4 #if TEMP_SENSOR_BED == -4
#define BED_USES_AD8495 #define BED_USES_AD8495
#elif TEMP_SENSOR_BED <= -2 #elif TEMP_SENSOR_BED == -3
#error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_BED" #error "MAX31855 Thermocouples not supported for TEMP_SENSOR_BED"
#elif TEMP_SENSOR_BED == -2
#error "MAX6675 Thermocouples not supported for TEMP_SENSOR_BED"
#elif TEMP_SENSOR_BED == -1 #elif TEMP_SENSOR_BED == -1
#define BED_USES_AD595 #define BED_USES_AD595
#elif TEMP_SENSOR_BED == 0 #elif TEMP_SENSOR_BED == 0
@ -398,8 +408,10 @@
#if TEMP_SENSOR_CHAMBER == -4 #if TEMP_SENSOR_CHAMBER == -4
#define CHAMBER_USES_AD8495 #define CHAMBER_USES_AD8495
#elif TEMP_SENSOR_CHAMBER <= -2 #elif TEMP_SENSOR_CHAMBER == -3
#error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_CHAMBER" #error "MAX31855 Thermocouples not supported for TEMP_SENSOR_CHAMBER"
#elif TEMP_SENSOR_CHAMBER == -2
#error "MAX6675 Thermocouples not supported for TEMP_SENSOR_CHAMBER"
#elif TEMP_SENSOR_CHAMBER == -1 #elif TEMP_SENSOR_CHAMBER == -1
#define CHAMBER_USES_AD595 #define CHAMBER_USES_AD595
#elif TEMP_SENSOR_CHAMBER > 0 #elif TEMP_SENSOR_CHAMBER > 0
@ -407,10 +419,10 @@
#define CHAMBER_USES_THERMISTOR #define CHAMBER_USES_THERMISTOR
#endif #endif
#define HEATER_USES_AD8495 (ENABLED(HEATER_0_USES_AD8495) || ENABLED(HEATER_1_USES_AD8495) || ENABLED(HEATER_2_USES_AD8495) || ENABLED(HEATER_3_USES_AD8495)) #define HEATER_USES_AD8495 (ENABLED(HEATER_0_USES_AD8495) || ENABLED(HEATER_1_USES_AD8495) || ENABLED(HEATER_2_USES_AD8495) || ENABLED(HEATER_3_USES_AD8495) || ENABLED(HEATER_4_USES_AD8495))
#ifdef __SAM3X8E__ #ifdef __SAM3X8E__
#define HEATER_USES_AD595 (ENABLED(HEATER_0_USES_AD595) || ENABLED(HEATER_1_USES_AD595) || ENABLED(HEATER_2_USES_AD595) || ENABLED(HEATER_3_USES_AD595)) #define HEATER_USES_AD595 (ENABLED(HEATER_0_USES_AD595) || ENABLED(HEATER_1_USES_AD595) || ENABLED(HEATER_2_USES_AD595) || ENABLED(HEATER_3_USES_AD595) || ENABLED(HEATER_4_USES_AD595))
#endif #endif
/** /**
@ -746,12 +758,13 @@
#endif #endif
// Endstops and bed probe // Endstops and bed probe
#define HAS_X_MIN (PIN_EXISTS(X_MIN) && !IS_X2_ENDSTOP(X,MIN) && !IS_Y2_ENDSTOP(X,MIN) && !IS_Z2_OR_PROBE(X,MIN)) #define HAS_STOP_TEST(A,M) (PIN_EXISTS(A##_##M) && !IS_X2_ENDSTOP(A,M) && !IS_Y2_ENDSTOP(A,M) && !IS_Z2_OR_PROBE(A,M))
#define HAS_X_MAX (PIN_EXISTS(X_MAX) && !IS_X2_ENDSTOP(X,MAX) && !IS_Y2_ENDSTOP(X,MAX) && !IS_Z2_OR_PROBE(X,MAX)) #define HAS_X_MIN HAS_STOP_TEST(X,MIN)
#define HAS_Y_MIN (PIN_EXISTS(Y_MIN) && !IS_X2_ENDSTOP(Y,MIN) && !IS_Y2_ENDSTOP(Y,MIN) && !IS_Z2_OR_PROBE(Y,MIN)) #define HAS_X_MAX HAS_STOP_TEST(X,MAX)
#define HAS_Y_MAX (PIN_EXISTS(Y_MAX) && !IS_X2_ENDSTOP(Y,MAX) && !IS_Y2_ENDSTOP(Y,MAX) && !IS_Z2_OR_PROBE(Y,MAX)) #define HAS_Y_MIN HAS_STOP_TEST(Y,MIN)
#define HAS_Z_MIN (PIN_EXISTS(Z_MIN) && !IS_X2_ENDSTOP(Z,MIN) && !IS_Y2_ENDSTOP(Z,MIN) && !IS_Z2_OR_PROBE(Z,MIN)) #define HAS_Y_MAX HAS_STOP_TEST(Y,MAX)
#define HAS_Z_MAX (PIN_EXISTS(Z_MAX) && !IS_X2_ENDSTOP(Z,MAX) && !IS_Y2_ENDSTOP(Z,MAX) && !IS_Z2_OR_PROBE(Z,MAX)) #define HAS_Z_MIN HAS_STOP_TEST(Z,MIN)
#define HAS_Z_MAX HAS_STOP_TEST(Z,MAX)
#define HAS_X2_MIN (PIN_EXISTS(X2_MIN)) #define HAS_X2_MIN (PIN_EXISTS(X2_MIN))
#define HAS_X2_MAX (PIN_EXISTS(X2_MAX)) #define HAS_X2_MAX (PIN_EXISTS(X2_MAX))
#define HAS_Y2_MIN (PIN_EXISTS(Y2_MIN)) #define HAS_Y2_MIN (PIN_EXISTS(Y2_MIN))
@ -761,14 +774,18 @@
#define HAS_Z_MIN_PROBE_PIN (PIN_EXISTS(Z_MIN_PROBE)) #define HAS_Z_MIN_PROBE_PIN (PIN_EXISTS(Z_MIN_PROBE))
// Thermistors // Thermistors
#define HAS_TEMP_0 (PIN_EXISTS(TEMP_0) && TEMP_SENSOR_0 != 0 && TEMP_SENSOR_0 > -2) #define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && TEMP_SENSOR_##P > -2)
#define HAS_TEMP_1 (PIN_EXISTS(TEMP_1) && TEMP_SENSOR_1 != 0 && TEMP_SENSOR_1 > -2) #define HAS_TEMP_ADC_0 (HAS_ADC_TEST(0) && DISABLED(HEATER_0_USES_MAX6675))
#define HAS_TEMP_2 (PIN_EXISTS(TEMP_2) && TEMP_SENSOR_2 != 0 && TEMP_SENSOR_2 > -2) #define HAS_TEMP_ADC_1 HAS_ADC_TEST(1)
#define HAS_TEMP_3 (PIN_EXISTS(TEMP_3) && TEMP_SENSOR_3 != 0 && TEMP_SENSOR_3 > -2) #define HAS_TEMP_ADC_2 HAS_ADC_TEST(2)
#define HAS_TEMP_4 (PIN_EXISTS(TEMP_4) && TEMP_SENSOR_4 != 0 && TEMP_SENSOR_4 > -2) #define HAS_TEMP_ADC_3 HAS_ADC_TEST(3)
#define HAS_TEMP_HOTEND (HAS_TEMP_0 || ENABLED(HEATER_0_USES_MAX6675)) #define HAS_TEMP_ADC_4 HAS_ADC_TEST(4)
#define HAS_TEMP_BED (PIN_EXISTS(TEMP_BED) && TEMP_SENSOR_BED != 0 && (TEMP_SENSOR_BED > -2 || TEMP_SENSOR_BED == -4)) #define HAS_TEMP_ADC_BED HAS_ADC_TEST(BED)
#define HAS_TEMP_CHAMBER (PIN_EXISTS(TEMP_CHAMBER) && TEMP_SENSOR_CHAMBER != 0 && TEMP_SENSOR_CHAMBER > -2) #define HAS_TEMP_ADC_CHAMBER HAS_ADC_TEST(CHAMBER)
#define HAS_TEMP_HOTEND (HAS_TEMP_ADC_0 || ENABLED(HEATER_0_USES_MAX6675))
#define HAS_TEMP_BED HAS_TEMP_ADC_BED
#define HAS_TEMP_CHAMBER HAS_TEMP_ADC_CHAMBER
// Heaters // Heaters
#define HAS_HEATER_0 (PIN_EXISTS(HEATER_0)) #define HAS_HEATER_0 (PIN_EXISTS(HEATER_0))

View File

@ -1579,7 +1579,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
*/ */
void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb, const int16_t fan) { void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb, const int16_t fan) {
if (temph > 0) thermalManager.setTargetHotend(min(heater_maxtemp[endnum], temph), endnum); if (temph > 0) thermalManager.setTargetHotend(min(heater_maxtemp[endnum], temph), endnum);
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
if (tempb >= 0) thermalManager.setTargetBed(tempb); if (tempb >= 0) thermalManager.setTargetBed(tempb);
#else #else
UNUSED(tempb); UNUSED(tempb);
@ -1596,10 +1596,10 @@ void lcd_quick_feedback(const bool clear_buttons) {
lcd_return_to_status(); lcd_return_to_status();
} }
#if TEMP_SENSOR_0 != 0 #if HAS_TEMP_HOTEND
void lcd_preheat_m1_e0_only() { _lcd_preheat(0, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); } void lcd_preheat_m1_e0_only() { _lcd_preheat(0, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e0_only() { _lcd_preheat(0, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); } void lcd_preheat_m2_e0_only() { _lcd_preheat(0, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
void lcd_preheat_m1_e0() { _lcd_preheat(0, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); } void lcd_preheat_m1_e0() { _lcd_preheat(0, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e0() { _lcd_preheat(0, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); } void lcd_preheat_m2_e0() { _lcd_preheat(0, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
#endif #endif
@ -1608,28 +1608,28 @@ void lcd_quick_feedback(const bool clear_buttons) {
#if HOTENDS > 1 #if HOTENDS > 1
void lcd_preheat_m1_e1_only() { _lcd_preheat(1, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); } void lcd_preheat_m1_e1_only() { _lcd_preheat(1, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e1_only() { _lcd_preheat(1, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); } void lcd_preheat_m2_e1_only() { _lcd_preheat(1, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
void lcd_preheat_m1_e1() { _lcd_preheat(1, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); } void lcd_preheat_m1_e1() { _lcd_preheat(1, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e1() { _lcd_preheat(1, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); } void lcd_preheat_m2_e1() { _lcd_preheat(1, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
#endif #endif
#if HOTENDS > 2 #if HOTENDS > 2
void lcd_preheat_m1_e2_only() { _lcd_preheat(2, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); } void lcd_preheat_m1_e2_only() { _lcd_preheat(2, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e2_only() { _lcd_preheat(2, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); } void lcd_preheat_m2_e2_only() { _lcd_preheat(2, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
void lcd_preheat_m1_e2() { _lcd_preheat(2, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); } void lcd_preheat_m1_e2() { _lcd_preheat(2, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e2() { _lcd_preheat(2, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); } void lcd_preheat_m2_e2() { _lcd_preheat(2, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
#endif #endif
#if HOTENDS > 3 #if HOTENDS > 3
void lcd_preheat_m1_e3_only() { _lcd_preheat(3, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); } void lcd_preheat_m1_e3_only() { _lcd_preheat(3, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e3_only() { _lcd_preheat(3, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); } void lcd_preheat_m2_e3_only() { _lcd_preheat(3, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
void lcd_preheat_m1_e3() { _lcd_preheat(3, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); } void lcd_preheat_m1_e3() { _lcd_preheat(3, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e3() { _lcd_preheat(3, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); } void lcd_preheat_m2_e3() { _lcd_preheat(3, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
#endif #endif
#if HOTENDS > 4 #if HOTENDS > 4
void lcd_preheat_m1_e4_only() { _lcd_preheat(4, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); } void lcd_preheat_m1_e4_only() { _lcd_preheat(4, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e4_only() { _lcd_preheat(4, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); } void lcd_preheat_m2_e4_only() { _lcd_preheat(4, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
void lcd_preheat_m1_e4() { _lcd_preheat(4, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); } void lcd_preheat_m1_e4() { _lcd_preheat(4, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e4() { _lcd_preheat(4, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); } void lcd_preheat_m2_e4() { _lcd_preheat(4, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
#endif #endif
@ -1650,7 +1650,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
#endif // HOTENDS > 3 #endif // HOTENDS > 3
#endif // HOTENDS > 2 #endif // HOTENDS > 2
#endif // HOTENDS > 1 #endif // HOTENDS > 1
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
lcd_preheat_m1_e0(); lcd_preheat_m1_e0();
#else #else
lcd_preheat_m1_e0_only(); lcd_preheat_m1_e0_only();
@ -1669,7 +1669,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
#endif // HOTENDS > 3 #endif // HOTENDS > 3
#endif // HOTENDS > 2 #endif // HOTENDS > 2
#endif // HOTENDS > 1 #endif // HOTENDS > 1
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
lcd_preheat_m2_e0(); lcd_preheat_m2_e0();
#else #else
lcd_preheat_m2_e0_only(); lcd_preheat_m2_e0_only();
@ -1678,25 +1678,25 @@ void lcd_quick_feedback(const bool clear_buttons) {
#endif // HOTENDS > 1 #endif // HOTENDS > 1
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
void lcd_preheat_m1_bedonly() { _lcd_preheat(0, 0, lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); } void lcd_preheat_m1_bedonly() { _lcd_preheat(0, 0, lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_bedonly() { _lcd_preheat(0, 0, lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); } void lcd_preheat_m2_bedonly() { _lcd_preheat(0, 0, lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
#endif #endif
#if TEMP_SENSOR_0 != 0 && (TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_4 != 0 || TEMP_SENSOR_BED != 0) #if HAS_TEMP_HOTEND && (TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_4 != 0 || HAS_HEATED_BED)
void lcd_preheat_m1_menu() { void lcd_preheat_m1_menu() {
START_MENU(); START_MENU();
MENU_BACK(MSG_PREPARE); MENU_BACK(MSG_PREPARE);
#if HOTENDS == 1 #if HOTENDS == 1
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_1, lcd_preheat_m1_e0); MENU_ITEM(function, MSG_PREHEAT_1, lcd_preheat_m1_e0);
MENU_ITEM(function, MSG_PREHEAT_1_END, lcd_preheat_m1_e0_only); MENU_ITEM(function, MSG_PREHEAT_1_END, lcd_preheat_m1_e0_only);
#else #else
MENU_ITEM(function, MSG_PREHEAT_1, lcd_preheat_m1_e0_only); MENU_ITEM(function, MSG_PREHEAT_1, lcd_preheat_m1_e0_only);
#endif #endif
#else #else
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H1, lcd_preheat_m1_e0); MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H1, lcd_preheat_m1_e0);
MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E1, lcd_preheat_m1_e0_only); MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E1, lcd_preheat_m1_e0_only);
MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H2, lcd_preheat_m1_e1); MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H2, lcd_preheat_m1_e1);
@ -1706,21 +1706,21 @@ void lcd_quick_feedback(const bool clear_buttons) {
MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H2, lcd_preheat_m1_e1_only); MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H2, lcd_preheat_m1_e1_only);
#endif #endif
#if HOTENDS > 2 #if HOTENDS > 2
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H3, lcd_preheat_m1_e2); MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H3, lcd_preheat_m1_e2);
MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E3, lcd_preheat_m1_e2_only); MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E3, lcd_preheat_m1_e2_only);
#else #else
MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H3, lcd_preheat_m1_e2_only); MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H3, lcd_preheat_m1_e2_only);
#endif #endif
#if HOTENDS > 3 #if HOTENDS > 3
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H4, lcd_preheat_m1_e3); MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H4, lcd_preheat_m1_e3);
MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E4, lcd_preheat_m1_e3_only); MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E4, lcd_preheat_m1_e3_only);
#else #else
MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H4, lcd_preheat_m1_e3_only); MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H4, lcd_preheat_m1_e3_only);
#endif #endif
#if HOTENDS > 4 #if HOTENDS > 4
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H5, lcd_preheat_m1_e4); MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H5, lcd_preheat_m1_e4);
MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E5, lcd_preheat_m1_e4_only); MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E5, lcd_preheat_m1_e4_only);
#else #else
@ -1731,7 +1731,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
#endif // HOTENDS > 2 #endif // HOTENDS > 2
MENU_ITEM(function, MSG_PREHEAT_1_ALL, lcd_preheat_m1_all); MENU_ITEM(function, MSG_PREHEAT_1_ALL, lcd_preheat_m1_all);
#endif // HOTENDS > 1 #endif // HOTENDS > 1
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_1_BEDONLY, lcd_preheat_m1_bedonly); MENU_ITEM(function, MSG_PREHEAT_1_BEDONLY, lcd_preheat_m1_bedonly);
#endif #endif
END_MENU(); END_MENU();
@ -1741,14 +1741,14 @@ void lcd_quick_feedback(const bool clear_buttons) {
START_MENU(); START_MENU();
MENU_BACK(MSG_PREPARE); MENU_BACK(MSG_PREPARE);
#if HOTENDS == 1 #if HOTENDS == 1
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0); MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0);
MENU_ITEM(function, MSG_PREHEAT_2_END, lcd_preheat_m2_e0_only); MENU_ITEM(function, MSG_PREHEAT_2_END, lcd_preheat_m2_e0_only);
#else #else
MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0_only); MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0_only);
#endif #endif
#else #else
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H1, lcd_preheat_m2_e0); MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H1, lcd_preheat_m2_e0);
MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E1, lcd_preheat_m2_e0_only); MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E1, lcd_preheat_m2_e0_only);
MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H2, lcd_preheat_m2_e1); MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H2, lcd_preheat_m2_e1);
@ -1758,21 +1758,21 @@ void lcd_quick_feedback(const bool clear_buttons) {
MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H2, lcd_preheat_m2_e1_only); MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H2, lcd_preheat_m2_e1_only);
#endif #endif
#if HOTENDS > 2 #if HOTENDS > 2
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H3, lcd_preheat_m2_e2); MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H3, lcd_preheat_m2_e2);
MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E3, lcd_preheat_m2_e2_only); MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E3, lcd_preheat_m2_e2_only);
#else #else
MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H3, lcd_preheat_m2_e2_only); MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H3, lcd_preheat_m2_e2_only);
#endif #endif
#if HOTENDS > 3 #if HOTENDS > 3
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H4, lcd_preheat_m2_e3); MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H4, lcd_preheat_m2_e3);
MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E4, lcd_preheat_m2_e3_only); MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E4, lcd_preheat_m2_e3_only);
#else #else
MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H4, lcd_preheat_m2_e3_only); MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H4, lcd_preheat_m2_e3_only);
#endif #endif
#if HOTENDS > 4 #if HOTENDS > 4
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H5, lcd_preheat_m2_e4); MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H5, lcd_preheat_m2_e4);
MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E5, lcd_preheat_m2_e4_only); MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E5, lcd_preheat_m2_e4_only);
#else #else
@ -1783,13 +1783,13 @@ void lcd_quick_feedback(const bool clear_buttons) {
#endif // HOTENDS > 2 #endif // HOTENDS > 2
MENU_ITEM(function, MSG_PREHEAT_2_ALL, lcd_preheat_m2_all); MENU_ITEM(function, MSG_PREHEAT_2_ALL, lcd_preheat_m2_all);
#endif // HOTENDS > 1 #endif // HOTENDS > 1
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_2_BEDONLY, lcd_preheat_m2_bedonly); MENU_ITEM(function, MSG_PREHEAT_2_BEDONLY, lcd_preheat_m2_bedonly);
#endif #endif
END_MENU(); END_MENU();
} }
#endif // TEMP_SENSOR_0 && (TEMP_SENSOR_1 || TEMP_SENSOR_2 || TEMP_SENSOR_3 || TEMP_SENSOR_4 || TEMP_SENSOR_BED) #endif // HAS_TEMP_HOTEND && (TEMP_SENSOR_1 || TEMP_SENSOR_2 || TEMP_SENSOR_3 || TEMP_SENSOR_4 || TEMP_SENSOR_BED)
void lcd_cooldown() { void lcd_cooldown() {
#if FAN_COUNT > 0 #if FAN_COUNT > 0
@ -2780,7 +2780,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
} }
#endif // ADVANCED_PAUSE_FEATURE #endif // ADVANCED_PAUSE_FEATURE
#if TEMP_SENSOR_0 != 0 #if HAS_TEMP_HOTEND
// //
// Cooldown // Cooldown
@ -2795,7 +2795,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
// //
// Preheat for Material 1 and 2 // Preheat for Material 1 and 2
// //
#if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_4 != 0 || TEMP_SENSOR_BED != 0 #if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_4 != 0 || HAS_HEATED_BED
MENU_ITEM(submenu, MSG_PREHEAT_1, lcd_preheat_m1_menu); MENU_ITEM(submenu, MSG_PREHEAT_1, lcd_preheat_m1_menu);
MENU_ITEM(submenu, MSG_PREHEAT_2, lcd_preheat_m2_menu); MENU_ITEM(submenu, MSG_PREHEAT_2, lcd_preheat_m2_menu);
#else #else
@ -2803,7 +2803,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0_only); MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0_only);
#endif #endif
#endif // TEMP_SENSOR_0 != 0 #endif // HAS_TEMP_HOTEND
// //
// BLTouch Self-Test and Reset // BLTouch Self-Test and Reset
@ -3538,7 +3538,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
// //
// Autotemp, Min, Max, Fact // Autotemp, Min, Max, Fact
// //
#if ENABLED(AUTOTEMP) && (TEMP_SENSOR_0 != 0) #if ENABLED(AUTOTEMP) && (HAS_TEMP_HOTEND)
MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &planner.autotemp_enabled); MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &planner.autotemp_enabled);
MENU_ITEM_EDIT(float3, MSG_MIN, &planner.autotemp_min, 0, HEATER_0_MAXTEMP - 15); MENU_ITEM_EDIT(float3, MSG_MIN, &planner.autotemp_min, 0, HEATER_0_MAXTEMP - 15);
MENU_ITEM_EDIT(float3, MSG_MAX, &planner.autotemp_max, 0, HEATER_0_MAXTEMP - 15); MENU_ITEM_EDIT(float3, MSG_MAX, &planner.autotemp_max, 0, HEATER_0_MAXTEMP - 15);
@ -3633,10 +3633,10 @@ void lcd_quick_feedback(const bool clear_buttons) {
START_MENU(); START_MENU();
MENU_BACK(MSG_TEMPERATURE); MENU_BACK(MSG_TEMPERATURE);
MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &lcd_preheat_fan_speed[material], 0, 255); MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &lcd_preheat_fan_speed[material], 0, 255);
#if TEMP_SENSOR_0 != 0 #if HAS_TEMP_HOTEND
MENU_ITEM_EDIT(int3, MSG_NOZZLE, &lcd_preheat_hotend_temp[material], MINTEMP_ALL, MAXTEMP_ALL - 15); MENU_ITEM_EDIT(int3, MSG_NOZZLE, &lcd_preheat_hotend_temp[material], MINTEMP_ALL, MAXTEMP_ALL - 15);
#endif #endif
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
MENU_ITEM_EDIT(int3, MSG_BED, &lcd_preheat_bed_temp[material], BED_MINTEMP, BED_MAXTEMP - 15); MENU_ITEM_EDIT(int3, MSG_BED, &lcd_preheat_bed_temp[material], BED_MINTEMP, BED_MAXTEMP - 15);
#endif #endif
#if ENABLED(EEPROM_SETTINGS) #if ENABLED(EEPROM_SETTINGS)
@ -4154,7 +4154,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_4_MAXTEMP), false); STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_4_MAXTEMP), false);
#endif #endif
#if TEMP_SENSOR_BED != 0 #if HAS_HEATED_BED
#undef THERMISTOR_ID #undef THERMISTOR_ID
#define THERMISTOR_ID TEMP_SENSOR_BED #define THERMISTOR_ID TEMP_SENSOR_BED
#include "thermistornames.h" #include "thermistornames.h"

View File

@ -952,31 +952,31 @@ float Temperature::analog2temp(const int raw, const uint8_t e) {
if (e == 0) return 0.25 * raw; if (e == 0) return 0.25 * raw;
#endif #endif
// Thermistor with conversion table?
if (heater_ttbl_map[e] != NULL) { if (heater_ttbl_map[e] != NULL) {
float celsius = 0;
uint8_t i;
short(*tt)[][2] = (short(*)[][2])(heater_ttbl_map[e]); short(*tt)[][2] = (short(*)[][2])(heater_ttbl_map[e]);
for (uint8_t i = 1; i < heater_ttbllen_map[e]; i++) {
for (i = 1; i < heater_ttbllen_map[e]; i++) { const short entry10 = PGM_RD_W((*tt)[i][0]);
if (PGM_RD_W((*tt)[i][0]) > raw) { if (entry10 > raw) {
celsius = PGM_RD_W((*tt)[i - 1][1]) + const short entry00 = PGM_RD_W((*tt)[i - 1][0]),
(raw - PGM_RD_W((*tt)[i - 1][0])) * entry01 = PGM_RD_W((*tt)[i - 1][1]),
(float)(PGM_RD_W((*tt)[i][1]) - PGM_RD_W((*tt)[i - 1][1])) / entry11 = PGM_RD_W((*tt)[i][1]);
(float)(PGM_RD_W((*tt)[i][0]) - PGM_RD_W((*tt)[i - 1][0])); return entry01 + (raw - entry00) * float(entry11 - entry01) / float(entry10 - entry00);
break;
} }
} }
return PGM_RD_W((*tt)[heater_ttbllen_map[e] - 1][1]); // Overflow: Return last value in the table
// Overflow: Set to last value in the table
if (i == heater_ttbllen_map[e]) celsius = PGM_RD_W((*tt)[i - 1][1]);
return celsius;
} }
#if defined(HEATER_USES_AD8495)
return ((raw * (660.0 / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD8495_GAIN)) + TEMP_SENSOR_AD8495_OFFSET; // Thermocouple with amplifier ADC interface
#else return (raw *
return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN)) + TEMP_SENSOR_AD595_OFFSET; #if HEATER_USES_AD8495
#endif 660.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD8495_GAIN) + TEMP_SENSOR_AD8495_OFFSET
#elif HEATER_USES_AD595
5.0 * 100.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET
#else
0
#endif
);
} }
#if HAS_HEATED_BED #if HAS_HEATED_BED
@ -984,36 +984,31 @@ float Temperature::analog2temp(const int raw, const uint8_t e) {
// For bed temperature measurement. // For bed temperature measurement.
float Temperature::analog2tempBed(const int raw) { float Temperature::analog2tempBed(const int raw) {
#if ENABLED(BED_USES_THERMISTOR) #if ENABLED(BED_USES_THERMISTOR)
float celsius = 0;
byte i;
for (i = 1; i < BEDTEMPTABLE_LEN; i++) { // Thermistor with conversion table
if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) { for (uint8_t i = 1; i < BEDTEMPTABLE_LEN; i++) {
celsius = PGM_RD_W(BEDTEMPTABLE[i - 1][1]) + const short entry10 = PGM_RD_W(BEDTEMPTABLE[i][0]);
(raw - PGM_RD_W(BEDTEMPTABLE[i - 1][0])) * if (entry10 > raw) {
(float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i - 1][1])) / const short entry00 = PGM_RD_W(BEDTEMPTABLE[i - 1][0]),
(float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i - 1][0])); entry01 = PGM_RD_W(BEDTEMPTABLE[i - 1][1]),
break; entry11 = PGM_RD_W(BEDTEMPTABLE[i][1]);
return entry01 + (raw - entry00) * float(entry11 - entry01) / float(entry10 - entry00);
} }
} }
return PGM_RD_W(BEDTEMPTABLE[BEDTEMPTABLE_LEN - 1][1]); // Overflow: Return last value in the table
// Overflow: Set to last value in the table
if (i == BEDTEMPTABLE_LEN) celsius = PGM_RD_W(BEDTEMPTABLE[i - 1][1]);
return celsius;
#elif defined(BED_USES_AD595)
return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN)) + TEMP_SENSOR_AD595_OFFSET;
#elif defined(BED_USES_AD8495)
return ((raw * (660.0 / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD8495_GAIN)) + TEMP_SENSOR_AD8495_OFFSET;
#else #else
UNUSED(raw); // Thermocouple with amplifier ADC interface
return 0; return (raw *
#if ENABLED(BED_USES_AD595)
5.0 * 100.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET
#elif ENABLED(BED_USES_AD8495)
660.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD8495_GAIN) + TEMP_SENSOR_AD8495_OFFSET
#else
0
#endif
);
#endif #endif
} }
@ -1024,36 +1019,31 @@ float Temperature::analog2temp(const int raw, const uint8_t e) {
// For chamber temperature measurement. // For chamber temperature measurement.
float Temperature::analog2tempChamber(const int raw) { float Temperature::analog2tempChamber(const int raw) {
#if ENABLED(CHAMBER_USES_THERMISTOR) #if ENABLED(CHAMBER_USES_THERMISTOR)
float celsius = 0;
byte i;
for (i = 1; i < CHAMBERTEMPTABLE_LEN; i++) { // Thermistor with conversion table
if (PGM_RD_W(CHAMBERTEMPTABLE[i][0]) > raw) { for (uint8_t i = 1; i < CHAMBERTEMPTABLE_LEN; i++) {
celsius = PGM_RD_W(CHAMBERTEMPTABLE[i - 1][1]) + const short entry10 = PGM_RD_W(CHAMBERTEMPTABLE[i][0]);
(raw - PGM_RD_W(CHAMBERTEMPTABLE[i - 1][0])) * if (entry10 > raw) {
(float)(PGM_RD_W(CHAMBERTEMPTABLE[i][1]) - PGM_RD_W(CHAMBERTEMPTABLE[i - 1][1])) / const short entry00 = PGM_RD_W(CHAMBERTEMPTABLE[i - 1][0]),
(float)(PGM_RD_W(CHAMBERTEMPTABLE[i][0]) - PGM_RD_W(CHAMBERTEMPTABLE[i - 1][0])); entry01 = PGM_RD_W(CHAMBERTEMPTABLE[i - 1][1]),
break; entry11 = PGM_RD_W(CHAMBERTEMPTABLE[i][1]);
return entry01 + (raw - entry00) * float(entry11 - entry01) / float(entry10 - entry00);
} }
} }
return PGM_RD_W(CHAMBERTEMPTABLE[CHAMBERTEMPTABLE_LEN - 1][1]); // Overflow: Return last value in the table
// Overflow: Set to last value in the table
if (i == CHAMBERTEMPTABLE_LEN) celsius = PGM_RD_W(CHAMBERTEMPTABLE[i - 1][1]);
return celsius;
#elif defined(CHAMBER_USES_AD595)
return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN)) + TEMP_SENSOR_AD595_OFFSET;
#elif defined(CHAMBER_USES_AD8495)
return ((raw * (660.0 / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD8495_GAIN)) + TEMP_SENSOR_AD8495_OFFSET;
#else #else
UNUSED(raw); // Thermocouple with amplifier ADC interface
return 0; return (raw *
#if ENABLED(CHAMBER_USES_AD595)
5.0 * 100.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET
#elif ENABLED(CHAMBER_USES_AD8495)
660.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD8495_GAIN) + TEMP_SENSOR_AD8495_OFFSET
#else
0
#endif
);
#endif #endif
} }
@ -1208,19 +1198,19 @@ void Temperature::init() {
HAL_adc_init(); HAL_adc_init();
#if HAS_TEMP_0 #if HAS_TEMP_ADC_0
HAL_ANALOG_SELECT(TEMP_0_PIN); HAL_ANALOG_SELECT(TEMP_0_PIN);
#endif #endif
#if HAS_TEMP_1 #if HAS_TEMP_ADC_1
HAL_ANALOG_SELECT(TEMP_1_PIN); HAL_ANALOG_SELECT(TEMP_1_PIN);
#endif #endif
#if HAS_TEMP_2 #if HAS_TEMP_ADC_2
HAL_ANALOG_SELECT(TEMP_2_PIN); HAL_ANALOG_SELECT(TEMP_2_PIN);
#endif #endif
#if HAS_TEMP_3 #if HAS_TEMP_ADC_3
HAL_ANALOG_SELECT(TEMP_3_PIN); HAL_ANALOG_SELECT(TEMP_3_PIN);
#endif #endif
#if HAS_TEMP_4 #if HAS_TEMP_ADC_4
HAL_ANALOG_SELECT(TEMP_4_PIN); HAL_ANALOG_SELECT(TEMP_4_PIN);
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
@ -1687,20 +1677,20 @@ void Temperature::disable_all_heaters() {
* Get raw temperatures * Get raw temperatures
*/ */
void Temperature::set_current_temp_raw() { void Temperature::set_current_temp_raw() {
#if HAS_TEMP_0 && DISABLED(HEATER_0_USES_MAX6675) #if HAS_TEMP_ADC_0 && DISABLED(HEATER_0_USES_MAX6675)
current_temperature_raw[0] = raw_temp_value[0]; current_temperature_raw[0] = raw_temp_value[0];
#endif #endif
#if HAS_TEMP_1 #if HAS_TEMP_ADC_1
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
redundant_temperature_raw = raw_temp_value[1]; redundant_temperature_raw = raw_temp_value[1];
#else #else
current_temperature_raw[1] = raw_temp_value[1]; current_temperature_raw[1] = raw_temp_value[1];
#endif #endif
#if HAS_TEMP_2 #if HAS_TEMP_ADC_2
current_temperature_raw[2] = raw_temp_value[2]; current_temperature_raw[2] = raw_temp_value[2];
#if HAS_TEMP_3 #if HAS_TEMP_ADC_3
current_temperature_raw[3] = raw_temp_value[3]; current_temperature_raw[3] = raw_temp_value[3];
#if HAS_TEMP_4 #if HAS_TEMP_ADC_4
current_temperature_raw[4] = raw_temp_value[4]; current_temperature_raw[4] = raw_temp_value[4];
#endif #endif
#endif #endif
@ -2050,7 +2040,7 @@ void Temperature::isr() {
adc_sensor_state = (ADCSensorState)0; // Fall-through to start first sensor now adc_sensor_state = (ADCSensorState)0; // Fall-through to start first sensor now
} }
#if HAS_TEMP_0 #if HAS_TEMP_ADC_0
case PrepareTemp_0: case PrepareTemp_0:
HAL_START_ADC(TEMP_0_PIN); HAL_START_ADC(TEMP_0_PIN);
break; break;
@ -2077,7 +2067,7 @@ void Temperature::isr() {
break; break;
#endif #endif
#if HAS_TEMP_1 #if HAS_TEMP_ADC_1
case PrepareTemp_1: case PrepareTemp_1:
HAL_START_ADC(TEMP_1_PIN); HAL_START_ADC(TEMP_1_PIN);
break; break;
@ -2086,7 +2076,7 @@ void Temperature::isr() {
break; break;
#endif #endif
#if HAS_TEMP_2 #if HAS_TEMP_ADC_2
case PrepareTemp_2: case PrepareTemp_2:
HAL_START_ADC(TEMP_2_PIN); HAL_START_ADC(TEMP_2_PIN);
break; break;
@ -2095,7 +2085,7 @@ void Temperature::isr() {
break; break;
#endif #endif
#if HAS_TEMP_3 #if HAS_TEMP_ADC_3
case PrepareTemp_3: case PrepareTemp_3:
HAL_START_ADC(TEMP_3_PIN); HAL_START_ADC(TEMP_3_PIN);
break; break;
@ -2104,7 +2094,7 @@ void Temperature::isr() {
break; break;
#endif #endif
#if HAS_TEMP_4 #if HAS_TEMP_ADC_4
case PrepareTemp_4: case PrepareTemp_4:
HAL_START_ADC(TEMP_4_PIN); HAL_START_ADC(TEMP_4_PIN);
break; break;

View File

@ -50,23 +50,23 @@
* States for ADC reading in the ISR * States for ADC reading in the ISR
*/ */
enum ADCSensorState : char { enum ADCSensorState : char {
#if HAS_TEMP_0 #if HAS_TEMP_ADC_0
PrepareTemp_0, PrepareTemp_0,
MeasureTemp_0, MeasureTemp_0,
#endif #endif
#if HAS_TEMP_1 #if HAS_TEMP_ADC_1
PrepareTemp_1, PrepareTemp_1,
MeasureTemp_1, MeasureTemp_1,
#endif #endif
#if HAS_TEMP_2 #if HAS_TEMP_ADC_2
PrepareTemp_2, PrepareTemp_2,
MeasureTemp_2, MeasureTemp_2,
#endif #endif
#if HAS_TEMP_3 #if HAS_TEMP_ADC_3
PrepareTemp_3, PrepareTemp_3,
MeasureTemp_3, MeasureTemp_3,
#endif #endif
#if HAS_TEMP_4 #if HAS_TEMP_ADC_4
PrepareTemp_4, PrepareTemp_4,
MeasureTemp_4, MeasureTemp_4,
#endif #endif