Ver código fonte

Additional temp-oriented improvements

Scott Lahteine 7 anos atrás
pai
commit
81b632c255

+ 15
- 15
Marlin/src/HAL/HAL_STM32F1/HAL.cpp Ver arquivo

101
 STM32ADC adc(ADC1);
101
 STM32ADC adc(ADC1);
102
 
102
 
103
 uint8 adc_pins[] = {
103
 uint8 adc_pins[] = {
104
-  #if HAS_TEMP_0
104
+  #if HAS_TEMP_ADC_0
105
     TEMP_0_PIN,
105
     TEMP_0_PIN,
106
   #endif
106
   #endif
107
-  #if HAS_TEMP_1
107
+  #if HAS_TEMP_ADC_1
108
     TEMP_1_PIN
108
     TEMP_1_PIN
109
   #endif
109
   #endif
110
-  #if HAS_TEMP_2
110
+  #if HAS_TEMP_ADC_2
111
     TEMP_2_PIN,
111
     TEMP_2_PIN,
112
   #endif
112
   #endif
113
-  #if HAS_TEMP_3
113
+  #if HAS_TEMP_ADC_3
114
     TEMP_3_PIN,
114
     TEMP_3_PIN,
115
   #endif
115
   #endif
116
-  #if HAS_TEMP_4
116
+  #if HAS_TEMP_ADC_4
117
     TEMP_4_PIN,
117
     TEMP_4_PIN,
118
   #endif
118
   #endif
119
   #if HAS_HEATED_BED
119
   #if HAS_HEATED_BED
125
 };
125
 };
126
 
126
 
127
 enum TEMP_PINS : char {
127
 enum TEMP_PINS : char {
128
-  #if HAS_TEMP_0
128
+  #if HAS_TEMP_ADC_0
129
     TEMP_0,
129
     TEMP_0,
130
   #endif
130
   #endif
131
-  #if HAS_TEMP_1
131
+  #if HAS_TEMP_ADC_1
132
     TEMP_1,
132
     TEMP_1,
133
   #endif
133
   #endif
134
-  #if HAS_TEMP_2
134
+  #if HAS_TEMP_ADC_2
135
     TEMP_2,
135
     TEMP_2,
136
   #endif
136
   #endif
137
-  #if HAS_TEMP_3
137
+  #if HAS_TEMP_ADC_3
138
     TEMP_3,
138
     TEMP_3,
139
   #endif
139
   #endif
140
-  #if HAS_TEMP_4
140
+  #if HAS_TEMP_ADC_4
141
     TEMP_4,
141
     TEMP_4,
142
   #endif
142
   #endif
143
   #if HAS_HEATED_BED
143
   #if HAS_HEATED_BED
247
 void HAL_adc_start_conversion(const uint8_t adc_pin) {
247
 void HAL_adc_start_conversion(const uint8_t adc_pin) {
248
   TEMP_PINS pin_index;
248
   TEMP_PINS pin_index;
249
   switch (adc_pin) {
249
   switch (adc_pin) {
250
-    #if HAS_TEMP_0
250
+    #if HAS_TEMP_ADC_0
251
       case TEMP_0_PIN: pin_index = TEMP_0; break;
251
       case TEMP_0_PIN: pin_index = TEMP_0; break;
252
     #endif
252
     #endif
253
-    #if HAS_TEMP_1
253
+    #if HAS_TEMP_ADC_1
254
       case TEMP_1_PIN: pin_index = TEMP_1; break;
254
       case TEMP_1_PIN: pin_index = TEMP_1; break;
255
     #endif
255
     #endif
256
-    #if HAS_TEMP_2
256
+    #if HAS_TEMP_ADC_2
257
       case TEMP_2_PIN: pin_index = TEMP_2; break;
257
       case TEMP_2_PIN: pin_index = TEMP_2; break;
258
     #endif
258
     #endif
259
-    #if HAS_TEMP_3
259
+    #if HAS_TEMP_ADC_3
260
       case TEMP_3_PIN: pin_index = TEMP_3; break;
260
       case TEMP_3_PIN: pin_index = TEMP_3; break;
261
     #endif
261
     #endif
262
-    #if HAS_TEMP_4
262
+    #if HAS_TEMP_ADC_4
263
       case TEMP_4_PIN: pin_index = TEMP_4; break;
263
       case TEMP_4_PIN: pin_index = TEMP_4; break;
264
     #endif
264
     #endif
265
     #if HAS_HEATED_BED
265
     #if HAS_HEATED_BED

+ 45
- 28
Marlin/src/inc/Conditionals_post.h Ver arquivo

328
 
328
 
329
 #if TEMP_SENSOR_1 == -4
329
 #if TEMP_SENSOR_1 == -4
330
   #define HEATER_1_USES_AD8495
330
   #define HEATER_1_USES_AD8495
331
-#elif TEMP_SENSOR_1 <= -2
332
-  #error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_1"
331
+#elif TEMP_SENSOR_1 == -3
332
+  #error "MAX31855 Thermocouples not supported for TEMP_SENSOR_1"
333
+#elif TEMP_SENSOR_1 == -2
334
+  #error "MAX6675 Thermocouples not supported for TEMP_SENSOR_1"
333
 #elif TEMP_SENSOR_1 == -1
335
 #elif TEMP_SENSOR_1 == -1
334
   #define HEATER_1_USES_AD595
336
   #define HEATER_1_USES_AD595
335
 #elif TEMP_SENSOR_1 == 0
337
 #elif TEMP_SENSOR_1 == 0
342
 
344
 
343
 #if TEMP_SENSOR_2 == -4
345
 #if TEMP_SENSOR_2 == -4
344
   #define HEATER_2_USES_AD8495
346
   #define HEATER_2_USES_AD8495
345
-#elif TEMP_SENSOR_2 <= -2
346
-  #error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_2"
347
+#elif TEMP_SENSOR_2 == -3
348
+  #error "MAX31855 Thermocouples not supported for TEMP_SENSOR_2"
349
+#elif TEMP_SENSOR_2 == -2
350
+  #error "MAX6675 Thermocouples not supported for TEMP_SENSOR_2"
347
 #elif TEMP_SENSOR_2 == -1
351
 #elif TEMP_SENSOR_2 == -1
348
   #define HEATER_2_USES_AD595
352
   #define HEATER_2_USES_AD595
349
 #elif TEMP_SENSOR_2 == 0
353
 #elif TEMP_SENSOR_2 == 0
356
 
360
 
357
 #if TEMP_SENSOR_3 == -4
361
 #if TEMP_SENSOR_3 == -4
358
   #define HEATER_3_USES_AD8495
362
   #define HEATER_3_USES_AD8495
359
-#elif TEMP_SENSOR_3 <= -2
360
-  #error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_3"
363
+#elif TEMP_SENSOR_3 == -3
364
+  #error "MAX31855 Thermocouples not supported for TEMP_SENSOR_3"
365
+#elif TEMP_SENSOR_3 == -2
366
+  #error "MAX6675 Thermocouples not supported for TEMP_SENSOR_3"
361
 #elif TEMP_SENSOR_3 == -1
367
 #elif TEMP_SENSOR_3 == -1
362
   #define HEATER_3_USES_AD595
368
   #define HEATER_3_USES_AD595
363
 #elif TEMP_SENSOR_3 == 0
369
 #elif TEMP_SENSOR_3 == 0
370
 
376
 
371
 #if TEMP_SENSOR_4 == -4
377
 #if TEMP_SENSOR_4 == -4
372
   #define HEATER_4_USES_AD8495
378
   #define HEATER_4_USES_AD8495
373
-#elif TEMP_SENSOR_4 <= -2
374
-  #error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_4"
379
+#elif TEMP_SENSOR_4 == -3
380
+  #error "MAX31855 Thermocouples not supported for TEMP_SENSOR_4"
381
+#elif TEMP_SENSOR_4 == -2
382
+  #error "MAX6675 Thermocouples not supported for TEMP_SENSOR_4"
375
 #elif TEMP_SENSOR_4 == -1
383
 #elif TEMP_SENSOR_4 == -1
376
   #define HEATER_4_USES_AD595
384
   #define HEATER_4_USES_AD595
377
 #elif TEMP_SENSOR_4 == 0
385
 #elif TEMP_SENSOR_4 == 0
384
 
392
 
385
 #if TEMP_SENSOR_BED == -4
393
 #if TEMP_SENSOR_BED == -4
386
   #define BED_USES_AD8495
394
   #define BED_USES_AD8495
387
-#elif TEMP_SENSOR_BED <= -2
388
-  #error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_BED"
395
+#elif TEMP_SENSOR_BED == -3
396
+  #error "MAX31855 Thermocouples not supported for TEMP_SENSOR_BED"
397
+#elif TEMP_SENSOR_BED == -2
398
+  #error "MAX6675 Thermocouples not supported for TEMP_SENSOR_BED"
389
 #elif TEMP_SENSOR_BED == -1
399
 #elif TEMP_SENSOR_BED == -1
390
   #define BED_USES_AD595
400
   #define BED_USES_AD595
391
 #elif TEMP_SENSOR_BED == 0
401
 #elif TEMP_SENSOR_BED == 0
398
 
408
 
399
 #if TEMP_SENSOR_CHAMBER == -4
409
 #if TEMP_SENSOR_CHAMBER == -4
400
   #define CHAMBER_USES_AD8495
410
   #define CHAMBER_USES_AD8495
401
-#elif TEMP_SENSOR_CHAMBER <= -2
402
-  #error "MAX6675 / MAX31855 Thermocouples not supported for TEMP_SENSOR_CHAMBER"
411
+#elif TEMP_SENSOR_CHAMBER == -3
412
+  #error "MAX31855 Thermocouples not supported for TEMP_SENSOR_CHAMBER"
413
+#elif TEMP_SENSOR_CHAMBER == -2
414
+  #error "MAX6675 Thermocouples not supported for TEMP_SENSOR_CHAMBER"
403
 #elif TEMP_SENSOR_CHAMBER == -1
415
 #elif TEMP_SENSOR_CHAMBER == -1
404
   #define CHAMBER_USES_AD595
416
   #define CHAMBER_USES_AD595
405
 #elif TEMP_SENSOR_CHAMBER > 0
417
 #elif TEMP_SENSOR_CHAMBER > 0
407
   #define CHAMBER_USES_THERMISTOR
419
   #define CHAMBER_USES_THERMISTOR
408
 #endif
420
 #endif
409
 
421
 
410
-#define HEATER_USES_AD8495 (ENABLED(HEATER_0_USES_AD8495) || ENABLED(HEATER_1_USES_AD8495) || ENABLED(HEATER_2_USES_AD8495) || ENABLED(HEATER_3_USES_AD8495))
422
+#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))
411
 
423
 
412
 #ifdef __SAM3X8E__
424
 #ifdef __SAM3X8E__
413
-  #define HEATER_USES_AD595 (ENABLED(HEATER_0_USES_AD595) || ENABLED(HEATER_1_USES_AD595) || ENABLED(HEATER_2_USES_AD595) || ENABLED(HEATER_3_USES_AD595))
425
+  #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))
414
 #endif
426
 #endif
415
 
427
 
416
 /**
428
 /**
746
 #endif
758
 #endif
747
 
759
 
748
 // Endstops and bed probe
760
 // Endstops and bed probe
749
-#define HAS_X_MIN (PIN_EXISTS(X_MIN) && !IS_X2_ENDSTOP(X,MIN) && !IS_Y2_ENDSTOP(X,MIN) && !IS_Z2_OR_PROBE(X,MIN))
750
-#define HAS_X_MAX (PIN_EXISTS(X_MAX) && !IS_X2_ENDSTOP(X,MAX) && !IS_Y2_ENDSTOP(X,MAX) && !IS_Z2_OR_PROBE(X,MAX))
751
-#define HAS_Y_MIN (PIN_EXISTS(Y_MIN) && !IS_X2_ENDSTOP(Y,MIN) && !IS_Y2_ENDSTOP(Y,MIN) && !IS_Z2_OR_PROBE(Y,MIN))
752
-#define HAS_Y_MAX (PIN_EXISTS(Y_MAX) && !IS_X2_ENDSTOP(Y,MAX) && !IS_Y2_ENDSTOP(Y,MAX) && !IS_Z2_OR_PROBE(Y,MAX))
753
-#define HAS_Z_MIN (PIN_EXISTS(Z_MIN) && !IS_X2_ENDSTOP(Z,MIN) && !IS_Y2_ENDSTOP(Z,MIN) && !IS_Z2_OR_PROBE(Z,MIN))
754
-#define HAS_Z_MAX (PIN_EXISTS(Z_MAX) && !IS_X2_ENDSTOP(Z,MAX) && !IS_Y2_ENDSTOP(Z,MAX) && !IS_Z2_OR_PROBE(Z,MAX))
761
+#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))
762
+#define HAS_X_MIN HAS_STOP_TEST(X,MIN)
763
+#define HAS_X_MAX HAS_STOP_TEST(X,MAX)
764
+#define HAS_Y_MIN HAS_STOP_TEST(Y,MIN)
765
+#define HAS_Y_MAX HAS_STOP_TEST(Y,MAX)
766
+#define HAS_Z_MIN HAS_STOP_TEST(Z,MIN)
767
+#define HAS_Z_MAX HAS_STOP_TEST(Z,MAX)
755
 #define HAS_X2_MIN (PIN_EXISTS(X2_MIN))
768
 #define HAS_X2_MIN (PIN_EXISTS(X2_MIN))
756
 #define HAS_X2_MAX (PIN_EXISTS(X2_MAX))
769
 #define HAS_X2_MAX (PIN_EXISTS(X2_MAX))
757
 #define HAS_Y2_MIN (PIN_EXISTS(Y2_MIN))
770
 #define HAS_Y2_MIN (PIN_EXISTS(Y2_MIN))
761
 #define HAS_Z_MIN_PROBE_PIN (PIN_EXISTS(Z_MIN_PROBE))
774
 #define HAS_Z_MIN_PROBE_PIN (PIN_EXISTS(Z_MIN_PROBE))
762
 
775
 
763
 // Thermistors
776
 // Thermistors
764
-#define HAS_TEMP_0 (PIN_EXISTS(TEMP_0) && TEMP_SENSOR_0 != 0 && TEMP_SENSOR_0 > -2)
765
-#define HAS_TEMP_1 (PIN_EXISTS(TEMP_1) && TEMP_SENSOR_1 != 0 && TEMP_SENSOR_1 > -2)
766
-#define HAS_TEMP_2 (PIN_EXISTS(TEMP_2) && TEMP_SENSOR_2 != 0 && TEMP_SENSOR_2 > -2)
767
-#define HAS_TEMP_3 (PIN_EXISTS(TEMP_3) && TEMP_SENSOR_3 != 0 && TEMP_SENSOR_3 > -2)
768
-#define HAS_TEMP_4 (PIN_EXISTS(TEMP_4) && TEMP_SENSOR_4 != 0 && TEMP_SENSOR_4 > -2)
769
-#define HAS_TEMP_HOTEND (HAS_TEMP_0 || ENABLED(HEATER_0_USES_MAX6675))
770
-#define HAS_TEMP_BED (PIN_EXISTS(TEMP_BED) && TEMP_SENSOR_BED != 0 && (TEMP_SENSOR_BED > -2 || TEMP_SENSOR_BED == -4))
771
-#define HAS_TEMP_CHAMBER (PIN_EXISTS(TEMP_CHAMBER) && TEMP_SENSOR_CHAMBER != 0 && TEMP_SENSOR_CHAMBER > -2)
777
+#define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && TEMP_SENSOR_##P > -2)
778
+#define HAS_TEMP_ADC_0 (HAS_ADC_TEST(0) && DISABLED(HEATER_0_USES_MAX6675))
779
+#define HAS_TEMP_ADC_1 HAS_ADC_TEST(1)
780
+#define HAS_TEMP_ADC_2 HAS_ADC_TEST(2)
781
+#define HAS_TEMP_ADC_3 HAS_ADC_TEST(3)
782
+#define HAS_TEMP_ADC_4 HAS_ADC_TEST(4)
783
+#define HAS_TEMP_ADC_BED HAS_ADC_TEST(BED)
784
+#define HAS_TEMP_ADC_CHAMBER HAS_ADC_TEST(CHAMBER)
785
+
786
+#define HAS_TEMP_HOTEND (HAS_TEMP_ADC_0 || ENABLED(HEATER_0_USES_MAX6675))
787
+#define HAS_TEMP_BED HAS_TEMP_ADC_BED
788
+#define HAS_TEMP_CHAMBER HAS_TEMP_ADC_CHAMBER
772
 
789
 
773
 // Heaters
790
 // Heaters
774
 #define HAS_HEATER_0 (PIN_EXISTS(HEATER_0))
791
 #define HAS_HEATER_0 (PIN_EXISTS(HEATER_0))

+ 31
- 31
Marlin/src/lcd/ultralcd.cpp Ver arquivo

1579
    */
1579
    */
1580
   void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb, const int16_t fan) {
1580
   void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb, const int16_t fan) {
1581
     if (temph > 0) thermalManager.setTargetHotend(min(heater_maxtemp[endnum], temph), endnum);
1581
     if (temph > 0) thermalManager.setTargetHotend(min(heater_maxtemp[endnum], temph), endnum);
1582
-    #if TEMP_SENSOR_BED != 0
1582
+    #if HAS_HEATED_BED
1583
       if (tempb >= 0) thermalManager.setTargetBed(tempb);
1583
       if (tempb >= 0) thermalManager.setTargetBed(tempb);
1584
     #else
1584
     #else
1585
       UNUSED(tempb);
1585
       UNUSED(tempb);
1596
     lcd_return_to_status();
1596
     lcd_return_to_status();
1597
   }
1597
   }
1598
 
1598
 
1599
-  #if TEMP_SENSOR_0 != 0
1599
+  #if HAS_TEMP_HOTEND
1600
     void lcd_preheat_m1_e0_only() { _lcd_preheat(0, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
1600
     void lcd_preheat_m1_e0_only() { _lcd_preheat(0, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
1601
     void lcd_preheat_m2_e0_only() { _lcd_preheat(0, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
1601
     void lcd_preheat_m2_e0_only() { _lcd_preheat(0, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
1602
-    #if TEMP_SENSOR_BED != 0
1602
+    #if HAS_HEATED_BED
1603
       void lcd_preheat_m1_e0() { _lcd_preheat(0, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
1603
       void lcd_preheat_m1_e0() { _lcd_preheat(0, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
1604
       void lcd_preheat_m2_e0() { _lcd_preheat(0, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
1604
       void lcd_preheat_m2_e0() { _lcd_preheat(0, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
1605
     #endif
1605
     #endif
1608
   #if HOTENDS > 1
1608
   #if HOTENDS > 1
1609
     void lcd_preheat_m1_e1_only() { _lcd_preheat(1, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
1609
     void lcd_preheat_m1_e1_only() { _lcd_preheat(1, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
1610
     void lcd_preheat_m2_e1_only() { _lcd_preheat(1, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
1610
     void lcd_preheat_m2_e1_only() { _lcd_preheat(1, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
1611
-    #if TEMP_SENSOR_BED != 0
1611
+    #if HAS_HEATED_BED
1612
       void lcd_preheat_m1_e1() { _lcd_preheat(1, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
1612
       void lcd_preheat_m1_e1() { _lcd_preheat(1, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
1613
       void lcd_preheat_m2_e1() { _lcd_preheat(1, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
1613
       void lcd_preheat_m2_e1() { _lcd_preheat(1, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
1614
     #endif
1614
     #endif
1615
     #if HOTENDS > 2
1615
     #if HOTENDS > 2
1616
       void lcd_preheat_m1_e2_only() { _lcd_preheat(2, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
1616
       void lcd_preheat_m1_e2_only() { _lcd_preheat(2, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
1617
       void lcd_preheat_m2_e2_only() { _lcd_preheat(2, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
1617
       void lcd_preheat_m2_e2_only() { _lcd_preheat(2, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
1618
-      #if TEMP_SENSOR_BED != 0
1618
+      #if HAS_HEATED_BED
1619
         void lcd_preheat_m1_e2() { _lcd_preheat(2, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
1619
         void lcd_preheat_m1_e2() { _lcd_preheat(2, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
1620
         void lcd_preheat_m2_e2() { _lcd_preheat(2, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
1620
         void lcd_preheat_m2_e2() { _lcd_preheat(2, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
1621
       #endif
1621
       #endif
1622
       #if HOTENDS > 3
1622
       #if HOTENDS > 3
1623
         void lcd_preheat_m1_e3_only() { _lcd_preheat(3, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
1623
         void lcd_preheat_m1_e3_only() { _lcd_preheat(3, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
1624
         void lcd_preheat_m2_e3_only() { _lcd_preheat(3, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
1624
         void lcd_preheat_m2_e3_only() { _lcd_preheat(3, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
1625
-        #if TEMP_SENSOR_BED != 0
1625
+        #if HAS_HEATED_BED
1626
           void lcd_preheat_m1_e3() { _lcd_preheat(3, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
1626
           void lcd_preheat_m1_e3() { _lcd_preheat(3, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
1627
           void lcd_preheat_m2_e3() { _lcd_preheat(3, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
1627
           void lcd_preheat_m2_e3() { _lcd_preheat(3, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
1628
         #endif
1628
         #endif
1629
         #if HOTENDS > 4
1629
         #if HOTENDS > 4
1630
           void lcd_preheat_m1_e4_only() { _lcd_preheat(4, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
1630
           void lcd_preheat_m1_e4_only() { _lcd_preheat(4, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
1631
           void lcd_preheat_m2_e4_only() { _lcd_preheat(4, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
1631
           void lcd_preheat_m2_e4_only() { _lcd_preheat(4, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
1632
-          #if TEMP_SENSOR_BED != 0
1632
+          #if HAS_HEATED_BED
1633
             void lcd_preheat_m1_e4() { _lcd_preheat(4, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
1633
             void lcd_preheat_m1_e4() { _lcd_preheat(4, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
1634
             void lcd_preheat_m2_e4() { _lcd_preheat(4, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
1634
             void lcd_preheat_m2_e4() { _lcd_preheat(4, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
1635
           #endif
1635
           #endif
1650
           #endif // HOTENDS > 3
1650
           #endif // HOTENDS > 3
1651
         #endif // HOTENDS > 2
1651
         #endif // HOTENDS > 2
1652
       #endif // HOTENDS > 1
1652
       #endif // HOTENDS > 1
1653
-      #if TEMP_SENSOR_BED != 0
1653
+      #if HAS_HEATED_BED
1654
         lcd_preheat_m1_e0();
1654
         lcd_preheat_m1_e0();
1655
       #else
1655
       #else
1656
         lcd_preheat_m1_e0_only();
1656
         lcd_preheat_m1_e0_only();
1669
           #endif // HOTENDS > 3
1669
           #endif // HOTENDS > 3
1670
         #endif // HOTENDS > 2
1670
         #endif // HOTENDS > 2
1671
       #endif // HOTENDS > 1
1671
       #endif // HOTENDS > 1
1672
-      #if TEMP_SENSOR_BED != 0
1672
+      #if HAS_HEATED_BED
1673
         lcd_preheat_m2_e0();
1673
         lcd_preheat_m2_e0();
1674
       #else
1674
       #else
1675
         lcd_preheat_m2_e0_only();
1675
         lcd_preheat_m2_e0_only();
1678
 
1678
 
1679
   #endif // HOTENDS > 1
1679
   #endif // HOTENDS > 1
1680
 
1680
 
1681
-  #if TEMP_SENSOR_BED != 0
1681
+  #if HAS_HEATED_BED
1682
     void lcd_preheat_m1_bedonly() { _lcd_preheat(0, 0, lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
1682
     void lcd_preheat_m1_bedonly() { _lcd_preheat(0, 0, lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
1683
     void lcd_preheat_m2_bedonly() { _lcd_preheat(0, 0, lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
1683
     void lcd_preheat_m2_bedonly() { _lcd_preheat(0, 0, lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
1684
   #endif
1684
   #endif
1685
 
1685
 
1686
-  #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)
1686
+  #if HAS_TEMP_HOTEND && (TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_4 != 0 || HAS_HEATED_BED)
1687
 
1687
 
1688
     void lcd_preheat_m1_menu() {
1688
     void lcd_preheat_m1_menu() {
1689
       START_MENU();
1689
       START_MENU();
1690
       MENU_BACK(MSG_PREPARE);
1690
       MENU_BACK(MSG_PREPARE);
1691
       #if HOTENDS == 1
1691
       #if HOTENDS == 1
1692
-        #if TEMP_SENSOR_BED != 0
1692
+        #if HAS_HEATED_BED
1693
           MENU_ITEM(function, MSG_PREHEAT_1, lcd_preheat_m1_e0);
1693
           MENU_ITEM(function, MSG_PREHEAT_1, lcd_preheat_m1_e0);
1694
           MENU_ITEM(function, MSG_PREHEAT_1_END, lcd_preheat_m1_e0_only);
1694
           MENU_ITEM(function, MSG_PREHEAT_1_END, lcd_preheat_m1_e0_only);
1695
         #else
1695
         #else
1696
           MENU_ITEM(function, MSG_PREHEAT_1, lcd_preheat_m1_e0_only);
1696
           MENU_ITEM(function, MSG_PREHEAT_1, lcd_preheat_m1_e0_only);
1697
         #endif
1697
         #endif
1698
       #else
1698
       #else
1699
-        #if TEMP_SENSOR_BED != 0
1699
+        #if HAS_HEATED_BED
1700
           MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H1, lcd_preheat_m1_e0);
1700
           MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H1, lcd_preheat_m1_e0);
1701
           MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E1, lcd_preheat_m1_e0_only);
1701
           MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E1, lcd_preheat_m1_e0_only);
1702
           MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H2, lcd_preheat_m1_e1);
1702
           MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H2, lcd_preheat_m1_e1);
1706
           MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H2, lcd_preheat_m1_e1_only);
1706
           MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H2, lcd_preheat_m1_e1_only);
1707
         #endif
1707
         #endif
1708
         #if HOTENDS > 2
1708
         #if HOTENDS > 2
1709
-          #if TEMP_SENSOR_BED != 0
1709
+          #if HAS_HEATED_BED
1710
             MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H3, lcd_preheat_m1_e2);
1710
             MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H3, lcd_preheat_m1_e2);
1711
             MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E3, lcd_preheat_m1_e2_only);
1711
             MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E3, lcd_preheat_m1_e2_only);
1712
           #else
1712
           #else
1713
             MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H3, lcd_preheat_m1_e2_only);
1713
             MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H3, lcd_preheat_m1_e2_only);
1714
           #endif
1714
           #endif
1715
           #if HOTENDS > 3
1715
           #if HOTENDS > 3
1716
-            #if TEMP_SENSOR_BED != 0
1716
+            #if HAS_HEATED_BED
1717
               MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H4, lcd_preheat_m1_e3);
1717
               MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H4, lcd_preheat_m1_e3);
1718
               MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E4, lcd_preheat_m1_e3_only);
1718
               MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E4, lcd_preheat_m1_e3_only);
1719
             #else
1719
             #else
1720
               MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H4, lcd_preheat_m1_e3_only);
1720
               MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H4, lcd_preheat_m1_e3_only);
1721
             #endif
1721
             #endif
1722
             #if HOTENDS > 4
1722
             #if HOTENDS > 4
1723
-              #if TEMP_SENSOR_BED != 0
1723
+              #if HAS_HEATED_BED
1724
                 MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H5, lcd_preheat_m1_e4);
1724
                 MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H5, lcd_preheat_m1_e4);
1725
                 MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E5, lcd_preheat_m1_e4_only);
1725
                 MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E5, lcd_preheat_m1_e4_only);
1726
               #else
1726
               #else
1731
         #endif // HOTENDS > 2
1731
         #endif // HOTENDS > 2
1732
         MENU_ITEM(function, MSG_PREHEAT_1_ALL, lcd_preheat_m1_all);
1732
         MENU_ITEM(function, MSG_PREHEAT_1_ALL, lcd_preheat_m1_all);
1733
       #endif // HOTENDS > 1
1733
       #endif // HOTENDS > 1
1734
-      #if TEMP_SENSOR_BED != 0
1734
+      #if HAS_HEATED_BED
1735
         MENU_ITEM(function, MSG_PREHEAT_1_BEDONLY, lcd_preheat_m1_bedonly);
1735
         MENU_ITEM(function, MSG_PREHEAT_1_BEDONLY, lcd_preheat_m1_bedonly);
1736
       #endif
1736
       #endif
1737
       END_MENU();
1737
       END_MENU();
1741
       START_MENU();
1741
       START_MENU();
1742
       MENU_BACK(MSG_PREPARE);
1742
       MENU_BACK(MSG_PREPARE);
1743
       #if HOTENDS == 1
1743
       #if HOTENDS == 1
1744
-        #if TEMP_SENSOR_BED != 0
1744
+        #if HAS_HEATED_BED
1745
           MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0);
1745
           MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0);
1746
           MENU_ITEM(function, MSG_PREHEAT_2_END, lcd_preheat_m2_e0_only);
1746
           MENU_ITEM(function, MSG_PREHEAT_2_END, lcd_preheat_m2_e0_only);
1747
         #else
1747
         #else
1748
           MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0_only);
1748
           MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0_only);
1749
         #endif
1749
         #endif
1750
       #else
1750
       #else
1751
-        #if TEMP_SENSOR_BED != 0
1751
+        #if HAS_HEATED_BED
1752
           MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H1, lcd_preheat_m2_e0);
1752
           MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H1, lcd_preheat_m2_e0);
1753
           MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E1, lcd_preheat_m2_e0_only);
1753
           MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E1, lcd_preheat_m2_e0_only);
1754
           MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H2, lcd_preheat_m2_e1);
1754
           MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H2, lcd_preheat_m2_e1);
1758
           MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H2, lcd_preheat_m2_e1_only);
1758
           MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H2, lcd_preheat_m2_e1_only);
1759
         #endif
1759
         #endif
1760
         #if HOTENDS > 2
1760
         #if HOTENDS > 2
1761
-          #if TEMP_SENSOR_BED != 0
1761
+          #if HAS_HEATED_BED
1762
             MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H3, lcd_preheat_m2_e2);
1762
             MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H3, lcd_preheat_m2_e2);
1763
             MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E3, lcd_preheat_m2_e2_only);
1763
             MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E3, lcd_preheat_m2_e2_only);
1764
           #else
1764
           #else
1765
             MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H3, lcd_preheat_m2_e2_only);
1765
             MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H3, lcd_preheat_m2_e2_only);
1766
           #endif
1766
           #endif
1767
           #if HOTENDS > 3
1767
           #if HOTENDS > 3
1768
-            #if TEMP_SENSOR_BED != 0
1768
+            #if HAS_HEATED_BED
1769
               MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H4, lcd_preheat_m2_e3);
1769
               MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H4, lcd_preheat_m2_e3);
1770
               MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E4, lcd_preheat_m2_e3_only);
1770
               MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E4, lcd_preheat_m2_e3_only);
1771
             #else
1771
             #else
1772
               MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H4, lcd_preheat_m2_e3_only);
1772
               MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H4, lcd_preheat_m2_e3_only);
1773
             #endif
1773
             #endif
1774
             #if HOTENDS > 4
1774
             #if HOTENDS > 4
1775
-              #if TEMP_SENSOR_BED != 0
1775
+              #if HAS_HEATED_BED
1776
                 MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H5, lcd_preheat_m2_e4);
1776
                 MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H5, lcd_preheat_m2_e4);
1777
                 MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E5, lcd_preheat_m2_e4_only);
1777
                 MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E5, lcd_preheat_m2_e4_only);
1778
               #else
1778
               #else
1783
         #endif // HOTENDS > 2
1783
         #endif // HOTENDS > 2
1784
         MENU_ITEM(function, MSG_PREHEAT_2_ALL, lcd_preheat_m2_all);
1784
         MENU_ITEM(function, MSG_PREHEAT_2_ALL, lcd_preheat_m2_all);
1785
       #endif // HOTENDS > 1
1785
       #endif // HOTENDS > 1
1786
-      #if TEMP_SENSOR_BED != 0
1786
+      #if HAS_HEATED_BED
1787
         MENU_ITEM(function, MSG_PREHEAT_2_BEDONLY, lcd_preheat_m2_bedonly);
1787
         MENU_ITEM(function, MSG_PREHEAT_2_BEDONLY, lcd_preheat_m2_bedonly);
1788
       #endif
1788
       #endif
1789
       END_MENU();
1789
       END_MENU();
1790
     }
1790
     }
1791
 
1791
 
1792
-  #endif // TEMP_SENSOR_0 && (TEMP_SENSOR_1 || TEMP_SENSOR_2 || TEMP_SENSOR_3 || TEMP_SENSOR_4 || TEMP_SENSOR_BED)
1792
+  #endif // HAS_TEMP_HOTEND && (TEMP_SENSOR_1 || TEMP_SENSOR_2 || TEMP_SENSOR_3 || TEMP_SENSOR_4 || TEMP_SENSOR_BED)
1793
 
1793
 
1794
   void lcd_cooldown() {
1794
   void lcd_cooldown() {
1795
     #if FAN_COUNT > 0
1795
     #if FAN_COUNT > 0
2780
       }
2780
       }
2781
     #endif // ADVANCED_PAUSE_FEATURE
2781
     #endif // ADVANCED_PAUSE_FEATURE
2782
 
2782
 
2783
-    #if TEMP_SENSOR_0 != 0
2783
+    #if HAS_TEMP_HOTEND
2784
 
2784
 
2785
       //
2785
       //
2786
       // Cooldown
2786
       // Cooldown
2795
       //
2795
       //
2796
       // Preheat for Material 1 and 2
2796
       // Preheat for Material 1 and 2
2797
       //
2797
       //
2798
-      #if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_4 != 0 || TEMP_SENSOR_BED != 0
2798
+      #if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_4 != 0 || HAS_HEATED_BED
2799
         MENU_ITEM(submenu, MSG_PREHEAT_1, lcd_preheat_m1_menu);
2799
         MENU_ITEM(submenu, MSG_PREHEAT_1, lcd_preheat_m1_menu);
2800
         MENU_ITEM(submenu, MSG_PREHEAT_2, lcd_preheat_m2_menu);
2800
         MENU_ITEM(submenu, MSG_PREHEAT_2, lcd_preheat_m2_menu);
2801
       #else
2801
       #else
2803
         MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0_only);
2803
         MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0_only);
2804
       #endif
2804
       #endif
2805
 
2805
 
2806
-    #endif // TEMP_SENSOR_0 != 0
2806
+    #endif // HAS_TEMP_HOTEND
2807
 
2807
 
2808
     //
2808
     //
2809
     // BLTouch Self-Test and Reset
2809
     // BLTouch Self-Test and Reset
3538
     //
3538
     //
3539
     // Autotemp, Min, Max, Fact
3539
     // Autotemp, Min, Max, Fact
3540
     //
3540
     //
3541
-    #if ENABLED(AUTOTEMP) && (TEMP_SENSOR_0 != 0)
3541
+    #if ENABLED(AUTOTEMP) && (HAS_TEMP_HOTEND)
3542
       MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &planner.autotemp_enabled);
3542
       MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &planner.autotemp_enabled);
3543
       MENU_ITEM_EDIT(float3, MSG_MIN, &planner.autotemp_min, 0, HEATER_0_MAXTEMP - 15);
3543
       MENU_ITEM_EDIT(float3, MSG_MIN, &planner.autotemp_min, 0, HEATER_0_MAXTEMP - 15);
3544
       MENU_ITEM_EDIT(float3, MSG_MAX, &planner.autotemp_max, 0, HEATER_0_MAXTEMP - 15);
3544
       MENU_ITEM_EDIT(float3, MSG_MAX, &planner.autotemp_max, 0, HEATER_0_MAXTEMP - 15);
3633
       START_MENU();
3633
       START_MENU();
3634
       MENU_BACK(MSG_TEMPERATURE);
3634
       MENU_BACK(MSG_TEMPERATURE);
3635
       MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &lcd_preheat_fan_speed[material], 0, 255);
3635
       MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &lcd_preheat_fan_speed[material], 0, 255);
3636
-      #if TEMP_SENSOR_0 != 0
3636
+      #if HAS_TEMP_HOTEND
3637
         MENU_ITEM_EDIT(int3, MSG_NOZZLE, &lcd_preheat_hotend_temp[material], MINTEMP_ALL, MAXTEMP_ALL - 15);
3637
         MENU_ITEM_EDIT(int3, MSG_NOZZLE, &lcd_preheat_hotend_temp[material], MINTEMP_ALL, MAXTEMP_ALL - 15);
3638
       #endif
3638
       #endif
3639
-      #if TEMP_SENSOR_BED != 0
3639
+      #if HAS_HEATED_BED
3640
         MENU_ITEM_EDIT(int3, MSG_BED, &lcd_preheat_bed_temp[material], BED_MINTEMP, BED_MAXTEMP - 15);
3640
         MENU_ITEM_EDIT(int3, MSG_BED, &lcd_preheat_bed_temp[material], BED_MINTEMP, BED_MAXTEMP - 15);
3641
       #endif
3641
       #endif
3642
       #if ENABLED(EEPROM_SETTINGS)
3642
       #if ENABLED(EEPROM_SETTINGS)
4154
         STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_4_MAXTEMP), false);
4154
         STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_4_MAXTEMP), false);
4155
       #endif
4155
       #endif
4156
 
4156
 
4157
-      #if TEMP_SENSOR_BED != 0
4157
+      #if HAS_HEATED_BED
4158
         #undef THERMISTOR_ID
4158
         #undef THERMISTOR_ID
4159
         #define THERMISTOR_ID TEMP_SENSOR_BED
4159
         #define THERMISTOR_ID TEMP_SENSOR_BED
4160
         #include "thermistornames.h"
4160
         #include "thermistornames.h"

+ 75
- 85
Marlin/src/module/temperature.cpp Ver arquivo

952
     if (e == 0) return 0.25 * raw;
952
     if (e == 0) return 0.25 * raw;
953
   #endif
953
   #endif
954
 
954
 
955
+  // Thermistor with conversion table?
955
   if (heater_ttbl_map[e] != NULL) {
956
   if (heater_ttbl_map[e] != NULL) {
956
-    float celsius = 0;
957
-    uint8_t i;
958
     short(*tt)[][2] = (short(*)[][2])(heater_ttbl_map[e]);
957
     short(*tt)[][2] = (short(*)[][2])(heater_ttbl_map[e]);
959
-
960
-    for (i = 1; i < heater_ttbllen_map[e]; i++) {
961
-      if (PGM_RD_W((*tt)[i][0]) > raw) {
962
-        celsius = PGM_RD_W((*tt)[i - 1][1]) +
963
-                  (raw - PGM_RD_W((*tt)[i - 1][0])) *
964
-                  (float)(PGM_RD_W((*tt)[i][1]) - PGM_RD_W((*tt)[i - 1][1])) /
965
-                  (float)(PGM_RD_W((*tt)[i][0]) - PGM_RD_W((*tt)[i - 1][0]));
966
-        break;
958
+    for (uint8_t i = 1; i < heater_ttbllen_map[e]; i++) {
959
+      const short entry10 = PGM_RD_W((*tt)[i][0]);
960
+      if (entry10 > raw) {
961
+        const short entry00 = PGM_RD_W((*tt)[i - 1][0]),
962
+                    entry01 = PGM_RD_W((*tt)[i - 1][1]),
963
+                    entry11 = PGM_RD_W((*tt)[i][1]);
964
+        return entry01 + (raw - entry00) * float(entry11 - entry01) / float(entry10 - entry00);
967
       }
965
       }
968
     }
966
     }
969
-
970
-    // Overflow: Set to last value in the table
971
-    if (i == heater_ttbllen_map[e]) celsius = PGM_RD_W((*tt)[i - 1][1]);
972
-
973
-    return celsius;
967
+    return PGM_RD_W((*tt)[heater_ttbllen_map[e] - 1][1]); // Overflow: Return last value in the table
974
   }
968
   }
975
-  #if defined(HEATER_USES_AD8495)
976
-  return ((raw * (660.0 / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD8495_GAIN)) + TEMP_SENSOR_AD8495_OFFSET;
977
-  #else
978
-  return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN)) + TEMP_SENSOR_AD595_OFFSET;
979
-  #endif  
969
+
970
+  // Thermocouple with amplifier ADC interface
971
+  return (raw *
972
+    #if HEATER_USES_AD8495
973
+      660.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD8495_GAIN) + TEMP_SENSOR_AD8495_OFFSET
974
+    #elif HEATER_USES_AD595
975
+      5.0 * 100.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET
976
+    #else
977
+      0
978
+    #endif
979
+  );
980
 }
980
 }
981
 
981
 
982
 #if HAS_HEATED_BED
982
 #if HAS_HEATED_BED
984
   // For bed temperature measurement.
984
   // For bed temperature measurement.
985
   float Temperature::analog2tempBed(const int raw) {
985
   float Temperature::analog2tempBed(const int raw) {
986
     #if ENABLED(BED_USES_THERMISTOR)
986
     #if ENABLED(BED_USES_THERMISTOR)
987
-      float celsius = 0;
988
-      byte i;
989
-
990
-      for (i = 1; i < BEDTEMPTABLE_LEN; i++) {
991
-        if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) {
992
-          celsius  = PGM_RD_W(BEDTEMPTABLE[i - 1][1]) +
993
-                     (raw - PGM_RD_W(BEDTEMPTABLE[i - 1][0])) *
994
-                     (float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i - 1][1])) /
995
-                     (float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i - 1][0]));
996
-          break;
987
+
988
+      // Thermistor with conversion table
989
+      for (uint8_t i = 1; i < BEDTEMPTABLE_LEN; i++) {
990
+        const short entry10 = PGM_RD_W(BEDTEMPTABLE[i][0]);
991
+        if (entry10 > raw) {
992
+          const short entry00 = PGM_RD_W(BEDTEMPTABLE[i - 1][0]),
993
+                      entry01 = PGM_RD_W(BEDTEMPTABLE[i - 1][1]),
994
+                      entry11 = PGM_RD_W(BEDTEMPTABLE[i][1]);
995
+          return entry01 + (raw - entry00) * float(entry11 - entry01) / float(entry10 - entry00);
997
         }
996
         }
998
       }
997
       }
999
-
1000
-      // Overflow: Set to last value in the table
1001
-      if (i == BEDTEMPTABLE_LEN) celsius = PGM_RD_W(BEDTEMPTABLE[i - 1][1]);
1002
-
1003
-      return celsius;
1004
-
1005
-    #elif defined(BED_USES_AD595)
1006
-
1007
-      return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN)) + TEMP_SENSOR_AD595_OFFSET;
1008
-
1009
-	#elif defined(BED_USES_AD8495)
1010
-
1011
-      return ((raw * (660.0 / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD8495_GAIN)) + TEMP_SENSOR_AD8495_OFFSET;
998
+      return PGM_RD_W(BEDTEMPTABLE[BEDTEMPTABLE_LEN - 1][1]); // Overflow: Return last value in the table
1012
 
999
 
1013
     #else
1000
     #else
1014
 
1001
 
1015
-      UNUSED(raw);
1016
-      return 0;
1002
+      // Thermocouple with amplifier ADC interface
1003
+      return (raw *
1004
+        #if ENABLED(BED_USES_AD595)
1005
+          5.0 * 100.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET
1006
+        #elif ENABLED(BED_USES_AD8495)
1007
+          660.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD8495_GAIN) + TEMP_SENSOR_AD8495_OFFSET
1008
+        #else
1009
+          0
1010
+        #endif
1011
+      );
1017
 
1012
 
1018
     #endif
1013
     #endif
1019
   }
1014
   }
1024
   // For chamber temperature measurement.
1019
   // For chamber temperature measurement.
1025
   float Temperature::analog2tempChamber(const int raw) {
1020
   float Temperature::analog2tempChamber(const int raw) {
1026
     #if ENABLED(CHAMBER_USES_THERMISTOR)
1021
     #if ENABLED(CHAMBER_USES_THERMISTOR)
1027
-      float celsius = 0;
1028
-      byte i;
1029
-
1030
-      for (i = 1; i < CHAMBERTEMPTABLE_LEN; i++) {
1031
-        if (PGM_RD_W(CHAMBERTEMPTABLE[i][0]) > raw) {
1032
-          celsius  = PGM_RD_W(CHAMBERTEMPTABLE[i - 1][1]) +
1033
-                     (raw - PGM_RD_W(CHAMBERTEMPTABLE[i - 1][0])) *
1034
-                     (float)(PGM_RD_W(CHAMBERTEMPTABLE[i][1]) - PGM_RD_W(CHAMBERTEMPTABLE[i - 1][1])) /
1035
-                     (float)(PGM_RD_W(CHAMBERTEMPTABLE[i][0]) - PGM_RD_W(CHAMBERTEMPTABLE[i - 1][0]));
1036
-          break;
1022
+
1023
+      // Thermistor with conversion table
1024
+      for (uint8_t i = 1; i < CHAMBERTEMPTABLE_LEN; i++) {
1025
+        const short entry10 = PGM_RD_W(CHAMBERTEMPTABLE[i][0]);
1026
+        if (entry10 > raw) {
1027
+          const short entry00 = PGM_RD_W(CHAMBERTEMPTABLE[i - 1][0]),
1028
+                      entry01 = PGM_RD_W(CHAMBERTEMPTABLE[i - 1][1]),
1029
+                      entry11 = PGM_RD_W(CHAMBERTEMPTABLE[i][1]);
1030
+          return entry01 + (raw - entry00) * float(entry11 - entry01) / float(entry10 - entry00);
1037
         }
1031
         }
1038
       }
1032
       }
1033
+      return PGM_RD_W(CHAMBERTEMPTABLE[CHAMBERTEMPTABLE_LEN - 1][1]); // Overflow: Return last value in the table
1039
 
1034
 
1040
-      // Overflow: Set to last value in the table
1041
-      if (i == CHAMBERTEMPTABLE_LEN) celsius = PGM_RD_W(CHAMBERTEMPTABLE[i - 1][1]);
1042
-
1043
-      return celsius;
1044
-
1045
-    #elif defined(CHAMBER_USES_AD595)
1046
-
1047
-      return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN)) + TEMP_SENSOR_AD595_OFFSET;
1048
-
1049
-    #elif defined(CHAMBER_USES_AD8495)
1050
-
1051
-      return ((raw * (660.0 / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD8495_GAIN)) + TEMP_SENSOR_AD8495_OFFSET;
1052
-	  
1053
     #else
1035
     #else
1054
 
1036
 
1055
-      UNUSED(raw);
1056
-      return 0;
1037
+      // Thermocouple with amplifier ADC interface
1038
+      return (raw *
1039
+        #if ENABLED(CHAMBER_USES_AD595)
1040
+          5.0 * 100.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET
1041
+        #elif ENABLED(CHAMBER_USES_AD8495)
1042
+          660.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD8495_GAIN) + TEMP_SENSOR_AD8495_OFFSET
1043
+        #else
1044
+          0
1045
+        #endif
1046
+      );
1057
 
1047
 
1058
     #endif
1048
     #endif
1059
   }
1049
   }
1208
 
1198
 
1209
   HAL_adc_init();
1199
   HAL_adc_init();
1210
 
1200
 
1211
-  #if HAS_TEMP_0
1201
+  #if HAS_TEMP_ADC_0
1212
     HAL_ANALOG_SELECT(TEMP_0_PIN);
1202
     HAL_ANALOG_SELECT(TEMP_0_PIN);
1213
   #endif
1203
   #endif
1214
-  #if HAS_TEMP_1
1204
+  #if HAS_TEMP_ADC_1
1215
     HAL_ANALOG_SELECT(TEMP_1_PIN);
1205
     HAL_ANALOG_SELECT(TEMP_1_PIN);
1216
   #endif
1206
   #endif
1217
-  #if HAS_TEMP_2
1207
+  #if HAS_TEMP_ADC_2
1218
     HAL_ANALOG_SELECT(TEMP_2_PIN);
1208
     HAL_ANALOG_SELECT(TEMP_2_PIN);
1219
   #endif
1209
   #endif
1220
-  #if HAS_TEMP_3
1210
+  #if HAS_TEMP_ADC_3
1221
     HAL_ANALOG_SELECT(TEMP_3_PIN);
1211
     HAL_ANALOG_SELECT(TEMP_3_PIN);
1222
   #endif
1212
   #endif
1223
-  #if HAS_TEMP_4
1213
+  #if HAS_TEMP_ADC_4
1224
     HAL_ANALOG_SELECT(TEMP_4_PIN);
1214
     HAL_ANALOG_SELECT(TEMP_4_PIN);
1225
   #endif
1215
   #endif
1226
   #if HAS_HEATED_BED
1216
   #if HAS_HEATED_BED
1687
  * Get raw temperatures
1677
  * Get raw temperatures
1688
  */
1678
  */
1689
 void Temperature::set_current_temp_raw() {
1679
 void Temperature::set_current_temp_raw() {
1690
-  #if HAS_TEMP_0 && DISABLED(HEATER_0_USES_MAX6675)
1680
+  #if HAS_TEMP_ADC_0 && DISABLED(HEATER_0_USES_MAX6675)
1691
     current_temperature_raw[0] = raw_temp_value[0];
1681
     current_temperature_raw[0] = raw_temp_value[0];
1692
   #endif
1682
   #endif
1693
-  #if HAS_TEMP_1
1683
+  #if HAS_TEMP_ADC_1
1694
     #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
1684
     #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
1695
       redundant_temperature_raw = raw_temp_value[1];
1685
       redundant_temperature_raw = raw_temp_value[1];
1696
     #else
1686
     #else
1697
       current_temperature_raw[1] = raw_temp_value[1];
1687
       current_temperature_raw[1] = raw_temp_value[1];
1698
     #endif
1688
     #endif
1699
-    #if HAS_TEMP_2
1689
+    #if HAS_TEMP_ADC_2
1700
       current_temperature_raw[2] = raw_temp_value[2];
1690
       current_temperature_raw[2] = raw_temp_value[2];
1701
-      #if HAS_TEMP_3
1691
+      #if HAS_TEMP_ADC_3
1702
         current_temperature_raw[3] = raw_temp_value[3];
1692
         current_temperature_raw[3] = raw_temp_value[3];
1703
-        #if HAS_TEMP_4
1693
+        #if HAS_TEMP_ADC_4
1704
           current_temperature_raw[4] = raw_temp_value[4];
1694
           current_temperature_raw[4] = raw_temp_value[4];
1705
         #endif
1695
         #endif
1706
       #endif
1696
       #endif
2050
         adc_sensor_state = (ADCSensorState)0; // Fall-through to start first sensor now
2040
         adc_sensor_state = (ADCSensorState)0; // Fall-through to start first sensor now
2051
     }
2041
     }
2052
 
2042
 
2053
-    #if HAS_TEMP_0
2043
+    #if HAS_TEMP_ADC_0
2054
       case PrepareTemp_0:
2044
       case PrepareTemp_0:
2055
         HAL_START_ADC(TEMP_0_PIN);
2045
         HAL_START_ADC(TEMP_0_PIN);
2056
         break;
2046
         break;
2077
         break;
2067
         break;
2078
     #endif
2068
     #endif
2079
 
2069
 
2080
-    #if HAS_TEMP_1
2070
+    #if HAS_TEMP_ADC_1
2081
       case PrepareTemp_1:
2071
       case PrepareTemp_1:
2082
         HAL_START_ADC(TEMP_1_PIN);
2072
         HAL_START_ADC(TEMP_1_PIN);
2083
         break;
2073
         break;
2086
         break;
2076
         break;
2087
     #endif
2077
     #endif
2088
 
2078
 
2089
-    #if HAS_TEMP_2
2079
+    #if HAS_TEMP_ADC_2
2090
       case PrepareTemp_2:
2080
       case PrepareTemp_2:
2091
         HAL_START_ADC(TEMP_2_PIN);
2081
         HAL_START_ADC(TEMP_2_PIN);
2092
         break;
2082
         break;
2095
         break;
2085
         break;
2096
     #endif
2086
     #endif
2097
 
2087
 
2098
-    #if HAS_TEMP_3
2088
+    #if HAS_TEMP_ADC_3
2099
       case PrepareTemp_3:
2089
       case PrepareTemp_3:
2100
         HAL_START_ADC(TEMP_3_PIN);
2090
         HAL_START_ADC(TEMP_3_PIN);
2101
         break;
2091
         break;
2104
         break;
2094
         break;
2105
     #endif
2095
     #endif
2106
 
2096
 
2107
-    #if HAS_TEMP_4
2097
+    #if HAS_TEMP_ADC_4
2108
       case PrepareTemp_4:
2098
       case PrepareTemp_4:
2109
         HAL_START_ADC(TEMP_4_PIN);
2099
         HAL_START_ADC(TEMP_4_PIN);
2110
         break;
2100
         break;

+ 5
- 5
Marlin/src/module/temperature.h Ver arquivo

50
  * States for ADC reading in the ISR
50
  * States for ADC reading in the ISR
51
  */
51
  */
52
 enum ADCSensorState : char {
52
 enum ADCSensorState : char {
53
-  #if HAS_TEMP_0
53
+  #if HAS_TEMP_ADC_0
54
     PrepareTemp_0,
54
     PrepareTemp_0,
55
     MeasureTemp_0,
55
     MeasureTemp_0,
56
   #endif
56
   #endif
57
-  #if HAS_TEMP_1
57
+  #if HAS_TEMP_ADC_1
58
     PrepareTemp_1,
58
     PrepareTemp_1,
59
     MeasureTemp_1,
59
     MeasureTemp_1,
60
   #endif
60
   #endif
61
-  #if HAS_TEMP_2
61
+  #if HAS_TEMP_ADC_2
62
     PrepareTemp_2,
62
     PrepareTemp_2,
63
     MeasureTemp_2,
63
     MeasureTemp_2,
64
   #endif
64
   #endif
65
-  #if HAS_TEMP_3
65
+  #if HAS_TEMP_ADC_3
66
     PrepareTemp_3,
66
     PrepareTemp_3,
67
     MeasureTemp_3,
67
     MeasureTemp_3,
68
   #endif
68
   #endif
69
-  #if HAS_TEMP_4
69
+  #if HAS_TEMP_ADC_4
70
     PrepareTemp_4,
70
     PrepareTemp_4,
71
     MeasureTemp_4,
71
     MeasureTemp_4,
72
   #endif
72
   #endif

Carregando…
Cancelar
Salvar