Browse Source

✨ More flexible redundant temp sensor (#22085)

Katelyn Schiesser 3 years ago
parent
commit
629551d9bc
No account linked to committer's email address
65 changed files with 573 additions and 254 deletions
  1. 23
    5
      Marlin/Configuration.h
  2. 6
    0
      Marlin/Configuration_adv.h
  3. 1
    1
      Marlin/src/HAL/LPC1768/tft/xpt2046.h
  4. 1
    1
      Marlin/src/HAL/STM32/tft/xpt2046.h
  5. 1
    1
      Marlin/src/HAL/STM32F1/tft/xpt2046.h
  6. 2
    2
      Marlin/src/MarlinCore.cpp
  7. 1
    5
      Marlin/src/gcode/temp/M105.cpp
  8. 166
    27
      Marlin/src/inc/Conditionals_post.h
  9. 79
    12
      Marlin/src/inc/SanityCheck.h
  10. 145
    72
      Marlin/src/module/temperature.cpp
  11. 33
    13
      Marlin/src/module/temperature.h
  12. 1
    1
      Marlin/src/module/thermistor/thermistor_1.h
  13. 1
    1
      Marlin/src/module/thermistor/thermistor_10.h
  14. 1
    1
      Marlin/src/module/thermistor/thermistor_1010.h
  15. 1
    1
      Marlin/src/module/thermistor/thermistor_1047.h
  16. 1
    1
      Marlin/src/module/thermistor/thermistor_11.h
  17. 1
    1
      Marlin/src/module/thermistor/thermistor_110.h
  18. 1
    1
      Marlin/src/module/thermistor/thermistor_12.h
  19. 1
    1
      Marlin/src/module/thermistor/thermistor_13.h
  20. 1
    1
      Marlin/src/module/thermistor/thermistor_147.h
  21. 1
    1
      Marlin/src/module/thermistor/thermistor_15.h
  22. 1
    1
      Marlin/src/module/thermistor/thermistor_17.h
  23. 1
    1
      Marlin/src/module/thermistor/thermistor_18.h
  24. 1
    1
      Marlin/src/module/thermistor/thermistor_2.h
  25. 1
    1
      Marlin/src/module/thermistor/thermistor_20.h
  26. 1
    1
      Marlin/src/module/thermistor/thermistor_201.h
  27. 1
    1
      Marlin/src/module/thermistor/thermistor_202.h
  28. 1
    1
      Marlin/src/module/thermistor/thermistor_21.h
  29. 1
    1
      Marlin/src/module/thermistor/thermistor_22.h
  30. 1
    1
      Marlin/src/module/thermistor/thermistor_23.h
  31. 1
    1
      Marlin/src/module/thermistor/thermistor_3.h
  32. 1
    1
      Marlin/src/module/thermistor/thermistor_30.h
  33. 1
    1
      Marlin/src/module/thermistor/thermistor_331.h
  34. 1
    1
      Marlin/src/module/thermistor/thermistor_332.h
  35. 1
    1
      Marlin/src/module/thermistor/thermistor_4.h
  36. 1
    1
      Marlin/src/module/thermistor/thermistor_5.h
  37. 1
    1
      Marlin/src/module/thermistor/thermistor_501.h
  38. 1
    1
      Marlin/src/module/thermistor/thermistor_502.h
  39. 1
    1
      Marlin/src/module/thermistor/thermistor_503.h
  40. 1
    1
      Marlin/src/module/thermistor/thermistor_51.h
  41. 1
    1
      Marlin/src/module/thermistor/thermistor_512.h
  42. 1
    1
      Marlin/src/module/thermistor/thermistor_52.h
  43. 1
    1
      Marlin/src/module/thermistor/thermistor_55.h
  44. 1
    1
      Marlin/src/module/thermistor/thermistor_6.h
  45. 1
    1
      Marlin/src/module/thermistor/thermistor_60.h
  46. 1
    1
      Marlin/src/module/thermistor/thermistor_61.h
  47. 1
    1
      Marlin/src/module/thermistor/thermistor_66.h
  48. 1
    1
      Marlin/src/module/thermistor/thermistor_666.h
  49. 1
    1
      Marlin/src/module/thermistor/thermistor_67.h
  50. 1
    1
      Marlin/src/module/thermistor/thermistor_7.h
  51. 1
    1
      Marlin/src/module/thermistor/thermistor_70.h
  52. 1
    1
      Marlin/src/module/thermistor/thermistor_71.h
  53. 1
    1
      Marlin/src/module/thermistor/thermistor_75.h
  54. 1
    1
      Marlin/src/module/thermistor/thermistor_8.h
  55. 1
    1
      Marlin/src/module/thermistor/thermistor_9.h
  56. 1
    1
      Marlin/src/module/thermistor/thermistor_99.h
  57. 1
    1
      Marlin/src/module/thermistor/thermistor_998.h
  58. 1
    1
      Marlin/src/module/thermistor/thermistor_999.h
  59. 62
    62
      Marlin/src/module/thermistor/thermistors.h
  60. 1
    1
      buildroot/bin/mftest
  61. 1
    1
      buildroot/bin/opt_disable
  62. 1
    1
      buildroot/bin/opt_enable
  63. 1
    1
      buildroot/bin/opt_set
  64. 1
    1
      buildroot/bin/pins_set
  65. 1
    1
      buildroot/share/git/mfconfig

+ 23
- 5
Marlin/Configuration.h View File

@@ -472,6 +472,7 @@
472 472
 #define TEMP_SENSOR_PROBE 0
473 473
 #define TEMP_SENSOR_CHAMBER 0
474 474
 #define TEMP_SENSOR_COOLER 0
475
+#define TEMP_SENSOR_REDUNDANT 0
475 476
 
476 477
 // Dummy thermistor constant temperature readings, for use with 998 and 999
477 478
 #define DUMMY_THERMISTOR_998_VALUE  25
@@ -483,11 +484,6 @@
483 484
 //#define MAX31865_SENSOR_OHMS_1      100
484 485
 //#define MAX31865_CALIBRATION_OHMS_1 430
485 486
 
486
-// Use temp sensor 1 as a redundant sensor with sensor 0. If the readings
487
-// from the two sensors differ too much the print will be aborted.
488
-//#define TEMP_SENSOR_1_AS_REDUNDANT
489
-#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10
490
-
491 487
 #define TEMP_RESIDENCY_TIME         10  // (seconds) Time to wait for hotend to "settle" in M109
492 488
 #define TEMP_WINDOW                  1  // (°C) Temperature proximity for the "temperature reached" timer
493 489
 #define TEMP_HYSTERESIS              3  // (°C) Temperature proximity considered "close enough" to the target
@@ -500,6 +496,28 @@
500 496
 #define TEMP_CHAMBER_WINDOW          1  // (°C) Temperature proximity for the "temperature reached" timer
501 497
 #define TEMP_CHAMBER_HYSTERESIS      3  // (°C) Temperature proximity considered "close enough" to the target
502 498
 
499
+/**
500
+ * Redundant Temperature Sensor (TEMP_SENSOR_REDUNDANT)
501
+ *
502
+ * Use a temp sensor as a redundant sensor for another reading. Select an unused temperature sensor, and another
503
+ * sensor you'd like it to be redundant for. If the two thermistors differ by TEMP_SENSOR_REDUNDANT_MAX_DIFF (°C),
504
+ * the print will be aborted. Whichever sensor is selected will have its normal functions disabled; i.e. selecting
505
+ * the Bed sensor (-1) will disable bed heating/monitoring.
506
+ *
507
+ * Use the following to select temp sensors:
508
+ *    -5 : Cooler
509
+ *    -4 : Probe
510
+ *    -3 : not used
511
+ *    -2 : Chamber
512
+ *    -1 : Bed
513
+ *   0-7 : E0 through E7
514
+ */
515
+#if TEMP_SENSOR_REDUNDANT
516
+  #define TEMP_SENSOR_REDUNDANT_SOURCE     1  // The sensor that will provide the redundant reading.
517
+  #define TEMP_SENSOR_REDUNDANT_TARGET     0  // The sensor that we are providing a redundant reading for.
518
+  #define TEMP_SENSOR_REDUNDANT_MAX_DIFF  10  // (°C) Temperature difference that will trigger a print abort.
519
+#endif
520
+
503 521
 // Below this temperature the heater will be switched off
504 522
 // because it probably indicates a broken thermistor wire.
505 523
 #define HEATER_0_MINTEMP   5

+ 6
- 0
Marlin/Configuration_adv.h View File

@@ -125,6 +125,12 @@
125 125
   #define PROBE_BETA                   3950    // Beta value
126 126
 #endif
127 127
 
128
+#if TEMP_SENSOR_REDUNDANT == 1000
129
+  #define REDUNDANT_PULLUP_RESISTOR_OHMS   4700    // Pullup resistor
130
+  #define REDUNDANT_RESISTANCE_25C_OHMS    100000  // Resistance at 25C
131
+  #define REDUNDANT_BETA                   3950    // Beta value
132
+#endif
133
+
128 134
 //
129 135
 // Hephestos 2 24V heated bed upgrade kit.
130 136
 // https://store.bq.com/en/heated-bed-kit-hephestos2

+ 1
- 1
Marlin/src/HAL/LPC1768/tft/xpt2046.h View File

@@ -54,7 +54,7 @@ enum XPTCoordinate : uint8_t {
54 54
   XPT2046_Z2 = 0x40 | XPT2046_CONTROL | XPT2046_DFR_MODE,
55 55
 };
56 56
 
57
-#if !defined(XPT2046_Z1_THRESHOLD)
57
+#ifndef XPT2046_Z1_THRESHOLD
58 58
   #define XPT2046_Z1_THRESHOLD 10
59 59
 #endif
60 60
 

+ 1
- 1
Marlin/src/HAL/STM32/tft/xpt2046.h View File

@@ -56,7 +56,7 @@ enum XPTCoordinate : uint8_t {
56 56
   XPT2046_Z2 = 0x40 | XPT2046_CONTROL | XPT2046_DFR_MODE,
57 57
 };
58 58
 
59
-#if !defined(XPT2046_Z1_THRESHOLD)
59
+#ifndef XPT2046_Z1_THRESHOLD
60 60
   #define XPT2046_Z1_THRESHOLD 10
61 61
 #endif
62 62
 

+ 1
- 1
Marlin/src/HAL/STM32F1/tft/xpt2046.h View File

@@ -54,7 +54,7 @@ enum XPTCoordinate : uint8_t {
54 54
   XPT2046_Z2 = 0x40 | XPT2046_CONTROL | XPT2046_DFR_MODE,
55 55
 };
56 56
 
57
-#if !defined(XPT2046_Z1_THRESHOLD)
57
+#ifndef XPT2046_Z1_THRESHOLD
58 58
   #define XPT2046_Z1_THRESHOLD 10
59 59
 #endif
60 60
 

+ 2
- 2
Marlin/src/MarlinCore.cpp View File

@@ -1157,10 +1157,10 @@ void setup() {
1157 1157
   SETUP_RUN(HAL_init());
1158 1158
 
1159 1159
   // Init and disable SPI thermocouples; this is still needed
1160
-  #if TEMP_SENSOR_0_IS_MAX_TC
1160
+  #if TEMP_SENSOR_0_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 0)
1161 1161
     OUT_WRITE(MAX6675_SS_PIN, HIGH);  // Disable
1162 1162
   #endif
1163
-  #if TEMP_SENSOR_1_IS_MAX_TC
1163
+  #if TEMP_SENSOR_1_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 1)
1164 1164
     OUT_WRITE(MAX6675_SS2_PIN, HIGH); // Disable
1165 1165
   #endif
1166 1166
 

+ 1
- 5
Marlin/src/gcode/temp/M105.cpp View File

@@ -35,11 +35,7 @@ void GcodeSuite::M105() {
35 35
 
36 36
   #if HAS_TEMP_SENSOR
37 37
 
38
-    thermalManager.print_heater_states(target_extruder
39
-      #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
40
-        , parser.boolval('R')
41
-      #endif
42
-    );
38
+    thermalManager.print_heater_states(target_extruder OPTARG(HAS_TEMP_REDUNDANT, parser.boolval('R')));
43 39
 
44 40
     SERIAL_EOL();
45 41
 

+ 166
- 27
Marlin/src/inc/Conditionals_post.h View File

@@ -512,11 +512,99 @@
512 512
  * Temp Sensor defines
513 513
  */
514 514
 
515
-#define ANY_TEMP_SENSOR_IS(n) (TEMP_SENSOR_0 == (n) || TEMP_SENSOR_1 == (n) || TEMP_SENSOR_2 == (n) || TEMP_SENSOR_3 == (n) || TEMP_SENSOR_4 == (n) || TEMP_SENSOR_5 == (n) || TEMP_SENSOR_6 == (n) || TEMP_SENSOR_7 == (n) || TEMP_SENSOR_BED == (n) || TEMP_SENSOR_PROBE == (n) || TEMP_SENSOR_CHAMBER == (n) || TEMP_SENSOR_COOLER == (n))
516
-
515
+#define ANY_TEMP_SENSOR_IS(n) ( \
516
+     n == TEMP_SENSOR_0 || n == TEMP_SENSOR_1 || n == TEMP_SENSOR_2 || n == TEMP_SENSOR_3 \
517
+  || n == TEMP_SENSOR_4 || n == TEMP_SENSOR_5 || n == TEMP_SENSOR_6 || n == TEMP_SENSOR_7 \
518
+  || n == TEMP_SENSOR_BED \
519
+  || n == TEMP_SENSOR_PROBE \
520
+  || n == TEMP_SENSOR_CHAMBER \
521
+  || n == TEMP_SENSOR_COOLER \
522
+  || n == TEMP_SENSOR_REDUNDANT )
517 523
 #if ANY_TEMP_SENSOR_IS(1000)
518 524
   #define HAS_USER_THERMISTORS 1
519 525
 #endif
526
+#undef ANY_TEMP_SENSOR_IS
527
+
528
+// Usurp a sensor to do redundant readings
529
+#if TEMP_SENSOR_REDUNDANT && !PIN_EXISTS(TEMP_REDUNDANT)
530
+  #if TEMP_SENSOR_REDUNDANT_SOURCE == -5
531
+    #if !PIN_EXISTS(TEMP_COOLER)
532
+      #error "TEMP_SENSOR_REDUNDANT_SOURCE set to COOLER requires TEMP_COOLER_PIN."
533
+    #else
534
+      #define TEMP_REDUNDANT_PIN TEMP_COOLER_PIN
535
+    #endif
536
+  #elif TEMP_SENSOR_REDUNDANT_SOURCE == -4
537
+    #if !PIN_EXISTS(TEMP_PROBE)
538
+      #error "TEMP_SENSOR_REDUNDANT_SOURCE set to PROBE requires TEMP_PROBE_PIN."
539
+    #else
540
+      #define TEMP_REDUNDANT_PIN TEMP_PROBE_PIN
541
+    #endif
542
+  #elif TEMP_SENSOR_REDUNDANT_SOURCE == -2
543
+    #if !PIN_EXISTS(TEMP_CHAMBER)
544
+      #error "TEMP_SENSOR_REDUNDANT_SOURCE set to CHAMBER requires TEMP_CHAMBER_PIN."
545
+    #else
546
+      #define TEMP_REDUNDANT_PIN TEMP_CHAMBER_PIN
547
+    #endif
548
+  #elif TEMP_SENSOR_REDUNDANT_SOURCE == -1
549
+    #if !PIN_EXISTS(TEMP_BED)
550
+      #error "TEMP_SENSOR_REDUNDANT_SOURCE set to BED requires TEMP_BED_PIN."
551
+    #else
552
+      #define TEMP_REDUNDANT_PIN TEMP_BED_PIN
553
+    #endif
554
+  #elif TEMP_SENSOR_REDUNDANT_SOURCE == 0
555
+    #if !PIN_EXISTS(TEMP_0)
556
+      #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 0 requires TEMP_0_PIN."
557
+    #else
558
+      #define TEMP_REDUNDANT_PIN TEMP_0_PIN
559
+    #endif
560
+  #elif TEMP_SENSOR_REDUNDANT_SOURCE == 1
561
+    #if !PIN_EXISTS(TEMP_1)
562
+      #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 1 requires TEMP_1_PIN."
563
+    #else
564
+      #define TEMP_REDUNDANT_PIN TEMP_1_PIN
565
+    #endif
566
+  #elif TEMP_SENSOR_REDUNDANT_SOURCE == 2
567
+    #if !PIN_EXISTS(TEMP_2)
568
+      #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 2 requires TEMP_2_PIN."
569
+    #else
570
+      #define TEMP_REDUNDANT_PIN TEMP_2_PIN
571
+    #endif
572
+  #elif TEMP_SENSOR_REDUNDANT_SOURCE == 3
573
+    #if !PIN_EXISTS(TEMP_3)
574
+      #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 3 requires TEMP_3_PIN."
575
+    #else
576
+      #define TEMP_REDUNDANT_PIN TEMP_3_PIN
577
+    #endif
578
+  #elif TEMP_SENSOR_REDUNDANT_SOURCE == 4
579
+    #if !PIN_EXISTS(TEMP_4)
580
+      #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 4 requires TEMP_4_PIN."
581
+    #else
582
+      #define TEMP_REDUNDANT_PIN TEMP_4_PIN
583
+    #endif
584
+  #elif TEMP_SENSOR_REDUNDANT_SOURCE == 5
585
+    #if !PIN_EXISTS(TEMP_5)
586
+      #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 5 requires TEMP_5_PIN."
587
+    #else
588
+      #define TEMP_REDUNDANT_PIN TEMP_5_PIN
589
+    #endif
590
+  #elif TEMP_SENSOR_REDUNDANT_SOURCE == 6
591
+    #if !PIN_EXISTS(TEMP_6)
592
+      #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 6 requires TEMP_6_PIN."
593
+    #else
594
+      #define TEMP_REDUNDANT_PIN TEMP_6_PIN
595
+    #endif
596
+  #elif TEMP_SENSOR_REDUNDANT_SOURCE == 7
597
+    #if !PIN_EXISTS(TEMP_7)
598
+      #error "TEMP_SENSOR_REDUNDANT_SOURCE set to 7 requires TEMP_7_PIN."
599
+    #else
600
+      #define TEMP_REDUNDANT_PIN TEMP_7_PIN
601
+    #endif
602
+  #endif
603
+
604
+  #ifndef TEMP_SENSOR_REDUNDANT_MAX_DIFF
605
+    #define TEMP_SENSOR_REDUNDANT_MAX_DIFF 10
606
+  #endif
607
+#endif
520 608
 
521 609
 #if TEMP_SENSOR_0 == -5 || TEMP_SENSOR_0 == -3 || TEMP_SENSOR_0 == -2
522 610
   #define TEMP_SENSOR_0_IS_MAX_TC 1
@@ -540,7 +628,6 @@
540 628
 #elif TEMP_SENSOR_0 == -1
541 629
   #define TEMP_SENSOR_0_IS_AD595 1
542 630
 #elif TEMP_SENSOR_0 > 0
543
-  #define TEMP_SENSOR_0_THERMISTOR_ID TEMP_SENSOR_0
544 631
   #define TEMP_SENSOR_0_IS_THERMISTOR 1
545 632
   #if TEMP_SENSOR_0 == 1000
546 633
     #define TEMP_SENSOR_0_IS_CUSTOM 1
@@ -583,7 +670,6 @@
583 670
 #elif TEMP_SENSOR_1 == -1
584 671
   #define TEMP_SENSOR_1_IS_AD595 1
585 672
 #elif TEMP_SENSOR_1 > 0
586
-  #define TEMP_SENSOR_1_THERMISTOR_ID TEMP_SENSOR_1
587 673
   #define TEMP_SENSOR_1_IS_THERMISTOR 1
588 674
   #if TEMP_SENSOR_1 == 1000
589 675
     #define TEMP_SENSOR_1_IS_CUSTOM 1
@@ -595,35 +681,92 @@
595 681
   #undef HEATER_1_MAXTEMP
596 682
 #endif
597 683
 
598
-#if TEMP_SENSOR_0_IS_MAX31855 || TEMP_SENSOR_1_IS_MAX31855
684
+#if TEMP_SENSOR_REDUNDANT == -5 || TEMP_SENSOR_REDUNDANT == -3 || TEMP_SENSOR_REDUNDANT == -2
685
+  #define TEMP_SENSOR_REDUNDANT_IS_MAX_TC 1
686
+  #define HAS_MAX_TC 1
687
+  #if TEMP_SENSOR_REDUNDANT == -3
688
+    #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN -270
689
+    #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX 1800
690
+  #else
691
+    #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN    0
692
+    #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX 1024
693
+  #endif
694
+  #if TEMP_SENSOR_REDUNDANT_SOURCE == 0
695
+    #define TEMP_SENSOR_0_MAX_TC_TMIN TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN
696
+    #define TEMP_SENSOR_0_MAX_TC_TMAX TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX
697
+  #elif TEMP_SENSOR_REDUNDANT_SOURCE == 1
698
+    #define TEMP_SENSOR_1_MAX_TC_TMIN TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN
699
+    #define TEMP_SENSOR_1_MAX_TC_TMAX TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX
700
+  #endif
701
+  #if TEMP_SENSOR_REDUNDANT == -5
702
+    #if TEMP_SENSOR_REDUNDANT_SOURCE != 0 && TEMP_SENSOR_REDUNDANT_SOURCE != 1
703
+      #error "MAX31865 Thermocouples (-5) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1 (0/1)."
704
+    #endif
705
+    #define TEMP_SENSOR_REDUNDANT_IS_MAX31865 1
706
+  #elif TEMP_SENSOR_REDUNDANT == -3
707
+    #if TEMP_SENSOR_REDUNDANT_SOURCE != 0 && TEMP_SENSOR_REDUNDANT_SOURCE != 1
708
+      #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1 (0/1)."
709
+    #endif
710
+    #define TEMP_SENSOR_REDUNDANT_IS_MAX31855 1
711
+  #elif TEMP_SENSOR_REDUNDANT == -2
712
+    #if TEMP_SENSOR_REDUNDANT_SOURCE != 0 && TEMP_SENSOR_REDUNDANT_SOURCE != 1
713
+      #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1 (0/1)."
714
+    #endif
715
+    #define TEMP_SENSOR_REDUNDANT_IS_MAX6675 1
716
+  #endif
717
+  #if (TEMP_SENSOR_0_IS_MAX_TC && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_0) || (TEMP_SENSOR_1_IS_MAX_TC && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_1)
718
+    #if   TEMP_SENSOR_REDUNDANT == -5
719
+      #error "If MAX31865 Thermocouple (-5) is used for TEMP_SENSOR_0/TEMP_SENSOR_1 then TEMP_SENSOR_REDUNDANT must match."
720
+    #elif TEMP_SENSOR_REDUNDANT == -3
721
+      #error "If MAX31855 Thermocouple (-3) is used for TEMP_SENSOR_0/TEMP_SENSOR_1 then TEMP_SENSOR_REDUNDANT must match."
722
+    #elif TEMP_SENSOR_REDUNDANT == -2
723
+      #error "If MAX6675 Thermocouple (-2) is used for TEMP_SENSOR_0/TEMP_SENSOR_1 then TEMP_SENSOR_REDUNDANT must match."
724
+    #endif
725
+  #endif
726
+#elif TEMP_SENSOR_REDUNDANT == -4
727
+  #define TEMP_SENSOR_REDUNDANT_IS_AD8495 1
728
+#elif TEMP_SENSOR_REDUNDANT == -1
729
+  #define TEMP_SENSOR_REDUNDANT_IS_AD595 1
730
+#elif TEMP_SENSOR_REDUNDANT > 0
731
+  #define TEMP_SENSOR_REDUNDANT_IS_THERMISTOR 1
732
+  #if TEMP_SENSOR_REDUNDANT == 1000
733
+    #define TEMP_SENSOR_REDUNDANT_IS_CUSTOM 1
734
+  #elif TEMP_SENSOR_REDUNDANT == 998 || TEMP_SENSOR_REDUNDANT == 999
735
+    #error "Dummy sensors are not supported for TEMP_SENSOR_REDUNDANT."
736
+  #endif
737
+#endif
738
+
739
+#if TEMP_SENSOR_0_IS_MAX31855 || TEMP_SENSOR_1_IS_MAX31855 || TEMP_SENSOR_REDUNDANT_IS_MAX31855
599 740
   #define HAS_MAX31855 1
600 741
 #endif
601
-#if TEMP_SENSOR_0_IS_MAX31865 || TEMP_SENSOR_1_IS_MAX31865
742
+#if TEMP_SENSOR_0_IS_MAX31865 || TEMP_SENSOR_1_IS_MAX31865 || TEMP_SENSOR_REDUNDANT_IS_MAX31865
602 743
   #define HAS_MAX31865 1
603 744
 #endif
604
-#if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675
745
+#if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675 || TEMP_SENSOR_REDUNDANT_IS_MAX6675
605 746
   #define HAS_MAX6675 1
606 747
 #endif
607 748
 
608 749
 //
609 750
 // Compatibility layer for MAX (SPI) temp boards
610 751
 //
752
+#define TEMP_SENSOR_IS_MAX(n, M) (ENABLED(TEMP_SENSOR_##n##_IS_##M) || (ENABLED(TEMP_SENSOR_REDUNDANT_IS_##M) && TEMP_SENSOR_REDUNDANT_SOURCE == (n)))
753
+
611 754
 #if PIN_EXISTS(MAX6675_SS)
612
-  #if TEMP_SENSOR_0_IS_MAX31855
755
+  #if TEMP_SENSOR_IS_MAX(0, MAX31855)
613 756
     #define MAX31855_CS_PIN MAX6675_SS_PIN
614
-  #elif TEMP_SENSOR_0_IS_MAX31865
757
+  #elif TEMP_SENSOR_IS_MAX(0, MAX31865)
615 758
     #define MAX31865_CS_PIN MAX6675_SS_PIN
616
-  #elif TEMP_SENSOR_0_IS_MAX6675
759
+  #elif TEMP_SENSOR_IS_MAX(0, MAX6675)
617 760
     #define MAX6675_CS_PIN MAX6675_SS_PIN
618 761
   #endif
619 762
 #endif
620 763
 
621 764
 #if PIN_EXISTS(MAX6675_SS2)
622
-  #if TEMP_SENSOR_1_IS_MAX31855
765
+  #if TEMP_SENSOR_IS_MAX(1, MAX31855)
623 766
     #define MAX31855_CS2_PIN MAX6675_SS2_PIN
624
-  #elif TEMP_SENSOR_1_IS_MAX31865
767
+  #elif TEMP_SENSOR_IS_MAX(1, MAX31865)
625 768
     #define MAX31865_CS2_PIN MAX6675_SS2_PIN
626
-  #elif TEMP_SENSOR_1_IS_MAX6675
769
+  #elif TEMP_SENSOR_IS_MAX(1, MAX6675)
627 770
     #define MAX6675_CS2_PIN MAX6675_SS2_PIN
628 771
   #endif
629 772
 #endif
@@ -698,7 +841,6 @@
698 841
 #elif TEMP_SENSOR_2 == -1
699 842
   #define TEMP_SENSOR_2_IS_AD595 1
700 843
 #elif TEMP_SENSOR_2 > 0
701
-  #define TEMP_SENSOR_2_THERMISTOR_ID TEMP_SENSOR_2
702 844
   #define TEMP_SENSOR_2_IS_THERMISTOR 1
703 845
   #if TEMP_SENSOR_2 == 1000
704 846
     #define TEMP_SENSOR_2_IS_CUSTOM 1
@@ -719,7 +861,6 @@
719 861
 #elif TEMP_SENSOR_3 == -1
720 862
   #define TEMP_SENSOR_3_IS_AD595 1
721 863
 #elif TEMP_SENSOR_3 > 0
722
-  #define TEMP_SENSOR_3_THERMISTOR_ID TEMP_SENSOR_3
723 864
   #define TEMP_SENSOR_3_IS_THERMISTOR 1
724 865
   #if TEMP_SENSOR_3 == 1000
725 866
     #define TEMP_SENSOR_3_IS_CUSTOM 1
@@ -740,7 +881,6 @@
740 881
 #elif TEMP_SENSOR_4 == -1
741 882
   #define TEMP_SENSOR_4_IS_AD595 1
742 883
 #elif TEMP_SENSOR_4 > 0
743
-  #define TEMP_SENSOR_4_THERMISTOR_ID TEMP_SENSOR_4
744 884
   #define TEMP_SENSOR_4_IS_THERMISTOR 1
745 885
   #if TEMP_SENSOR_4 == 1000
746 886
     #define TEMP_SENSOR_4_IS_CUSTOM 1
@@ -761,7 +901,6 @@
761 901
 #elif TEMP_SENSOR_5 == -1
762 902
   #define TEMP_SENSOR_5_IS_AD595 1
763 903
 #elif TEMP_SENSOR_5 > 0
764
-  #define TEMP_SENSOR_5_THERMISTOR_ID TEMP_SENSOR_5
765 904
   #define TEMP_SENSOR_5_IS_THERMISTOR 1
766 905
   #if TEMP_SENSOR_5 == 1000
767 906
     #define TEMP_SENSOR_5_IS_CUSTOM 1
@@ -782,7 +921,6 @@
782 921
 #elif TEMP_SENSOR_6 == -1
783 922
   #define TEMP_SENSOR_6_IS_AD595 1
784 923
 #elif TEMP_SENSOR_6 > 0
785
-  #define TEMP_SENSOR_6_THERMISTOR_ID TEMP_SENSOR_6
786 924
   #define TEMP_SENSOR_6_IS_THERMISTOR 1
787 925
   #if TEMP_SENSOR_6 == 1000
788 926
     #define TEMP_SENSOR_6_IS_CUSTOM 1
@@ -803,7 +941,6 @@
803 941
 #elif TEMP_SENSOR_7 == -1
804 942
   #define TEMP_SENSOR_7_IS_AD595 1
805 943
 #elif TEMP_SENSOR_7 > 0
806
-  #define TEMP_SENSOR_7_THERMISTOR_ID TEMP_SENSOR_7
807 944
   #define TEMP_SENSOR_7_IS_THERMISTOR 1
808 945
   #if TEMP_SENSOR_7 == 1000
809 946
     #define TEMP_SENSOR_7_IS_CUSTOM 1
@@ -824,7 +961,6 @@
824 961
 #elif TEMP_SENSOR_BED == -1
825 962
   #define TEMP_SENSOR_BED_IS_AD595 1
826 963
 #elif TEMP_SENSOR_BED > 0
827
-  #define TEMP_SENSOR_BED_THERMISTOR_ID TEMP_SENSOR_BED
828 964
   #define TEMP_SENSOR_BED_IS_THERMISTOR 1
829 965
   #if TEMP_SENSOR_BED == 1000
830 966
     #define TEMP_SENSOR_BED_IS_CUSTOM 1
@@ -845,7 +981,6 @@
845 981
 #elif TEMP_SENSOR_CHAMBER == -1
846 982
   #define TEMP_SENSOR_CHAMBER_IS_AD595 1
847 983
 #elif TEMP_SENSOR_CHAMBER > 0
848
-  #define TEMP_SENSOR_CHAMBER_THERMISTOR_ID TEMP_SENSOR_CHAMBER
849 984
   #define TEMP_SENSOR_CHAMBER_IS_THERMISTOR 1
850 985
   #if TEMP_SENSOR_CHAMBER == 1000
851 986
     #define TEMP_SENSOR_CHAMBER_IS_CUSTOM 1
@@ -858,20 +993,19 @@
858 993
 #endif
859 994
 
860 995
 #if TEMP_SENSOR_COOLER == -4
861
-  #define COOLER_USES_AD8495 1
996
+  #define TEMP_SENSOR_COOLER_IS_AD8495 1
862 997
 #elif TEMP_SENSOR_COOLER == -3
863 998
   #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_COOLER."
864 999
 #elif TEMP_SENSOR_COOLER == -2
865 1000
   #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_COOLER."
866 1001
 #elif TEMP_SENSOR_COOLER == -1
867
-  #define COOLER_USES_AD595 1
1002
+  #define TEMP_SENSOR_COOLER_IS_AD595 1
868 1003
 #elif TEMP_SENSOR_COOLER > 0
869
-  #define TEMP_SENSOR_COOLER_THERMISTOR_ID TEMP_SENSOR_COOLER
870 1004
   #define TEMP_SENSOR_COOLER_IS_THERMISTOR 1
871 1005
   #if TEMP_SENSOR_COOLER == 1000
872
-    #define COOLER_USER_THERMISTOR 1
1006
+    #define TEMP_SENSOR_COOLER_IS_CUSTOM 1
873 1007
   #elif TEMP_SENSOR_COOLER == 998 || TEMP_SENSOR_COOLER == 999
874
-    #define COOLER_DUMMY_THERMISTOR 1
1008
+    #define TEMP_SENSOR_COOLER_IS_DUMMY 1
875 1009
   #endif
876 1010
 #else
877 1011
   #undef COOLER_MINTEMP
@@ -887,7 +1021,6 @@
887 1021
 #elif TEMP_SENSOR_PROBE == -1
888 1022
   #define TEMP_SENSOR_PROBE_IS_AD595 1
889 1023
 #elif TEMP_SENSOR_PROBE > 0
890
-  #define TEMP_SENSOR_PROBE_THERMISTOR_ID TEMP_SENSOR_PROBE
891 1024
   #define TEMP_SENSOR_PROBE_IS_THERMISTOR 1
892 1025
   #if TEMP_SENSOR_PROBE == 1000
893 1026
     #define TEMP_SENSOR_PROBE_IS_CUSTOM 1
@@ -2345,6 +2478,9 @@
2345 2478
 #if HAS_ADC_TEST(COOLER)
2346 2479
   #define HAS_TEMP_ADC_COOLER 1
2347 2480
 #endif
2481
+#if HAS_ADC_TEST(REDUNDANT)
2482
+  #define HAS_TEMP_ADC_REDUNDANT 1
2483
+#endif
2348 2484
 
2349 2485
 #define HAS_TEMP(N) ANY(HAS_TEMP_ADC_##N, TEMP_SENSOR_##N##_IS_MAX_TC, TEMP_SENSOR_##N##_IS_DUMMY)
2350 2486
 #if HAS_HOTEND && HAS_TEMP(0)
@@ -2362,6 +2498,9 @@
2362 2498
 #if HAS_TEMP(COOLER)
2363 2499
   #define HAS_TEMP_COOLER 1
2364 2500
 #endif
2501
+#if HAS_TEMP(REDUNDANT)
2502
+  #define HAS_TEMP_REDUNDANT 1
2503
+#endif
2365 2504
 
2366 2505
 #if ENABLED(JOYSTICK)
2367 2506
   #if PIN_EXISTS(JOY_X)

+ 79
- 12
Marlin/src/inc/SanityCheck.h View File

@@ -568,6 +568,10 @@
568 568
   #error "MKS_LCD12864 is now MKS_LCD12864A or MKS_LCD12864B."
569 569
 #elif defined(NEOPIXEL_BKGD_LED_INDEX)
570 570
   #error "NEOPIXEL_BKGD_LED_INDEX is now NEOPIXEL_BKGD_INDEX_FIRST."
571
+#elif defined(TEMP_SENSOR_1_AS_REDUNDANT)
572
+  #error "TEMP_SENSOR_1_AS_REDUNDANT is now TEMP_SENSOR_REDUNDANT, with associated TEMP_SENSOR_REDUNDANT_* config."
573
+#elif defined(MAX_REDUNDANT_TEMP_SENSOR_DIFF)
574
+  #error "MAX_REDUNDANT_TEMP_SENSOR_DIFF is now TEMP_SENSOR_REDUNDANT_MAX_DIFF"
571 575
 #endif
572 576
 
573 577
 constexpr float arm[] = AXIS_RELATIVE_MODES;
@@ -1887,19 +1891,88 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
1887 1891
   #error "TEMP_SENSOR_CHAMBER 1000 requires CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS and CHAMBER_BETA in Configuration_adv.h."
1888 1892
 #elif TEMP_SENSOR_PROBE_IS_CUSTOM && !(defined(PROBE_PULLUP_RESISTOR_OHMS) && defined(PROBE_RESISTANCE_25C_OHMS) && defined(PROBE_BETA))
1889 1893
   #error "TEMP_SENSOR_PROBE 1000 requires PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS and PROBE_BETA in Configuration_adv.h."
1894
+#elif TEMP_SENSOR_REDUNDANT_IS_CUSTOM && !(defined(REDUNDANT_PULLUP_RESISTOR_OHMS) && defined(REDUNDANT_RESISTANCE_25C_OHMS) && defined(REDUNDANT_BETA))
1895
+  #error "TEMP_SENSOR_REDUNDANT 1000 requires REDUNDANT_PULLUP_RESISTOR_OHMS, REDUNDANT_RESISTANCE_25C_OHMS and REDUNDANT_BETA in Configuration_adv.h."
1890 1896
 #endif
1891 1897
 
1892 1898
 /**
1893 1899
  * Pins and Sensor IDs must be set for each heater
1894 1900
  */
1895 1901
 #if TEMP_SENSOR_0_IS_MAX6675 && !ANY_PIN(MAX6675_SS, MAX31855_CS, MAX31865_CS, MAX6675_CS)
1896
-  #error "TEMP_SENSOR_0 requires a MAX6675_SS_PIN, MAX6675_CS_PIN, MAX31855_CS_PIN, or MAX31865_CS_PIN."
1902
+  #error "TEMP_SENSOR_0 -2 requires a MAX6675_SS_PIN, MAX6675_CS_PIN, MAX31855_CS_PIN, or MAX31865_CS_PIN."
1897 1903
 #elif HAS_HOTEND && !HAS_TEMP_HOTEND && !TEMP_SENSOR_0_IS_DUMMY
1898 1904
   #error "TEMP_0_PIN (required for TEMP_SENSOR_0) not defined for this board."
1899 1905
 #elif EITHER(HAS_MULTI_HOTEND, HEATERS_PARALLEL) && !HAS_HEATER_1
1900 1906
   #error "HEATER_1_PIN is not defined. TEMP_SENSOR_1 might not be set, or the board (not EEB / EEF?) doesn't define a pin."
1901 1907
 #endif
1902 1908
 
1909
+/**
1910
+ * Redundant temperature sensor config
1911
+ */
1912
+#if HAS_TEMP_REDUNDANT
1913
+  #if !defined(TEMP_SENSOR_REDUNDANT_SOURCE)
1914
+    #error "TEMP_SENSOR_REDUNDANT requires TEMP_SENSOR_REDUNDANT_SOURCE."
1915
+  #elif !defined(TEMP_SENSOR_REDUNDANT_TARGET)
1916
+    #error "TEMP_SENSOR_REDUNDANT requires TEMP_SENSOR_REDUNDANT_TARGET."
1917
+  #elif TEMP_SENSOR_REDUNDANT_SOURCE == TEMP_SENSOR_REDUNDANT_TARGET
1918
+    #error "TEMP_SENSOR_REDUNDANT_SOURCE can't be the same as TEMP_SENSOR_REDUNDANT_TARGET."
1919
+  #elif TEMP_SENSOR_REDUNDANT_SOURCE < -5 || TEMP_SENSOR_REDUNDANT_SOURCE > 7
1920
+    #error "TEMP_SENSOR_REDUNDANT_SOURCE must be between -5 and 7."
1921
+  #elif TEMP_SENSOR_REDUNDANT_TARGET < -5 || TEMP_SENSOR_REDUNDANT_TARGET > 7
1922
+    #error "TEMP_SENSOR_REDUNDANT_TARGET must be between -5 and 7."
1923
+  #elif TEMP_SENSOR_REDUNDANT_SOURCE == -3
1924
+    #error "TEMP_SENSOR_REDUNDANT_SOURCE can't be -3 (not used)."
1925
+  #elif TEMP_SENSOR_REDUNDANT_TARGET == -3
1926
+    #error "TEMP_SENSOR_REDUNDANT_TARGET can't be -3 (not used)."
1927
+  #elif HAS_MULTI_HOTEND && TEMP_SENSOR_REDUNDANT_SOURCE < HOTENDS
1928
+    #error "TEMP_SENSOR_REDUNDANT_SOURCE must be after the last TEMP_SENSOR used with a hotend; you can't use a sensor in the middle of two hotends."
1929
+  #endif
1930
+
1931
+  #if TEMP_SENSOR_REDUNDANT_SOURCE == 0 && HAS_HOTEND
1932
+    #error "TEMP_SENSOR_REDUNDANT_SOURCE can not be 0 if a hotend is used. E0 always uses TEMP_SENSOR_0."
1933
+  #elif TEMP_SENSOR_REDUNDANT_SOURCE == -5 && HAS_TEMP_COOLER
1934
+    #error "TEMP_SENSOR_REDUNDANT_SOURCE can't be Cooler (-5): TEMP_SENSOR_COOLER has already defined the sensor."
1935
+  #elif TEMP_SENSOR_REDUNDANT_SOURCE == -4 && HAS_TEMP_PROBE
1936
+    #error "TEMP_SENSOR_REDUNDANT_SOURCE can't be Probe (-4): TEMP_SENSOR_PROBE has already defined the sensor."
1937
+  #elif TEMP_SENSOR_REDUNDANT_SOURCE == -2 && HAS_TEMP_CHAMBER
1938
+    #error "TEMP_SENSOR_REDUNDANT_SOURCE can't be Chamber (-2): TEMP_SENSOR_CHAMBER has already defined the sensor."
1939
+  #elif TEMP_SENSOR_REDUNDANT_SOURCE == -1 && HAS_TEMP_BED
1940
+    #error "TEMP_SENSOR_REDUNDANT_SOURCE can't be Bed (-1): TEMP_SENSOR_BED has already defined the sensor."
1941
+  #endif
1942
+
1943
+  #if TEMP_SENSOR_REDUNDANT_TARGET == 0 && !PIN_EXISTS(TEMP_0)
1944
+    #error "TEMP_SENSOR_REDUNDANT_TARGET can't be E0 (0): requires TEMP_0_PIN"
1945
+  #elif TEMP_SENSOR_REDUNDANT_TARGET == 1 && !PIN_EXISTS(TEMP_1)
1946
+    #error "TEMP_SENSOR_REDUNDANT_TARGET can't be E1 (1): requires TEMP_1_PIN"
1947
+  #elif TEMP_SENSOR_REDUNDANT_TARGET == 2 && !PIN_EXISTS(TEMP_2)
1948
+    #error "TEMP_SENSOR_REDUNDANT_TARGET can't be E2 (2): requires TEMP_2_PIN"
1949
+  #elif TEMP_SENSOR_REDUNDANT_TARGET == 3 && !PIN_EXISTS(TEMP_3)
1950
+    #error "TEMP_SENSOR_REDUNDANT_TARGET can't be E3 (3): requires TEMP_3_PIN"
1951
+  #elif TEMP_SENSOR_REDUNDANT_TARGET == 4 && !PIN_EXISTS(TEMP_4)
1952
+    #error "TEMP_SENSOR_REDUNDANT_TARGET can't be E4 (4): requires TEMP_4_PIN"
1953
+  #elif TEMP_SENSOR_REDUNDANT_TARGET == 5 && !PIN_EXISTS(TEMP_5)
1954
+    #error "TEMP_SENSOR_REDUNDANT_TARGET can't be E5 (5): requires TEMP_5_PIN"
1955
+  #elif TEMP_SENSOR_REDUNDANT_TARGET == 6 && !PIN_EXISTS(TEMP_6)
1956
+    #error "TEMP_SENSOR_REDUNDANT_TARGET can't be E6 (6): requires TEMP_6_PIN"
1957
+  #elif TEMP_SENSOR_REDUNDANT_TARGET == 7 && !PIN_EXISTS(TEMP_7)
1958
+    #error "TEMP_SENSOR_REDUNDANT_TARGET can't be E7 (7): requires TEMP_7_PIN"
1959
+  #elif TEMP_SENSOR_REDUNDANT_TARGET == -1 && !PIN_EXISTS(TEMP_BED)
1960
+    #error "TEMP_SENSOR_REDUNDANT_TARGET can't be Bed (-1): requires TEMP_BED_PIN"
1961
+  #elif TEMP_SENSOR_REDUNDANT_TARGET == -2 && !PIN_EXISTS(TEMP_CHAMBER)
1962
+    #error "TEMP_SENSOR_REDUNDANT_TARGET can't be Chamber (-2): requires TEMP_CHAMBER_PIN"
1963
+  #elif TEMP_SENSOR_REDUNDANT_TARGET == -4 && !PIN_EXISTS(TEMP_PROBE)
1964
+    #error "TEMP_SENSOR_REDUNDANT_TARGET can't be Probe (-4): requires TEMP_PROBE_PIN"
1965
+  #elif TEMP_SENSOR_REDUNDANT_TARGET == -5 && !PIN_EXISTS(TEMP_COOLER)
1966
+    #error "TEMP_SENSOR_REDUNDANT_TARGET can't be Cooler (-5): requires TEMP_COOLER_PIN"
1967
+  #endif
1968
+
1969
+  #if TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 0 && !PIN_EXISTS(MAX6675_SS)
1970
+    #error "TEMP_SENSOR_REDUNDANT MAX Thermocouple with TEMP_SENSOR_REDUNDANT_SOURCE 0 requires a MAX6675_SS_PIN, MAX6675_CS_PIN, MAX31855_CS_PIN, or MAX31865_CS_PIN."
1971
+  #elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 1 && !PIN_EXISTS(MAX6675_SS2)
1972
+    #error "TEMP_SENSOR_REDUNDANT MAX Thermocouple with TEMP_SENSOR_REDUNDANT_SOURCE 1 requires a MAX6675_SS2_PIN, MAX6675_CS_PIN, MAX31855_CS_PIN, or MAX31865_CS_PIN."
1973
+  #endif
1974
+#endif
1975
+
1903 1976
 #if HAS_MULTI_HOTEND
1904 1977
   #if TEMP_SENSOR_1_IS_MAX6675 && !ANY_PIN(MAX6675_SS2, MAX31855_CS2, MAX31865_CS2, MAX6675_CS2)
1905 1978
     #error "TEMP_SENSOR_1 requires a MAX6675_SS2_PIN, MAX6675_CS2_PIN, MAX31855_CS2_PIN, or MAX31865_CS2_PIN."
@@ -1907,8 +1980,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
1907 1980
     #error "TEMP_SENSOR_1 is required with 2 or more HOTENDS."
1908 1981
   #elif !ANY_PIN(TEMP_1, MAX6675_SS2) && !TEMP_SENSOR_1_IS_DUMMY
1909 1982
     #error "TEMP_1_PIN or MAX6675_SS2_PIN not defined for this board."
1910
-  #elif ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
1911
-    #error "HOTENDS must be 1 with TEMP_SENSOR_1_AS_REDUNDANT."
1912 1983
   #endif
1913 1984
   #if HOTENDS > 2
1914 1985
     #if TEMP_SENSOR_2 == 0
@@ -2006,7 +2077,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
2006 2077
   #elif TEMP_SENSOR_7 != 0
2007 2078
     #error "TEMP_SENSOR_7 shouldn't be set with only 2 HOTENDS."
2008 2079
   #endif
2009
-#elif TEMP_SENSOR_1 != 0 && DISABLED(TEMP_SENSOR_1_AS_REDUNDANT)
2080
+#elif TEMP_SENSOR_1 != 0
2010 2081
   #error "TEMP_SENSOR_1 shouldn't be set with only 1 HOTEND."
2011 2082
 #elif TEMP_SENSOR_2 != 0
2012 2083
   #error "TEMP_SENSOR_2 shouldn't be set with only 1 HOTEND."
@@ -2068,14 +2139,10 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
2068 2139
   #endif
2069 2140
 #endif
2070 2141
 
2071
-#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) && TEMP_SENSOR_1 == 0
2072
-  #error "TEMP_SENSOR_1 is required with TEMP_SENSOR_1_AS_REDUNDANT."
2073
-#endif
2074
-
2075
-#if TEMP_SENSOR_0_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_0) && defined(MAX31865_CALIBRATION_OHMS_0))
2076
-  #error "MAX31865_SENSOR_OHMS_0 and MAX31865_CALIBRATION_OHMS_0 must be set if TEMP_SENSOR_0 is MAX31865."
2077
-#elif TEMP_SENSOR_1_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_1) && defined(MAX31865_CALIBRATION_OHMS_1))
2078
-  #error "MAX31865_SENSOR_OHMS_1 and MAX31865_CALIBRATION_OHMS_1 must be set if TEMP_SENSOR_1 is MAX31865."
2142
+#if TEMP_SENSOR_IS_MAX(0, MAX31865) && !(defined(MAX31865_SENSOR_OHMS_0) && defined(MAX31865_CALIBRATION_OHMS_0))
2143
+  #error "MAX31865_SENSOR_OHMS_0 and MAX31865_CALIBRATION_OHMS_0 must be set if TEMP_SENSOR_0/TEMP_SENSOR_REDUNDANT is MAX31865."
2144
+#elif TEMP_SENSOR_IS_MAX(1, MAX31865) && !(defined(MAX31865_SENSOR_OHMS_1) && defined(MAX31865_CALIBRATION_OHMS_1))
2145
+  #error "MAX31865_SENSOR_OHMS_1 and MAX31865_CALIBRATION_OHMS_1 must be set if TEMP_SENSOR_1/TEMP_SENSOR_REDUNDANT is MAX31865."
2079 2146
 #endif
2080 2147
 
2081 2148
 /**

+ 145
- 72
Marlin/src/module/temperature.cpp View File

@@ -56,13 +56,15 @@
56 56
   #include "../feature/host_actions.h"
57 57
 #endif
58 58
 
59
+#define TEMP_SENSOR_IS_ANY_MAX_TC(n) (ENABLED(TEMP_SENSOR_##n##_IS_MAX_TC) || (ENABLED(TEMP_SENSOR_REDUNDANT_IS_MAX_TC) && ENABLED(TEMP_SENSOR_REDUNDANT_SOURCE) && TEMP_SENSOR_REDUNDANT_SOURCE == n))
60
+
59 61
 // LIB_MAX31855 can be added to the build_flags in platformio.ini to use a user-defined library
60 62
 #if LIB_USR_MAX31855
61 63
   #include <Adafruit_MAX31855.h>
62 64
   #if PIN_EXISTS(MAX31855_MISO) && PIN_EXISTS(MAX31855_SCK)
63 65
     #define MAX31855_USES_SW_SPI 1
64 66
   #endif
65
-  #if TEMP_SENSOR_0_IS_MAX31855 && PIN_EXISTS(MAX31855_CS)
67
+  #if TEMP_SENSOR_IS_MAX(0, MAX31855) && PIN_EXISTS(MAX31855_CS)
66 68
     #define HAS_MAX31855_TEMP 1
67 69
     Adafruit_MAX31855 max31855_0 = Adafruit_MAX31855(MAX31855_CS_PIN
68 70
       #if MAX31855_USES_SW_SPI
@@ -73,7 +75,7 @@
73 75
       #endif
74 76
     );
75 77
   #endif
76
-  #if TEMP_SENSOR_1_IS_MAX31855 && PIN_EXISTS(MAX31855_CS2)
78
+  #if TEMP_SENSOR_IS_MAX(1, MAX31855) && PIN_EXISTS(MAX31855_CS2)
77 79
     #define HAS_MAX31855_TEMP 1
78 80
     Adafruit_MAX31855 max31855_1 = Adafruit_MAX31855(MAX31855_CS2_PIN
79 81
       #if MAX31855_USES_SW_SPI
@@ -96,7 +98,7 @@
96 98
   #if PIN_EXISTS(MAX31865_MISO) && PIN_EXISTS(MAX31865_SCK)
97 99
     #define MAX31865_USES_SW_SPI 1
98 100
   #endif
99
-  #if TEMP_SENSOR_0_IS_MAX31865 && PIN_EXISTS(MAX31865_CS)
101
+  #if TEMP_SENSOR_IS_MAX(0, MAX31865) && PIN_EXISTS(MAX31865_CS)
100 102
     #define HAS_MAX31865_TEMP 1
101 103
       Adafruit_MAX31865 max31865_0 = Adafruit_MAX31865(MAX31865_CS_PIN
102 104
         #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI)
@@ -107,7 +109,7 @@
107 109
         #endif
108 110
       );
109 111
   #endif
110
-  #if TEMP_SENSOR_1_IS_MAX31865 && PIN_EXISTS(MAX31865_CS2)
112
+  #if TEMP_SENSOR_IS_MAX(1, MAX31865) && PIN_EXISTS(MAX31865_CS2)
111 113
     #define HAS_MAX31865_TEMP 1
112 114
     Adafruit_MAX31865 max31865_1 = Adafruit_MAX31865(MAX31865_CS2_PIN
113 115
       #if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI)
@@ -126,7 +128,7 @@
126 128
   #if PIN_EXISTS(MAX6675_MISO) && PIN_EXISTS(MAX6675_SCK)
127 129
     #define MAX6675_USES_SW_SPI 1
128 130
   #endif
129
-  #if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS)
131
+  #if TEMP_SENSOR_IS_MAX(0, MAX6675) && PIN_EXISTS(MAX6675_CS)
130 132
     #define HAS_MAX6675_TEMP 1
131 133
     MAX6675 max6675_0 = MAX6675(MAX6675_CS_PIN
132 134
       #if MAX6675_USES_SW_SPI
@@ -137,7 +139,7 @@
137 139
       #endif
138 140
     );
139 141
   #endif
140
-  #if TEMP_SENSOR_1_IS_MAX6675 && PIN_EXISTS(MAX6675_CS2)
142
+  #if TEMP_SENSOR_IS_MAX(1, MAX6675) && PIN_EXISTS(MAX6675_CS2)
141 143
     #define HAS_MAX6675_TEMP 1
142 144
     MAX6675 max6675_1 = MAX6675(MAX6675_CS2_PIN
143 145
       #if MAX6675_USES_SW_SPI
@@ -154,7 +156,7 @@
154 156
   #define NO_THERMO_TEMPS 1
155 157
 #endif
156 158
 
157
-#if (TEMP_SENSOR_0_IS_MAX_TC || TEMP_SENSOR_1_IS_MAX_TC) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && NO_THERMO_TEMPS
159
+#if (TEMP_SENSOR_0_IS_MAX_TC || TEMP_SENSOR_1_IS_MAX_TC || TEMP_SENSOR_REDUNDANT_IS_MAX_TC) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && NO_THERMO_TEMPS
158 160
   #define THERMO_SEPARATE_SPI 1
159 161
 #endif
160 162
 
@@ -210,15 +212,10 @@
210 212
 #endif
211 213
 
212 214
 #if HAS_HOTEND_THERMISTOR
213
-  #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
214
-    static const temp_entry_t* heater_ttbl_map[2] = { TEMPTABLE_0, TEMPTABLE_1 };
215
-    static constexpr uint8_t heater_ttbllen_map[2] = { TEMPTABLE_0_LEN, TEMPTABLE_1_LEN };
216
-  #else
217
-    #define NEXT_TEMPTABLE(N) ,TEMPTABLE_##N
218
-    #define NEXT_TEMPTABLE_LEN(N) ,TEMPTABLE_##N##_LEN
219
-    static const temp_entry_t* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS(TEMPTABLE_0 REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE));
220
-    static constexpr uint8_t heater_ttbllen_map[HOTENDS] = ARRAY_BY_HOTENDS(TEMPTABLE_0_LEN REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE_LEN));
221
-  #endif
215
+  #define NEXT_TEMPTABLE(N) ,TEMPTABLE_##N
216
+  #define NEXT_TEMPTABLE_LEN(N) ,TEMPTABLE_##N##_LEN
217
+  static const temp_entry_t* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS(TEMPTABLE_0 REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE));
218
+  static constexpr uint8_t heater_ttbllen_map[HOTENDS] = ARRAY_BY_HOTENDS(TEMPTABLE_0_LEN REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE_LEN));
222 219
 #endif
223 220
 
224 221
 Temperature thermalManager;
@@ -257,13 +254,14 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
257 254
 
258 255
 #if HAS_HOTEND
259 256
   hotend_info_t Temperature::temp_hotend[HOTENDS];
260
-  #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
261
-    temp_info_t Temperature::temp_redundant;
262
-  #endif
263 257
   #define _HMT(N) HEATER_##N##_MAXTEMP,
264 258
   const celsius_t Temperature::hotend_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP);
265 259
 #endif
266 260
 
261
+#if HAS_TEMP_REDUNDANT
262
+  redundant_temp_info_t Temperature::temp_redundant;
263
+#endif
264
+
267 265
 #if ENABLED(AUTO_POWER_E_FANS)
268 266
   uint8_t Temperature::autofan_speed[HOTENDS]; // = { 0 }
269 267
 #endif
@@ -1219,8 +1217,12 @@ void Temperature::manage_heater() {
1219 1217
       if (degHotend(0) < _MAX(HEATER_0_MINTEMP, TEMP_SENSOR_0_MAX_TC_TMIN + .01)) min_temp_error(H_E0);
1220 1218
     #endif
1221 1219
     #if TEMP_SENSOR_1_IS_MAX_TC
1222
-      if (TERN(TEMP_SENSOR_1_AS_REDUNDANT, degHotendRedundant(), degHotend(1)) > _MIN(HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0)) max_temp_error(H_E1);
1223
-      if (TERN(TEMP_SENSOR_1_AS_REDUNDANT, degHotendRedundant(), degHotend(1)) < _MAX(HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01)) min_temp_error(H_E1);
1220
+      if (degHotend(1) > _MIN(HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0)) max_temp_error(H_E1);
1221
+      if (degHotend(1) < _MAX(HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01)) min_temp_error(H_E1);
1222
+    #endif
1223
+    #if TEMP_SENSOR_REDUNDANT_IS_MAX_TC
1224
+      if (degRedundant() > TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX - 1.0) max_temp_error(H_REDUNDANT);
1225
+      if (degRedundant() < TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + .01) min_temp_error(H_REDUNDANT);
1224 1226
     #endif
1225 1227
   #endif
1226 1228
 
@@ -1254,16 +1256,16 @@ void Temperature::manage_heater() {
1254 1256
         }
1255 1257
       #endif
1256 1258
 
1257
-      #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
1258
-        // Make sure measured temperatures are close together
1259
-        if (ABS(degHotend(0) - degHotendRedundant()) > MAX_REDUNDANT_TEMP_SENSOR_DIFF)
1260
-          _temp_error(H_E0, PSTR(STR_REDUNDANCY), GET_TEXT(MSG_ERR_REDUNDANT_TEMP));
1261
-      #endif
1262
-
1263 1259
     } // HOTEND_LOOP
1264 1260
 
1265 1261
   #endif // HAS_HOTEND
1266 1262
 
1263
+  #if HAS_TEMP_REDUNDANT
1264
+    // Make sure measured temperatures are close together
1265
+    if (ABS(degRedundantTarget() - degRedundant()) > TEMP_SENSOR_REDUNDANT_MAX_DIFF)
1266
+      _temp_error((heater_id_t)TEMP_SENSOR_REDUNDANT_TARGET, PSTR(STR_REDUNDANCY), GET_TEXT(MSG_ERR_REDUNDANT_TEMP));
1267
+  #endif
1268
+
1267 1269
   #if HAS_AUTO_FAN
1268 1270
     if (ELAPSED(ms, next_auto_fan_check_ms)) { // only need to check fan state very infrequently
1269 1271
       checkExtruderAutoFans();
@@ -1613,13 +1615,16 @@ void Temperature::manage_heater() {
1613 1615
         { true, 0, 0, BED_PULLUP_RESISTOR_OHMS, BED_RESISTANCE_25C_OHMS, 0, 0, BED_BETA, 0 },
1614 1616
       #endif
1615 1617
       #if TEMP_SENSOR_CHAMBER_IS_CUSTOM
1616
-        { true, 0, 0, CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS, 0, 0, CHAMBER_BETA, 0 }
1618
+        { true, 0, 0, CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS, 0, 0, CHAMBER_BETA, 0 },
1617 1619
       #endif
1618 1620
       #if TEMP_SENSOR_COOLER_IS_CUSTOM
1619
-        { true, 0, 0, COOLER_PULLUP_RESISTOR_OHMS, COOLER_RESISTANCE_25C_OHMS, 0, 0, COOLER_BETA, 0 }
1621
+        { true, 0, 0, COOLER_PULLUP_RESISTOR_OHMS, COOLER_RESISTANCE_25C_OHMS, 0, 0, COOLER_BETA, 0 },
1620 1622
       #endif
1621 1623
       #if TEMP_SENSOR_PROBE_IS_CUSTOM
1622
-        { true, 0, 0, PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS, 0, 0, PROBE_BETA, 0 }
1624
+        { true, 0, 0, PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS, 0, 0, PROBE_BETA, 0 },
1625
+      #endif
1626
+      #if TEMP_SENSOR_REDUNDANT_IS_CUSTOM
1627
+        { true, 0, 0, REDUNDANT_PULLUP_RESISTOR_OHMS, REDUNDANT_RESISTANCE_25C_OHMS, 0, 0, REDUNDANT_BETA, 0 },
1623 1628
       #endif
1624 1629
     };
1625 1630
     COPY(user_thermistor, default_user_thermistor);
@@ -1653,6 +1658,7 @@ void Temperature::manage_heater() {
1653 1658
       TERN_(TEMP_SENSOR_CHAMBER_IS_CUSTOM, t_index == CTI_CHAMBER ? PSTR("CHAMBER") :)
1654 1659
       TERN_(TEMP_SENSOR_COOLER_IS_CUSTOM, t_index == CTI_COOLER ? PSTR("COOLER") :)
1655 1660
       TERN_(TEMP_SENSOR_PROBE_IS_CUSTOM, t_index == CTI_PROBE ? PSTR("PROBE") :)
1661
+      TERN_(TEMP_SENSOR_REDUNDANT_IS_CUSTOM, t_index == CTI_REDUNDANT ? PSTR("REDUNDANT") :)
1656 1662
       nullptr
1657 1663
     );
1658 1664
     SERIAL_EOL();
@@ -1708,7 +1714,7 @@ void Temperature::manage_heater() {
1708 1714
   // Derived from RepRap FiveD extruder::getTemperature()
1709 1715
   // For hot end temperature measurement.
1710 1716
   celsius_float_t Temperature::analog_to_celsius_hotend(const int16_t raw, const uint8_t e) {
1711
-      if (e >= HOTENDS + ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)) {
1717
+      if (e >= HOTENDS) {
1712 1718
         SERIAL_ERROR_START();
1713 1719
         SERIAL_ECHO(e);
1714 1720
         SERIAL_ECHOLNPGM(STR_INVALID_EXTRUDER_NUM);
@@ -1886,6 +1892,28 @@ void Temperature::manage_heater() {
1886 1892
   }
1887 1893
 #endif // HAS_TEMP_PROBE
1888 1894
 
1895
+#if HAS_TEMP_REDUNDANT
1896
+  // For redundant temperature measurement.
1897
+  celsius_float_t Temperature::analog_to_celsius_redundant(const int16_t raw) {
1898
+    #if TEMP_SENSOR_REDUNDANT_IS_CUSTOM
1899
+      return user_thermistor_to_deg_c(CTI_REDUNDANT, raw);
1900
+    #elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 0
1901
+      return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0), raw * 0.25);
1902
+    #elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 1
1903
+      return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_1.temperature(MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1), raw * 0.25);
1904
+    #elif TEMP_SENSOR_REDUNDANT_IS_THERMISTOR
1905
+      SCAN_THERMISTOR_TABLE(TEMPTABLE_REDUNDANT, TEMPTABLE_REDUNDANT_LEN);
1906
+    #elif TEMP_SENSOR_REDUNDANT_IS_AD595
1907
+      return TEMP_AD595(raw);
1908
+    #elif TEMP_SENSOR_REDUNDANT_IS_AD8495
1909
+      return TEMP_AD8495(raw);
1910
+    #else
1911
+      UNUSED(raw);
1912
+      return 0;
1913
+    #endif
1914
+  }
1915
+#endif // HAS_TEMP_REDUNDANT
1916
+
1889 1917
 /**
1890 1918
  * Convert the raw sensor readings into actual Celsius temperatures and
1891 1919
  * validate raw temperatures. Bad readings generate min/maxtemp errors.
@@ -1903,26 +1931,34 @@ void Temperature::updateTemperaturesFromRawValues() {
1903 1931
   watchdog_refresh(); // Reset because raw_temps_ready was set by the interrupt
1904 1932
 
1905 1933
   TERN_(TEMP_SENSOR_0_IS_MAX_TC, temp_hotend[0].raw = READ_MAX_TC(0));
1906
-  TERN_(TEMP_SENSOR_1_IS_MAX_TC, TERN(TEMP_SENSOR_1_AS_REDUNDANT, temp_redundant, temp_hotend[1]).raw = READ_MAX_TC(1));
1934
+  TERN_(TEMP_SENSOR_1_IS_MAX_TC, temp_hotend[1].raw = READ_MAX_TC(1));
1935
+  TERN_(TEMP_SENSOR_REDUNDANT_IS_MAX_TC, temp_redundant.raw = READ_MAX_TC(TEMP_SENSOR_REDUNDANT_SOURCE));
1907 1936
   #if HAS_HOTEND
1908 1937
     HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].raw, e);
1909 1938
   #endif
1910
-  TERN_(TEMP_SENSOR_1_AS_REDUNDANT, temp_redundant.celsius = analog_to_celsius_hotend(temp_redundant.raw, 1));
1911 1939
 
1912
-  TERN_(HAS_HEATED_BED,   temp_bed.celsius     = analog_to_celsius_bed(temp_bed.raw));
1913
-  TERN_(HAS_TEMP_CHAMBER, temp_chamber.celsius = analog_to_celsius_chamber(temp_chamber.raw));
1914
-  TERN_(HAS_TEMP_COOLER,  temp_cooler.celsius  = analog_to_celsius_cooler(temp_cooler.raw));
1915
-  TERN_(HAS_TEMP_PROBE,   temp_probe.celsius   = analog_to_celsius_probe(temp_probe.raw));
1940
+  TERN_(HAS_HEATED_BED,     temp_bed.celsius       = analog_to_celsius_bed(temp_bed.raw));
1941
+  TERN_(HAS_TEMP_CHAMBER,   temp_chamber.celsius   = analog_to_celsius_chamber(temp_chamber.raw));
1942
+  TERN_(HAS_TEMP_COOLER,    temp_cooler.celsius    = analog_to_celsius_cooler(temp_cooler.raw));
1943
+  TERN_(HAS_TEMP_PROBE,     temp_probe.celsius     = analog_to_celsius_probe(temp_probe.raw));
1944
+  TERN_(HAS_TEMP_REDUNDANT, temp_redundant.celsius = analog_to_celsius_redundant(temp_redundant.raw));
1916 1945
 
1917 1946
   TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_measured_mm());
1918 1947
   TERN_(HAS_POWER_MONITOR,     power_monitor.capture_values());
1919 1948
 
1920 1949
   #if HAS_HOTEND
1921
-
1922 1950
     static constexpr int8_t temp_dir[] = {
1923
-      TERN(TEMP_SENSOR_0_IS_MAX_TC, 0, TEMPDIR(0))
1951
+      #if TEMP_SENSOR_IS_ANY_MAX_TC(0)
1952
+        0
1953
+      #else
1954
+        TEMPDIR(0)
1955
+      #endif
1924 1956
       #if HAS_MULTI_HOTEND
1925
-        , TERN(TEMP_SENSOR_1_IS_MAX_TC, 0, TEMPDIR(1))
1957
+        #if TEMP_SENSOR_IS_ANY_MAX_TC(1)
1958
+          , 0
1959
+        #else
1960
+          , TEMPDIR(1)
1961
+        #endif
1926 1962
         #if HOTENDS > 2
1927 1963
           #define _TEMPDIR(N) , TEMPDIR(N)
1928 1964
           REPEAT_S(2, HOTENDS, _TEMPDIR)
@@ -2031,42 +2067,42 @@ void Temperature::init() {
2031 2067
   #endif
2032 2068
 
2033 2069
   // Init (and disable) SPI thermocouples
2034
-  #if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS)
2070
+  #if TEMP_SENSOR_IS_MAX(0, MAX6675) && PIN_EXISTS(MAX6675_CS)
2035 2071
     OUT_WRITE(MAX6675_CS_PIN, HIGH);
2036 2072
   #endif
2037
-  #if TEMP_SENSOR_1_IS_MAX6675 && PIN_EXISTS(MAX6675_CS2)
2073
+  #if TEMP_SENSOR_IS_MAX(1, MAX6675) && PIN_EXISTS(MAX6675_CS2)
2038 2074
     OUT_WRITE(MAX6675_CS2_PIN, HIGH);
2039 2075
   #endif
2040
-  #if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX31855_CS)
2076
+  #if TEMP_SENSOR_IS_MAX(0, MAX6675) && PIN_EXISTS(MAX31855_CS)
2041 2077
     OUT_WRITE(MAX31855_CS_PIN, HIGH);
2042 2078
   #endif
2043
-  #if TEMP_SENSOR_1_IS_MAX6675 && PIN_EXISTS(MAX31855_CS2)
2079
+  #if TEMP_SENSOR_IS_MAX(1, MAX6675) && PIN_EXISTS(MAX31855_CS2)
2044 2080
     OUT_WRITE(MAX31855_CS2_PIN, HIGH);
2045 2081
   #endif
2046
-  #if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX31865_CS)
2082
+  #if TEMP_SENSOR_IS_MAX(0, MAX6675) && PIN_EXISTS(MAX31865_CS)
2047 2083
     OUT_WRITE(MAX31865_CS_PIN, HIGH);
2048 2084
   #endif
2049
-  #if TEMP_SENSOR_1_IS_MAX6675 && PIN_EXISTS(MAX31865_CS2)
2085
+  #if TEMP_SENSOR_IS_MAX(1, MAX6675) && PIN_EXISTS(MAX31865_CS2)
2050 2086
     OUT_WRITE(MAX31865_CS2_PIN, HIGH);
2051 2087
   #endif
2052 2088
 
2053 2089
   #if HAS_MAX31865_TEMP
2054
-    TERN_(TEMP_SENSOR_0_IS_MAX31865, max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE
2055
-    TERN_(TEMP_SENSOR_1_IS_MAX31865, max31865_1.begin(MAX31865_2WIRE));
2090
+    TERN_(TEMP_SENSOR_IS_MAX(0, MAX31865), max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE
2091
+    TERN_(TEMP_SENSOR_IS_MAX(1, MAX31865), max31865_1.begin(MAX31865_2WIRE));
2056 2092
   #endif
2057 2093
   #if HAS_MAX31855_TEMP
2058
-    TERN_(TEMP_SENSOR_0_IS_MAX31855, max31855_0.begin());
2059
-    TERN_(TEMP_SENSOR_1_IS_MAX31855, max31855_1.begin());
2094
+    TERN_(TEMP_SENSOR_IS_MAX(0, MAX31855), max31855_0.begin());
2095
+    TERN_(TEMP_SENSOR_IS_MAX(1, MAX31855), max31855_1.begin());
2060 2096
   #endif
2061 2097
   #if HAS_MAX6675_TEMP
2062
-    TERN_(TEMP_SENSOR_0_IS_MAX6675, max6675_0.begin());
2063
-    TERN_(TEMP_SENSOR_1_IS_MAX6675, max6675_1.begin());
2098
+    TERN_(TEMP_SENSOR_IS_MAX(0, MAX6675), max6675_0.begin());
2099
+    TERN_(TEMP_SENSOR_IS_MAX(1, MAX6675), max6675_1.begin());
2064 2100
   #endif
2065 2101
 
2066 2102
   #if MB(RUMBA)
2067 2103
     // Disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector
2068 2104
     #define _AD(N) (TEMP_SENSOR_##N##_IS_AD595 || TEMP_SENSOR_##N##_IS_AD8495)
2069
-    #if _AD(0) || _AD(1) || _AD(2) || _AD(BED) || _AD(CHAMBER)
2105
+    #if _AD(0) || _AD(1) || _AD(2) || _AD(BED) || _AD(CHAMBER) || _AD(REDUNDANT)
2070 2106
       MCUCR = _BV(JTD);
2071 2107
       MCUCR = _BV(JTD);
2072 2108
     #endif
@@ -2074,10 +2110,22 @@ void Temperature::init() {
2074 2110
 
2075 2111
   // Thermistor activation by MCU pin
2076 2112
   #if PIN_EXISTS(TEMP_0_TR_ENABLE)
2077
-    OUT_WRITE(TEMP_0_TR_ENABLE_PIN, ENABLED(TEMP_SENSOR_0_IS_MAX_TC));
2113
+    OUT_WRITE(TEMP_0_TR_ENABLE_PIN,
2114
+      #if TEMP_SENSOR_IS_ANY_MAX_TC(0)
2115
+        1
2116
+      #else
2117
+        0
2118
+      #endif
2119
+    );
2078 2120
   #endif
2079 2121
   #if PIN_EXISTS(TEMP_1_TR_ENABLE)
2080
-    OUT_WRITE(TEMP_1_TR_ENABLE_PIN, ENABLED(TEMP_SENSOR_1_IS_MAX_TC));
2122
+    OUT_WRITE(TEMP_1_TR_ENABLE_PIN,
2123
+      #if TEMP_SENSOR_IS_ANY_MAX_TC(1)
2124
+        1
2125
+      #else
2126
+        0
2127
+      #endif
2128
+    );
2081 2129
   #endif
2082 2130
 
2083 2131
   #if HAS_HEATER_0
@@ -2206,6 +2254,9 @@ void Temperature::init() {
2206 2254
   #if HAS_TEMP_ADC_PROBE
2207 2255
     HAL_ANALOG_SELECT(TEMP_PROBE_PIN);
2208 2256
   #endif
2257
+  #if HAS_TEMP_ADC_REDUNDANT
2258
+    HAL_ANALOG_SELECT(TEMP_REDUNDANT_PIN);
2259
+  #endif
2209 2260
   #if ENABLED(FILAMENT_WIDTH_SENSOR)
2210 2261
     HAL_ANALOG_SELECT(FILWIDTH_PIN);
2211 2262
   #endif
@@ -2268,7 +2319,7 @@ void Temperature::init() {
2268 2319
         temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \
2269 2320
     }while(0)
2270 2321
 
2271
-    #define _MINMAX_TEST(N,M) (HOTENDS > N && TEMP_SENSOR_ ##N## _THERMISTOR_ID && TEMP_SENSOR_ ##N## _THERMISTOR_ID != 998 && TEMP_SENSOR_ ##N## _THERMISTOR_ID != 999 && defined(HEATER_##N##_##M##TEMP))
2322
+    #define _MINMAX_TEST(N,M) (HOTENDS > N && TEMP_SENSOR_##N > 0 && TEMP_SENSOR_##N != 998 && TEMP_SENSOR_##N != 999 && defined(HEATER_##N##_##M##TEMP))
2272 2323
 
2273 2324
     #if _MINMAX_TEST(0, MIN)
2274 2325
       _TEMP_MIN_E(0);
@@ -2335,6 +2386,22 @@ void Temperature::init() {
2335 2386
     while (analog_to_celsius_cooler(mintemp_raw_COOLER) > COOLER_MINTEMP) mintemp_raw_COOLER += TEMPDIR(COOLER) * (OVERSAMPLENR);
2336 2387
     while (analog_to_celsius_cooler(maxtemp_raw_COOLER) < COOLER_MAXTEMP) maxtemp_raw_COOLER -= TEMPDIR(COOLER) * (OVERSAMPLENR);
2337 2388
   #endif
2389
+
2390
+  #if HAS_TEMP_REDUNDANT
2391
+    temp_redundant.target = &(
2392
+      #if TEMP_SENSOR_REDUNDANT_TARGET == -5 && HAS_TEMP_COOLER
2393
+        temp_cooler
2394
+      #elif TEMP_SENSOR_REDUNDANT_TARGET == -4 && HAS_TEMP_PROBE
2395
+        temp_probe
2396
+      #elif TEMP_SENSOR_REDUNDANT_TARGET == -2 && HAS_TEMP_CHAMBER
2397
+        temp_chamber
2398
+      #elif TEMP_SENSOR_REDUNDANT_TARGET == -1 && HAS_TEMP_BED
2399
+        temp_bed
2400
+      #else
2401
+        temp_hotend[TEMP_SENSOR_REDUNDANT_TARGET]
2402
+      #endif
2403
+    );
2404
+  #endif
2338 2405
 }
2339 2406
 
2340 2407
 #if HAS_THERMAL_PROTECTION
@@ -2373,7 +2440,7 @@ void Temperature::init() {
2373 2440
           , " ;  Idle Timeout:", heater_idle[idle_index].timed_out
2374 2441
         #endif
2375 2442
       );
2376
-    //*/
2443
+    */
2377 2444
 
2378 2445
     #if HEATER_IDLE_HANDLER
2379 2446
       // If the heater idle timeout expires, restart
@@ -2570,12 +2637,12 @@ void Temperature::disable_all_heaters() {
2570 2637
     #else
2571 2638
       constexpr uint8_t hindex = 0;
2572 2639
       #define THERMO_TEMP(I) max_tc_temp
2573
-      #if TEMP_SENSOR_1_IS_MAX31865
2640
+      #if TEMP_SENSOR_IS_ANY_MAX_TC(1)
2574 2641
         #define THERMO_SEL(A,B) B
2575 2642
       #else
2576 2643
         #define THERMO_SEL(A,B) A
2577 2644
       #endif
2578
-      #if TEMP_SENSOR_0_IS_MAX6675
2645
+      #if TEMP_SENSOR_IS_MAX(0, MAX6675)
2579 2646
         #define MAX6675_WRITE(V)          WRITE(MAX6675_SS_PIN, V)
2580 2647
         #define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS_PIN)
2581 2648
       #else
@@ -2723,12 +2790,12 @@ void Temperature::update_raw_temperatures() {
2723 2790
     temp_hotend[0].update();
2724 2791
   #endif
2725 2792
 
2726
-  #if HAS_TEMP_ADC_1
2727
-    #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
2728
-      temp_redundant.update();
2729
-    #elif !TEMP_SENSOR_1_IS_MAX_TC
2730
-      temp_hotend[1].update();
2731
-    #endif
2793
+  #if HAS_TEMP_ADC_1 && !TEMP_SENSOR_1_IS_MAX_TC
2794
+    temp_hotend[1].update();
2795
+  #endif
2796
+
2797
+  #if HAS_TEMP_ADC_REDUNDANT && !TEMP_SENSOR_REDUNDANT_IS_MAX_TC
2798
+    temp_redundant.update();
2732 2799
   #endif
2733 2800
 
2734 2801
   TERN_(HAS_TEMP_ADC_2, temp_hotend[2].update());
@@ -2764,13 +2831,13 @@ void Temperature::readings_ready() {
2764 2831
 
2765 2832
   #if HAS_HOTEND
2766 2833
     HOTEND_LOOP() temp_hotend[e].reset();
2767
-    TERN_(TEMP_SENSOR_1_AS_REDUNDANT, temp_redundant.reset());
2768 2834
   #endif
2769 2835
 
2770 2836
   TERN_(HAS_HEATED_BED, temp_bed.reset());
2771 2837
   TERN_(HAS_TEMP_CHAMBER, temp_chamber.reset());
2772 2838
   TERN_(HAS_TEMP_PROBE, temp_probe.reset());
2773 2839
   TERN_(HAS_TEMP_COOLER, temp_cooler.reset());
2840
+  TERN_(HAS_TEMP_REDUNDANT, temp_redundant.reset());
2774 2841
 
2775 2842
   TERN_(HAS_JOY_ADC_X, joystick.x.reset());
2776 2843
   TERN_(HAS_JOY_ADC_Y, joystick.y.reset());
@@ -3196,9 +3263,14 @@ void Temperature::isr() {
3196 3263
       case MeasureTemp_PROBE: ACCUMULATE_ADC(temp_probe); break;
3197 3264
     #endif
3198 3265
 
3266
+    #if HAS_TEMP_ADC_REDUNDANT
3267
+      case PrepareTemp_REDUNDANT: HAL_START_ADC(TEMP_REDUNDANT_PIN); break;
3268
+      case MeasureTemp_REDUNDANT: ACCUMULATE_ADC(temp_redundant); break;
3269
+    #endif
3270
+
3199 3271
     #if HAS_TEMP_ADC_1
3200 3272
       case PrepareTemp_1: HAL_START_ADC(TEMP_1_PIN); break;
3201
-      case MeasureTemp_1: ACCUMULATE_ADC(TERN(TEMP_SENSOR_1_AS_REDUNDANT, temp_redundant, temp_hotend[1])); break;
3273
+      case MeasureTemp_1: ACCUMULATE_ADC(temp_hotend[1]); break;
3202 3274
     #endif
3203 3275
 
3204 3276
     #if HAS_TEMP_ADC_2
@@ -3332,6 +3404,7 @@ void Temperature::isr() {
3332 3404
    *    Chamber: " C:nnn.nn /nnn.nn"
3333 3405
    *      Probe: " P:nnn.nn /nnn.nn"
3334 3406
    *     Cooler: " L:nnn.nn /nnn.nn"
3407
+   *  Redundant: " R:nnn.nn /nnn.nn"
3335 3408
    *   Extruder: " T0:nnn.nn /nnn.nn"
3336 3409
    *   With ADC: " T0:nnn.nn /nnn.nn (nnn.nn)"
3337 3410
    */
@@ -3356,7 +3429,7 @@ void Temperature::isr() {
3356 3429
       #if HAS_TEMP_COOLER
3357 3430
         case H_COOLER: k = 'L'; break;
3358 3431
       #endif
3359
-      #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
3432
+      #if HAS_TEMP_REDUNDANT
3360 3433
         case H_REDUNDANT: k = 'R'; break;
3361 3434
       #endif
3362 3435
     }
@@ -3382,13 +3455,10 @@ void Temperature::isr() {
3382 3455
   }
3383 3456
 
3384 3457
   void Temperature::print_heater_states(const uint8_t target_extruder
3385
-    OPTARG(TEMP_SENSOR_1_AS_REDUNDANT, const bool include_r/*=false*/)
3458
+    OPTARG(HAS_TEMP_REDUNDANT, const bool include_r/*=false*/)
3386 3459
   ) {
3387 3460
     #if HAS_TEMP_HOTEND
3388 3461
       print_heater_state(H_NONE, degHotend(target_extruder), degTargetHotend(target_extruder) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTemp(target_extruder)));
3389
-      #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
3390
-        if (include_r) print_heater_state(H_REDUNDANT, degHotendRedundant(), degTargetHotend(0) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTempRedundant()));
3391
-      #endif
3392 3462
     #endif
3393 3463
     #if HAS_HEATED_BED
3394 3464
       print_heater_state(H_BED, degBed(), degTargetBed() OPTARG(SHOW_TEMP_ADC_VALUES, rawBedTemp()));
@@ -3402,6 +3472,9 @@ void Temperature::isr() {
3402 3472
     #if HAS_TEMP_PROBE
3403 3473
       print_heater_state(H_PROBE, degProbe(), 0 OPTARG(SHOW_TEMP_ADC_VALUES, rawProbeTemp()) );
3404 3474
     #endif
3475
+    #if HAS_TEMP_REDUNDANT
3476
+      if (include_r) print_heater_state(H_REDUNDANT, degRedundant(), degRedundantTarget() OPTARG(SHOW_TEMP_ADC_VALUES, rawRedundantTemp()));
3477
+    #endif
3405 3478
     #if HAS_MULTI_HOTEND
3406 3479
       HOTEND_LOOP() print_heater_state((heater_id_t)e, degHotend(e), degTargetHotend(e) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTemp(e)));
3407 3480
     #endif

+ 33
- 13
Marlin/src/module/temperature.h View File

@@ -105,6 +105,9 @@ enum ADCSensorState : char {
105 105
   #if HAS_TEMP_ADC_PROBE
106 106
     PrepareTemp_PROBE, MeasureTemp_PROBE,
107 107
   #endif
108
+  #if HAS_TEMP_ADC_REDUNDANT
109
+    PrepareTemp_REDUNDANT, MeasureTemp_REDUNDANT,
110
+  #endif
108 111
   #if HAS_TEMP_ADC_1
109 112
     PrepareTemp_1, MeasureTemp_1,
110 113
   #endif
@@ -185,6 +188,13 @@ typedef struct TempInfo {
185 188
   inline void update() { raw = acc; }
186 189
 } temp_info_t;
187 190
 
191
+#if HAS_TEMP_REDUNDANT
192
+  // A redundant temperature sensor
193
+  typedef struct RedundantTempInfo : public TempInfo {
194
+    temp_info_t* target;
195
+  } redundant_temp_info_t;
196
+#endif
197
+
188 198
 // A PWM heater with temperature sensor
189 199
 typedef struct HeaterInfo : public TempInfo {
190 200
   celsius_t target;
@@ -299,9 +309,12 @@ typedef struct { int16_t raw_min, raw_max; celsius_t mintemp, maxtemp; } temp_ra
299 309
     #if TEMP_SENSOR_CHAMBER_IS_CUSTOM
300 310
       CTI_CHAMBER,
301 311
     #endif
302
-    #if COOLER_USER_THERMISTOR
312
+    #if TEMP_SENSOR_COOLER_IS_CUSTOM
303 313
       CTI_COOLER,
304 314
     #endif
315
+    #if TEMP_SENSOR_REDUNDANT_IS_CUSTOM
316
+      CTI_REDUNDANT,
317
+    #endif
305 318
     USER_THERMISTORS
306 319
   };
307 320
 
@@ -323,9 +336,6 @@ class Temperature {
323 336
   public:
324 337
 
325 338
     #if HAS_HOTEND
326
-      #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
327
-        static temp_info_t temp_redundant;
328
-      #endif
329 339
       static hotend_info_t temp_hotend[HOTENDS];
330 340
       static const celsius_t hotend_maxtemp[HOTENDS];
331 341
       static inline celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); }
@@ -342,6 +352,9 @@ class Temperature {
342 352
     #if ENABLED(HAS_TEMP_COOLER)
343 353
       static cooler_info_t temp_cooler;
344 354
     #endif
355
+    #if HAS_TEMP_REDUNDANT
356
+      static redundant_temp_info_t temp_redundant;
357
+    #endif
345 358
 
346 359
     #if ENABLED(AUTO_POWER_E_FANS)
347 360
       static uint8_t autofan_speed[HOTENDS];
@@ -538,6 +551,9 @@ class Temperature {
538 551
     #if HAS_TEMP_COOLER
539 552
       static celsius_float_t analog_to_celsius_cooler(const int16_t raw);
540 553
     #endif
554
+    #if HAS_TEMP_REDUNDANT
555
+      static celsius_float_t analog_to_celsius_redundant(const int16_t raw);
556
+    #endif
541 557
 
542 558
     #if HAS_FAN
543 559
 
@@ -626,10 +642,6 @@ class Temperature {
626 642
       return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].celsius);
627 643
     }
628 644
 
629
-    #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
630
-      static inline celsius_float_t degHotendRedundant() { return temp_redundant.celsius; }
631
-    #endif
632
-
633 645
     static inline celsius_t wholeDegHotend(const uint8_t E_NAME) {
634 646
       return TERN0(HAS_HOTEND, static_cast<celsius_t>(temp_hotend[HOTEND_INDEX].celsius + 0.5f));
635 647
     }
@@ -638,9 +650,6 @@ class Temperature {
638 650
       static inline int16_t rawHotendTemp(const uint8_t E_NAME) {
639 651
         return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].raw);
640 652
       }
641
-      #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
642
-        static inline int16_t rawHotendTempRedundant() { return temp_redundant.raw; }
643
-      #endif
644 653
     #endif
645 654
 
646 655
     static inline celsius_t degTargetHotend(const uint8_t E_NAME) {
@@ -778,6 +787,17 @@ class Temperature {
778 787
       #endif
779 788
     #endif
780 789
 
790
+    #if HAS_TEMP_REDUNDANT
791
+      #if ENABLED(SHOW_TEMP_ADC_VALUES)
792
+        static inline int16_t rawRedundantTemp()         { return temp_redundant.raw; }
793
+        static inline int16_t rawRedundanTargetTemp()    { return (*temp_redundant.target).raw; }
794
+      #endif
795
+      static inline celsius_float_t degRedundant()       { return temp_redundant.celsius; }
796
+      static inline celsius_float_t degRedundantTarget() { return (*temp_redundant.target).celsius; }
797
+      static inline celsius_t wholeDegRedundant()        { return static_cast<celsius_t>(temp_redundant.celsius + 0.5f); }
798
+      static inline celsius_t wholeDegRedundantTarget()  { return static_cast<celsius_t>((*temp_redundant.target).celsius + 0.5f); }
799
+    #endif
800
+
781 801
     #if HAS_COOLER
782 802
       static inline void setTargetCooler(const celsius_t celsius) {
783 803
         temp_cooler.target = constrain(celsius, COOLER_MIN_TARGET, COOLER_MAX_TARGET);
@@ -855,7 +875,7 @@ class Temperature {
855 875
 
856 876
     #if HAS_TEMP_SENSOR
857 877
       static void print_heater_states(const uint8_t target_extruder
858
-        OPTARG(TEMP_SENSOR_1_AS_REDUNDANT, const bool include_r=false)
878
+        OPTARG(HAS_TEMP_REDUNDANT, const bool include_r=false)
859 879
       );
860 880
       #if ENABLED(AUTO_REPORT_TEMPERATURES)
861 881
         struct AutoReportTemp { static void report(); };
@@ -888,7 +908,7 @@ class Temperature {
888 908
 
889 909
     // MAX Thermocouples
890 910
     #if HAS_MAX_TC
891
-      #define MAX_TC_COUNT 1 + BOTH(TEMP_SENSOR_0_IS_MAX_TC, TEMP_SENSOR_1_IS_MAX_TC)
911
+      #define MAX_TC_COUNT COUNT_ENABLED(TEMP_SENSOR_0_IS_MAX_TC, TEMP_SENSOR_1_IS_MAX_TC, TEMP_SENSOR_REDUNDANT_IS_MAX_TC)
892 912
       #if MAX_TC_COUNT > 1
893 913
         #define HAS_MULTI_MAX_TC 1
894 914
         #define READ_MAX_TC(N) read_max_tc(N)

+ 1
- 1
Marlin/src/module/thermistor/thermistor_1.h View File

@@ -22,7 +22,7 @@
22 22
 #pragma once
23 23
 
24 24
 // R25 = 100 kOhm, beta25 = 4092 K, 4.7 kOhm pull-up, bed thermistor
25
-const temp_entry_t temptable_1[] PROGMEM = {
25
+constexpr temp_entry_t temptable_1[] PROGMEM = {
26 26
   { OV(  23), 300 },
27 27
   { OV(  25), 295 },
28 28
   { OV(  27), 290 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_10.h View File

@@ -22,7 +22,7 @@
22 22
 #pragma once
23 23
 
24 24
 // R25 = 100 kOhm, beta25 = 3960 K, 4.7 kOhm pull-up, RS thermistor 198-961
25
-const temp_entry_t temptable_10[] PROGMEM = {
25
+constexpr temp_entry_t temptable_10[] PROGMEM = {
26 26
   { OV(   1), 929 },
27 27
   { OV(  36), 299 },
28 28
   { OV(  71), 246 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_1010.h View File

@@ -24,7 +24,7 @@
24 24
 #define REVERSE_TEMP_SENSOR_RANGE_1010 1
25 25
 
26 26
 // Pt1000 with 1k0 pullup
27
-const temp_entry_t temptable_1010[] PROGMEM = {
27
+constexpr temp_entry_t temptable_1010[] PROGMEM = {
28 28
   PtLine(  0, 1000, 1000),
29 29
   PtLine( 25, 1000, 1000),
30 30
   PtLine( 50, 1000, 1000),

+ 1
- 1
Marlin/src/module/thermistor/thermistor_1047.h View File

@@ -24,7 +24,7 @@
24 24
 #define REVERSE_TEMP_SENSOR_RANGE_1047 1
25 25
 
26 26
 // Pt1000 with 4k7 pullup
27
-const temp_entry_t temptable_1047[] PROGMEM = {
27
+constexpr temp_entry_t temptable_1047[] PROGMEM = {
28 28
   // only a few values are needed as the curve is very flat
29 29
   PtLine(  0, 1000, 4700),
30 30
   PtLine( 50, 1000, 4700),

+ 1
- 1
Marlin/src/module/thermistor/thermistor_11.h View File

@@ -22,7 +22,7 @@
22 22
 #pragma once
23 23
 
24 24
 // R25 = 100 kOhm, beta25 = 3950 K, 4.7 kOhm pull-up, QU-BD silicone bed QWG-104F-3950 thermistor
25
-const temp_entry_t temptable_11[] PROGMEM = {
25
+constexpr temp_entry_t temptable_11[] PROGMEM = {
26 26
   { OV(   1), 938 },
27 27
   { OV(  31), 314 },
28 28
   { OV(  41), 290 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_110.h View File

@@ -24,7 +24,7 @@
24 24
 #define REVERSE_TEMP_SENSOR_RANGE_110 1
25 25
 
26 26
 // Pt100 with 1k0 pullup
27
-const temp_entry_t temptable_110[] PROGMEM = {
27
+constexpr temp_entry_t temptable_110[] PROGMEM = {
28 28
   // only a few values are needed as the curve is very flat
29 29
   PtLine(  0, 100, 1000),
30 30
   PtLine( 50, 100, 1000),

+ 1
- 1
Marlin/src/module/thermistor/thermistor_12.h View File

@@ -22,7 +22,7 @@
22 22
 #pragma once
23 23
 
24 24
 // R25 = 100 kOhm, beta25 = 4700 K, 4.7 kOhm pull-up, (personal calibration for Makibox hot bed)
25
-const temp_entry_t temptable_12[] PROGMEM = {
25
+constexpr temp_entry_t temptable_12[] PROGMEM = {
26 26
   { OV(  35), 180 }, // top rating 180C
27 27
   { OV( 211), 140 },
28 28
   { OV( 233), 135 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_13.h View File

@@ -22,7 +22,7 @@
22 22
 #pragma once
23 23
 
24 24
 // R25 = 100 kOhm, beta25 = 4100 K, 4.7 kOhm pull-up, Hisens thermistor
25
-const temp_entry_t temptable_13[] PROGMEM = {
25
+constexpr temp_entry_t temptable_13[] PROGMEM = {
26 26
   { OV( 20.04), 300 },
27 27
   { OV( 23.19), 290 },
28 28
   { OV( 26.71), 280 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_147.h View File

@@ -24,7 +24,7 @@
24 24
 #define REVERSE_TEMP_SENSOR_RANGE_147 1
25 25
 
26 26
 // Pt100 with 4k7 pullup
27
-const temp_entry_t temptable_147[] PROGMEM = {
27
+constexpr temp_entry_t temptable_147[] PROGMEM = {
28 28
   // only a few values are needed as the curve is very flat
29 29
   PtLine(  0, 100, 4700),
30 30
   PtLine( 50, 100, 4700),

+ 1
- 1
Marlin/src/module/thermistor/thermistor_15.h View File

@@ -22,7 +22,7 @@
22 22
 #pragma once
23 23
 
24 24
  // 100k bed thermistor in JGAurora A5. Calibrated by Sam Pinches 21st Jan 2018 using cheap k-type thermocouple inserted into heater block, using TM-902C meter.
25
-const temp_entry_t temptable_15[] PROGMEM = {
25
+constexpr temp_entry_t temptable_15[] PROGMEM = {
26 26
   { OV(  31), 275 },
27 27
   { OV(  33), 270 },
28 28
   { OV(  35), 260 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_17.h View File

@@ -22,7 +22,7 @@
22 22
 #pragma once
23 23
 
24 24
 // Dagoma NTC 100k white thermistor
25
-const temp_entry_t temptable_17[] PROGMEM = {
25
+constexpr temp_entry_t temptable_17[] PROGMEM = {
26 26
   { OV(  16),  309 },
27 27
   { OV(  18),  307 },
28 28
   { OV(  20),  300 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_18.h View File

@@ -22,7 +22,7 @@
22 22
 #pragma once
23 23
 
24 24
 // ATC Semitec 204GT-2 (4.7k pullup) Dagoma.Fr - MKS_Base_DKU001327 - version (measured/tested/approved)
25
-const temp_entry_t temptable_18[] PROGMEM = {
25
+constexpr temp_entry_t temptable_18[] PROGMEM = {
26 26
   { OV(   1), 713 },
27 27
   { OV(  17), 284 },
28 28
   { OV(  20), 275 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_2.h View File

@@ -26,7 +26,7 @@
26 26
 // Verified by linagee. Source: https://www.mouser.com/datasheet/2/362/semitec%20usa%20corporation_gtthermistor-1202937.pdf
27 27
 // Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance
28 28
 //
29
-const temp_entry_t temptable_2[] PROGMEM = {
29
+constexpr temp_entry_t temptable_2[] PROGMEM = {
30 30
   { OV(   1), 848 },
31 31
   { OV(  30), 300 }, // top rating 300C
32 32
   { OV(  34), 290 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_20.h View File

@@ -24,7 +24,7 @@
24 24
 #define REVERSE_TEMP_SENSOR_RANGE_20 1
25 25
 
26 26
 // Pt100 with INA826 amp on Ultimaker v2.0 electronics
27
-const temp_entry_t temptable_20[] PROGMEM = {
27
+constexpr temp_entry_t temptable_20[] PROGMEM = {
28 28
   { OV(  0),    0 },
29 29
   { OV(227),    1 },
30 30
   { OV(236),   10 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_201.h View File

@@ -24,7 +24,7 @@
24 24
 #define REVERSE_TEMP_SENSOR_RANGE_201 1
25 25
 
26 26
 // Pt100 with LMV324 amp on Overlord v1.1 electronics
27
-const temp_entry_t temptable_201[] PROGMEM = {
27
+constexpr temp_entry_t temptable_201[] PROGMEM = {
28 28
   { OV(   0),   0 },
29 29
   { OV(   8),   1 },
30 30
   { OV(  23),   6 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_202.h View File

@@ -3,7 +3,7 @@
3 3
 // Temptable sent from dealer technologyoutlet.co.uk
4 4
 //
5 5
 
6
-const temp_entry_t temptable_202[] PROGMEM = {
6
+constexpr temp_entry_t temptable_202[] PROGMEM = {
7 7
   { OV(   1), 864 },
8 8
   { OV(  35), 300 },
9 9
   { OV(  38), 295 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_21.h View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 // Pt100 with INA826 amplifier board with 5v supply based on Thermistor 20, with 3v3 ADC reference on the mainboard.
30 30
 // If the ADC reference and INA826 board supply voltage are identical, Thermistor 20 instead.
31
-const temp_entry_t temptable_21[] PROGMEM = {
31
+constexpr temp_entry_t temptable_21[] PROGMEM = {
32 32
   { OV(  0),    0 },
33 33
   { OV(227),    1 },
34 34
   { OV(236),   10 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_22.h View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 
23 23
 // 100k hotend thermistor with 4.7k pull up to 3.3v and 220R to analog input as in GTM32 Pro vB
24
-const temp_entry_t temptable_22[] PROGMEM = {
24
+constexpr temp_entry_t temptable_22[] PROGMEM = {
25 25
   { OV(   1), 352 },
26 26
   { OV(   6), 341 },
27 27
   { OV(  11), 330 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_23.h View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 
23 23
 // 100k hotbed thermistor with 4.7k pull up to 3.3v and 220R to analog input as in GTM32 Pro vB
24
-const temp_entry_t temptable_23[] PROGMEM = {
24
+constexpr temp_entry_t temptable_23[] PROGMEM = {
25 25
   { OV(   1), 938 },
26 26
   { OV(  11), 423 },
27 27
   { OV(  21), 351 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_3.h View File

@@ -22,7 +22,7 @@
22 22
 #pragma once
23 23
 
24 24
 // R25 = 100 kOhm, beta25 = 4120 K, 4.7 kOhm pull-up, mendel-parts
25
-const temp_entry_t temptable_3[] PROGMEM = {
25
+constexpr temp_entry_t temptable_3[] PROGMEM = {
26 26
   { OV(   1), 864 },
27 27
   { OV(  21), 300 },
28 28
   { OV(  25), 290 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_30.h View File

@@ -28,7 +28,7 @@
28 28
 // B Value Tolerance         + / - 1%
29 29
 // Kis3d Silicone Heater 24V 200W/300W with 6mm Precision cast plate (EN AW 5083)
30 30
 // Temperature setting time 10 min to determine the 12Bit ADC value on the surface. (le3tspeak)
31
-const temp_entry_t temptable_30[] PROGMEM = {
31
+constexpr temp_entry_t temptable_30[] PROGMEM = {
32 32
   { OV(   1), 938 },
33 33
   { OV( 298), 125 }, // 1193 - 125°
34 34
   { OV( 321), 121 }, // 1285 - 121°

+ 1
- 1
Marlin/src/module/thermistor/thermistor_331.h View File

@@ -24,7 +24,7 @@
24 24
 #define OVM(V) OV((V)*(0.327/0.5))
25 25
 
26 26
 // R25 = 100 kOhm, beta25 = 4092 K, 4.7 kOhm pull-up, bed thermistor
27
-const temp_entry_t temptable_331[] PROGMEM = {
27
+constexpr temp_entry_t temptable_331[] PROGMEM = {
28 28
   { OVM(  23), 300 },
29 29
   { OVM(  25), 295 },
30 30
   { OVM(  27), 290 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_332.h View File

@@ -24,7 +24,7 @@
24 24
 #define OVM(V) OV((V)*(0.327/0.327))
25 25
 
26 26
 // R25 = 100 kOhm, beta25 = 4092 K, 4.7 kOhm pull-up, bed thermistor
27
-const temp_entry_t temptable_332[] PROGMEM = {
27
+constexpr temp_entry_t temptable_332[] PROGMEM = {
28 28
   { OVM( 268), 150 },
29 29
   { OVM( 293), 145 },
30 30
   { OVM( 320), 141 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_4.h View File

@@ -22,7 +22,7 @@
22 22
 #pragma once
23 23
 
24 24
 // R25 = 10 kOhm, beta25 = 3950 K, 4.7 kOhm pull-up, Generic 10k thermistor
25
-const temp_entry_t temptable_4[] PROGMEM = {
25
+constexpr temp_entry_t temptable_4[] PROGMEM = {
26 26
   { OV(   1), 430 },
27 27
   { OV(  54), 137 },
28 28
   { OV( 107), 107 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_5.h View File

@@ -26,7 +26,7 @@
26 26
 // ATC Semitec 104GT-2/104NT-4-R025H42G (Used in ParCan)
27 27
 // Verified by linagee. Source: https://www.mouser.com/datasheet/2/362/semitec%20usa%20corporation_gtthermistor-1202937.pdf
28 28
 // Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance
29
-const temp_entry_t temptable_5[] PROGMEM = {
29
+constexpr temp_entry_t temptable_5[] PROGMEM = {
30 30
   { OV(   1), 713 },
31 31
   { OV(  17), 300 }, // top rating 300C
32 32
   { OV(  20), 290 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_501.h View File

@@ -22,7 +22,7 @@
22 22
 #pragma once
23 23
 
24 24
 // 100k Zonestar thermistor. Adjusted By Hally
25
-const temp_entry_t temptable_501[] PROGMEM = {
25
+constexpr temp_entry_t temptable_501[] PROGMEM = {
26 26
    { OV(   1), 713 },
27 27
    { OV(  14), 300 }, // Top rating 300C
28 28
    { OV(  16), 290 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_502.h View File

@@ -23,7 +23,7 @@
23 23
 
24 24
 // Unknown thermistor for the Zonestar P802M hot bed. Adjusted By Nerseth
25 25
 // These were the shipped settings from Zonestar in original firmware: P802M_8_Repetier_V1.6_Zonestar.zip
26
-const temp_entry_t temptable_502[] PROGMEM = {
26
+constexpr temp_entry_t temptable_502[] PROGMEM = {
27 27
    { OV(  56.0 / 4), 300 },
28 28
    { OV( 187.0 / 4), 250 },
29 29
    { OV( 615.0 / 4), 190 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_503.h View File

@@ -23,7 +23,7 @@
23 23
 
24 24
 // Zonestar (Z8XM2) Heated Bed thermistor. Added By AvanOsch
25 25
 // These are taken from the Zonestar settings in original Repetier firmware: Z8XM2_ZRIB_LCD12864_V51.zip
26
-const temp_entry_t temptable_503[] PROGMEM = {
26
+constexpr temp_entry_t temptable_503[] PROGMEM = {
27 27
    { OV(  12), 300 },
28 28
    { OV(  27), 270 },
29 29
    { OV(  47), 250 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_51.h View File

@@ -26,7 +26,7 @@
26 26
 // Verified by linagee.
27 27
 // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance
28 28
 // Advantage: Twice the resolution and better linearity from 150C to 200C
29
-const temp_entry_t temptable_51[] PROGMEM = {
29
+constexpr temp_entry_t temptable_51[] PROGMEM = {
30 30
   { OV(   1), 350 },
31 31
   { OV( 190), 250 }, // top rating 250C
32 32
   { OV( 203), 245 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_512.h View File

@@ -22,7 +22,7 @@
22 22
 
23 23
 // 100k thermistor supplied with RPW-Ultra hotend, 4.7k pullup
24 24
 
25
-const temp_entry_t temptable_512[] PROGMEM = {
25
+constexpr temp_entry_t temptable_512[] PROGMEM = {
26 26
   { OV(26),  300 },
27 27
   { OV(28),  295 },
28 28
   { OV(30),  290 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_52.h View File

@@ -26,7 +26,7 @@
26 26
 // Verified by linagee. Source: https://www.mouser.com/datasheet/2/362/semitec%20usa%20corporation_gtthermistor-1202937.pdf
27 27
 // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance
28 28
 // Advantage: More resolution and better linearity from 150C to 200C
29
-const temp_entry_t temptable_52[] PROGMEM = {
29
+constexpr temp_entry_t temptable_52[] PROGMEM = {
30 30
   { OV(   1), 500 },
31 31
   { OV( 125), 300 }, // top rating 300C
32 32
   { OV( 142), 290 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_55.h View File

@@ -26,7 +26,7 @@
26 26
 // Verified by linagee. Source: https://www.mouser.com/datasheet/2/362/semitec%20usa%20corporation_gtthermistor-1202937.pdf
27 27
 // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance
28 28
 // Advantage: More resolution and better linearity from 150C to 200C
29
-const temp_entry_t temptable_55[] PROGMEM = {
29
+constexpr temp_entry_t temptable_55[] PROGMEM = {
30 30
   { OV(   1), 500 },
31 31
   { OV(  76), 300 },
32 32
   { OV(  87), 290 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_6.h View File

@@ -22,7 +22,7 @@
22 22
 #pragma once
23 23
 
24 24
 // R25 = 100 kOhm, beta25 = 4092 K, 8.2 kOhm pull-up, 100k Epcos (?) thermistor
25
-const temp_entry_t temptable_6[] PROGMEM = {
25
+constexpr temp_entry_t temptable_6[] PROGMEM = {
26 26
   { OV(   1), 350 },
27 27
   { OV(  28), 250 }, // top rating 250C
28 28
   { OV(  31), 245 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_60.h View File

@@ -31,7 +31,7 @@
31 31
 // beta: 3950
32 32
 // min adc: 1 at 0.0048828125 V
33 33
 // max adc: 1023 at 4.9951171875 V
34
-const temp_entry_t temptable_60[] PROGMEM = {
34
+constexpr temp_entry_t temptable_60[] PROGMEM = {
35 35
   { OV(  51), 272 },
36 36
   { OV(  61), 258 },
37 37
   { OV(  71), 247 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_61.h View File

@@ -30,7 +30,7 @@
30 30
 // Resistance Tolerance     + / -1%
31 31
 // B Value             3950K at 25/50 deg. C
32 32
 // B Value Tolerance         + / - 1%
33
-const temp_entry_t temptable_61[] PROGMEM = {
33
+constexpr temp_entry_t temptable_61[] PROGMEM = {
34 34
   { OV(   2.00), 420 }, // Guestimate to ensure we dont lose a reading and drop temps to -50 when over
35 35
   { OV(  12.07), 350 },
36 36
   { OV(  12.79), 345 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_66.h View File

@@ -22,7 +22,7 @@
22 22
 #pragma once
23 23
 
24 24
 // R25 = 2.5 MOhm, beta25 = 4500 K, 4.7 kOhm pull-up, DyzeDesign 500 °C Thermistor
25
-const temp_entry_t temptable_66[] PROGMEM = {
25
+constexpr temp_entry_t temptable_66[] PROGMEM = {
26 26
   { OV(  17.5), 850 },
27 27
   { OV(  17.9), 500 },
28 28
   { OV(  21.7), 480 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_666.h View File

@@ -33,7 +33,7 @@
33 33
  * B: 0.00031362
34 34
  * C: -2.03978e-07
35 35
  */
36
-const temp_entry_t temptable_666[] PROGMEM = {
36
+constexpr temp_entry_t temptable_666[] PROGMEM = {
37 37
   { OV(  1), 794 },
38 38
   { OV( 18), 288 },
39 39
   { OV( 35), 234 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_67.h View File

@@ -22,7 +22,7 @@
22 22
 #pragma once
23 23
 
24 24
 // R25 = 500 KOhm, beta25 = 3800 K, 4.7 kOhm pull-up, SliceEngineering 450 °C Thermistor
25
-const temp_entry_t temptable_67[] PROGMEM = {
25
+constexpr temp_entry_t temptable_67[] PROGMEM = {
26 26
   { OV(  22 ),  500 },
27 27
   { OV(  23 ),  490 },
28 28
   { OV(  25 ),  480 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_7.h View File

@@ -22,7 +22,7 @@
22 22
 #pragma once
23 23
 
24 24
 // R25 = 100 kOhm, beta25 = 3974 K, 4.7 kOhm pull-up, Honeywell 135-104LAG-J01
25
-const temp_entry_t temptable_7[] PROGMEM = {
25
+constexpr temp_entry_t temptable_7[] PROGMEM = {
26 26
   { OV(   1), 941 },
27 27
   { OV(  19), 362 },
28 28
   { OV(  37), 299 }, // top rating 300C

+ 1
- 1
Marlin/src/module/thermistor/thermistor_70.h View File

@@ -26,7 +26,7 @@
26 26
 // ANENG AN8009 DMM with a K-type probe used for measurements.
27 27
 
28 28
 // R25 = 100 kOhm, beta25 = 4100 K, 4.7 kOhm pull-up, bqh2 stock thermistor
29
-const temp_entry_t temptable_70[] PROGMEM = {
29
+constexpr temp_entry_t temptable_70[] PROGMEM = {
30 30
   { OV(  18), 270 },
31 31
   { OV(  27), 248 },
32 32
   { OV(  34), 234 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_71.h View File

@@ -27,7 +27,7 @@
27 27
 // Beta = 3974
28 28
 // R1 = 0 Ohm
29 29
 // R2 = 4700 Ohm
30
-const temp_entry_t temptable_71[] PROGMEM = {
30
+constexpr temp_entry_t temptable_71[] PROGMEM = {
31 31
   { OV(  35), 300 },
32 32
   { OV(  51), 269 },
33 33
   { OV(  59), 258 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_75.h View File

@@ -34,7 +34,7 @@
34 34
 
35 35
 //#define HIGH_TEMP_RANGE_75
36 36
 
37
-const temp_entry_t temptable_75[] PROGMEM = { // Generic Silicon Heat Pad with NTC 100K MGB18-104F39050L32 thermistor
37
+constexpr temp_entry_t temptable_75[] PROGMEM = { // Generic Silicon Heat Pad with NTC 100K MGB18-104F39050L32 thermistor
38 38
   { OV(111.06), 200 }, // v=0.542 r=571.747 res=0.501 degC/count
39 39
 
40 40
   #ifdef HIGH_TEMP_RANGE_75

+ 1
- 1
Marlin/src/module/thermistor/thermistor_8.h View File

@@ -22,7 +22,7 @@
22 22
 #pragma once
23 23
 
24 24
 // R25 = 100 kOhm, beta25 = 3950 K, 10 kOhm pull-up, NTCS0603E3104FHT
25
-const temp_entry_t temptable_8[] PROGMEM = {
25
+constexpr temp_entry_t temptable_8[] PROGMEM = {
26 26
   { OV(   1), 704 },
27 27
   { OV(  54), 216 },
28 28
   { OV( 107), 175 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_9.h View File

@@ -22,7 +22,7 @@
22 22
 #pragma once
23 23
 
24 24
 // R25 = 100 kOhm, beta25 = 3960 K, 4.7 kOhm pull-up, GE Sensing AL03006-58.2K-97-G1
25
-const temp_entry_t temptable_9[] PROGMEM = {
25
+constexpr temp_entry_t temptable_9[] PROGMEM = {
26 26
   { OV(   1), 936 },
27 27
   { OV(  36), 300 },
28 28
   { OV(  71), 246 },

+ 1
- 1
Marlin/src/module/thermistor/thermistor_99.h View File

@@ -24,7 +24,7 @@
24 24
 
25 25
 // 100k bed thermistor with a 10K pull-up resistor - made by $ buildroot/share/scripts/createTemperatureLookupMarlin.py --rp=10000
26 26
 
27
-const temp_entry_t temptable_99[] PROGMEM = {
27
+constexpr temp_entry_t temptable_99[] PROGMEM = {
28 28
   { OV(  5.81), 350 }, // v=0.028   r=    57.081  res=13.433 degC/count
29 29
   { OV(  6.54), 340 }, // v=0.032   r=    64.248  res=11.711 degC/count
30 30
   { OV(  7.38), 330 }, // v=0.036   r=    72.588  res=10.161 degC/count

+ 1
- 1
Marlin/src/module/thermistor/thermistor_998.h View File

@@ -27,7 +27,7 @@
27 27
   #define DUMMY_THERMISTOR_998_VALUE 25
28 28
 #endif
29 29
 
30
-const temp_entry_t temptable_998[] PROGMEM = {
30
+constexpr temp_entry_t temptable_998[] PROGMEM = {
31 31
   { OV(   1), DUMMY_THERMISTOR_998_VALUE },
32 32
   { OV(1023), DUMMY_THERMISTOR_998_VALUE }
33 33
 };

+ 1
- 1
Marlin/src/module/thermistor/thermistor_999.h View File

@@ -27,7 +27,7 @@
27 27
   #define DUMMY_THERMISTOR_999_VALUE 25
28 28
 #endif
29 29
 
30
-const temp_entry_t temptable_999[] PROGMEM = {
30
+constexpr temp_entry_t temptable_999[] PROGMEM = {
31 31
   { OV(   1), DUMMY_THERMISTOR_999_VALUE },
32 32
   { OV(1023), DUMMY_THERMISTOR_999_VALUE }
33 33
 };

+ 62
- 62
Marlin/src/module/thermistor/thermistors.h View File

@@ -42,7 +42,16 @@
42 42
 #define OV_SCALE(N) (N)
43 43
 #define OV(N) int16_t(OV_SCALE(N) * (OVERSAMPLENR) * (THERMISTOR_TABLE_SCALE))
44 44
 
45
-#define ANY_THERMISTOR_IS(n) (TEMP_SENSOR_0_THERMISTOR_ID == n || TEMP_SENSOR_1_THERMISTOR_ID == n || TEMP_SENSOR_2_THERMISTOR_ID == n || TEMP_SENSOR_3_THERMISTOR_ID == n || TEMP_SENSOR_4_THERMISTOR_ID == n || TEMP_SENSOR_5_THERMISTOR_ID == n || TEMP_SENSOR_6_THERMISTOR_ID == n || TEMP_SENSOR_7_THERMISTOR_ID == n || TEMP_SENSOR_BED_THERMISTOR_ID == n || TEMP_SENSOR_CHAMBER_THERMISTOR_ID == n || TEMP_SENSOR_COOLER_THERMISTOR_ID == n || TEMP_SENSOR_PROBE_THERMISTOR_ID == n)
45
+#define TEMP_SENSOR_IS(n,H) (n == TEMP_SENSOR_##H)
46
+#define ANY_THERMISTOR_IS(n) ( TEMP_SENSOR_IS(n, 0) || TEMP_SENSOR_IS(n, 1) \
47
+                            || TEMP_SENSOR_IS(n, 2) || TEMP_SENSOR_IS(n, 3) \
48
+                            || TEMP_SENSOR_IS(n, 4) || TEMP_SENSOR_IS(n, 5) \
49
+                            || TEMP_SENSOR_IS(n, 6) || TEMP_SENSOR_IS(n, 7) \
50
+                            || TEMP_SENSOR_IS(n, BED) \
51
+                            || TEMP_SENSOR_IS(n, CHAMBER) \
52
+                            || TEMP_SENSOR_IS(n, COOLER) \
53
+                            || TEMP_SENSOR_IS(n, PROBE) \
54
+                            || TEMP_SENSOR_IS(n, REDUNDANT) )
46 55
 
47 56
 typedef struct { int16_t value; celsius_t celsius; } temp_entry_t;
48 57
 
@@ -198,146 +207,128 @@ typedef struct { int16_t value; celsius_t celsius; } temp_entry_t;
198 207
   #include "thermistor_999.h"
199 208
 #endif
200 209
 #if ANY_THERMISTOR_IS(1000) // Custom
201
-  const temp_entry_t temptable_1000[] PROGMEM = { { 0, 0 } };
210
+  constexpr temp_entry_t temptable_1000[] PROGMEM = { { 0, 0 } };
202 211
 #endif
203 212
 
204 213
 #define _TT_NAME(_N) temptable_ ## _N
205 214
 #define TT_NAME(_N) _TT_NAME(_N)
206 215
 
207
-
208
-#if TEMP_SENSOR_0_THERMISTOR_ID
209
-  #define TEMPTABLE_0 TT_NAME(TEMP_SENSOR_0_THERMISTOR_ID)
216
+#if TEMP_SENSOR_0 > 0
217
+  #define TEMPTABLE_0 TT_NAME(TEMP_SENSOR_0)
210 218
   #define TEMPTABLE_0_LEN COUNT(TEMPTABLE_0)
211
-#elif TEMP_SENSOR_0_IS_THERMISTOR
212
-  #error "No heater 0 thermistor table specified"
213 219
 #else
214 220
   #define TEMPTABLE_0 nullptr
215 221
   #define TEMPTABLE_0_LEN 0
216 222
 #endif
217 223
 
218
-#if TEMP_SENSOR_1_THERMISTOR_ID
219
-  #define TEMPTABLE_1 TT_NAME(TEMP_SENSOR_1_THERMISTOR_ID)
224
+#if TEMP_SENSOR_1 > 0
225
+  #define TEMPTABLE_1 TT_NAME(TEMP_SENSOR_1)
220 226
   #define TEMPTABLE_1_LEN COUNT(TEMPTABLE_1)
221
-#elif TEMP_SENSOR_1_IS_THERMISTOR
222
-  #error "No heater 1 thermistor table specified"
223 227
 #else
224 228
   #define TEMPTABLE_1 nullptr
225 229
   #define TEMPTABLE_1_LEN 0
226 230
 #endif
227 231
 
228
-#if TEMP_SENSOR_2_THERMISTOR_ID
229
-  #define TEMPTABLE_2 TT_NAME(TEMP_SENSOR_2_THERMISTOR_ID)
232
+#if TEMP_SENSOR_2 > 0
233
+  #define TEMPTABLE_2 TT_NAME(TEMP_SENSOR_2)
230 234
   #define TEMPTABLE_2_LEN COUNT(TEMPTABLE_2)
231
-#elif TEMP_SENSOR_2_IS_THERMISTOR
232
-  #error "No heater 2 thermistor table specified"
233 235
 #else
234 236
   #define TEMPTABLE_2 nullptr
235 237
   #define TEMPTABLE_2_LEN 0
236 238
 #endif
237 239
 
238
-#if TEMP_SENSOR_3_THERMISTOR_ID
239
-  #define TEMPTABLE_3 TT_NAME(TEMP_SENSOR_3_THERMISTOR_ID)
240
+#if TEMP_SENSOR_3 > 0
241
+  #define TEMPTABLE_3 TT_NAME(TEMP_SENSOR_3)
240 242
   #define TEMPTABLE_3_LEN COUNT(TEMPTABLE_3)
241
-#elif TEMP_SENSOR_3_IS_THERMISTOR
242
-  #error "No heater 3 thermistor table specified"
243 243
 #else
244 244
   #define TEMPTABLE_3 nullptr
245 245
   #define TEMPTABLE_3_LEN 0
246 246
 #endif
247 247
 
248
-#if TEMP_SENSOR_4_THERMISTOR_ID
249
-  #define TEMPTABLE_4 TT_NAME(TEMP_SENSOR_4_THERMISTOR_ID)
248
+#if TEMP_SENSOR_4 > 0
249
+  #define TEMPTABLE_4 TT_NAME(TEMP_SENSOR_4)
250 250
   #define TEMPTABLE_4_LEN COUNT(TEMPTABLE_4)
251
-#elif TEMP_SENSOR_4_IS_THERMISTOR
252
-  #error "No heater 4 thermistor table specified"
253 251
 #else
254 252
   #define TEMPTABLE_4 nullptr
255 253
   #define TEMPTABLE_4_LEN 0
256 254
 #endif
257 255
 
258
-#if TEMP_SENSOR_5_THERMISTOR_ID
259
-  #define TEMPTABLE_5 TT_NAME(TEMP_SENSOR_5_THERMISTOR_ID)
256
+#if TEMP_SENSOR_5 > 0
257
+  #define TEMPTABLE_5 TT_NAME(TEMP_SENSOR_5)
260 258
   #define TEMPTABLE_5_LEN COUNT(TEMPTABLE_5)
261
-#elif TEMP_SENSOR_5_IS_THERMISTOR
262
-  #error "No heater 5 thermistor table specified"
263 259
 #else
264 260
   #define TEMPTABLE_5 nullptr
265 261
   #define TEMPTABLE_5_LEN 0
266 262
 #endif
267 263
 
268
-#if TEMP_SENSOR_6_THERMISTOR_ID
269
-  #define TEMPTABLE_6 TT_NAME(TEMP_SENSOR_6_THERMISTOR_ID)
264
+#if TEMP_SENSOR_6 > 0
265
+  #define TEMPTABLE_6 TT_NAME(TEMP_SENSOR_6)
270 266
   #define TEMPTABLE_6_LEN COUNT(TEMPTABLE_6)
271
-#elif TEMP_SENSOR_6_IS_THERMISTOR
272
-  #error "No heater 6 thermistor table specified"
273 267
 #else
274 268
   #define TEMPTABLE_6 nullptr
275 269
   #define TEMPTABLE_6_LEN 0
276 270
 #endif
277 271
 
278
-#if TEMP_SENSOR_7_THERMISTOR_ID
279
-  #define TEMPTABLE_7 TT_NAME(TEMP_SENSOR_7_THERMISTOR_ID)
272
+#if TEMP_SENSOR_7 > 0
273
+  #define TEMPTABLE_7 TT_NAME(TEMP_SENSOR_7)
280 274
   #define TEMPTABLE_7_LEN COUNT(TEMPTABLE_7)
281
-#elif TEMP_SENSOR_7_IS_THERMISTOR
282
-  #error "No heater 7 thermistor table specified"
283 275
 #else
284 276
   #define TEMPTABLE_7 nullptr
285 277
   #define TEMPTABLE_7_LEN 0
286 278
 #endif
287 279
 
288
-#ifdef TEMP_SENSOR_BED_THERMISTOR_ID
289
-  #define TEMPTABLE_BED TT_NAME(TEMP_SENSOR_BED_THERMISTOR_ID)
280
+#if TEMP_SENSOR_BED > 0
281
+  #define TEMPTABLE_BED TT_NAME(TEMP_SENSOR_BED)
290 282
   #define TEMPTABLE_BED_LEN COUNT(TEMPTABLE_BED)
291
-#elif TEMP_SENSOR_BED_IS_THERMISTOR
292
-  #error "No bed thermistor table specified"
293 283
 #else
294 284
   #define TEMPTABLE_BED_LEN 0
295 285
 #endif
296 286
 
297
-#ifdef TEMP_SENSOR_CHAMBER_THERMISTOR_ID
298
-  #define TEMPTABLE_CHAMBER TT_NAME(TEMP_SENSOR_CHAMBER_THERMISTOR_ID)
287
+#if TEMP_SENSOR_CHAMBER > 0
288
+  #define TEMPTABLE_CHAMBER TT_NAME(TEMP_SENSOR_CHAMBER)
299 289
   #define TEMPTABLE_CHAMBER_LEN COUNT(TEMPTABLE_CHAMBER)
300
-#elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR
301
-  #error "No chamber thermistor table specified"
302 290
 #else
303 291
   #define TEMPTABLE_CHAMBER_LEN 0
304 292
 #endif
305 293
 
306
-#ifdef TEMP_SENSOR_COOLER_THERMISTOR_ID
307
-  #define TEMPTABLE_COOLER TT_NAME(TEMP_SENSOR_COOLER_THERMISTOR_ID)
294
+#if TEMP_SENSOR_COOLER > 0
295
+  #define TEMPTABLE_COOLER TT_NAME(TEMP_SENSOR_COOLER)
308 296
   #define TEMPTABLE_COOLER_LEN COUNT(TEMPTABLE_COOLER)
309
-#elif TEMP_SENSOR_COOLER_IS_THERMISTOR
310
-  #error "No cooler thermistor table specified"
311 297
 #else
312 298
   #define TEMPTABLE_COOLER_LEN 0
313 299
 #endif
314
-#ifdef TEMP_SENSOR_PROBE_THERMISTOR_ID
315
-  #define TEMPTABLE_PROBE TT_NAME(TEMP_SENSOR_PROBE_THERMISTOR_ID)
300
+
301
+#if TEMP_SENSOR_PROBE > 0
302
+  #define TEMPTABLE_PROBE TT_NAME(TEMP_SENSOR_PROBE)
316 303
   #define TEMPTABLE_PROBE_LEN COUNT(TEMPTABLE_PROBE)
317
-#elif TEMP_SENSOR_PROBE_IS_THERMISTOR
318
-  #error "No probe thermistor table specified"
319 304
 #else
320 305
   #define TEMPTABLE_PROBE_LEN 0
321 306
 #endif
322 307
 
308
+#if TEMP_SENSOR_REDUNDANT > 0
309
+  #define TEMPTABLE_REDUNDANT TT_NAME(TEMP_SENSOR_REDUNDANT)
310
+  #define TEMPTABLE_REDUNDANT_LEN COUNT(TEMPTABLE_REDUNDANT)
311
+#else
312
+  #define TEMPTABLE_REDUNDANT_LEN 0
313
+#endif
314
+
323 315
 // The SCAN_THERMISTOR_TABLE macro needs alteration?
324
-static_assert(
325
-     TEMPTABLE_0_LEN < 256 && TEMPTABLE_1_LEN < 256
326
-  && TEMPTABLE_2_LEN < 256 && TEMPTABLE_3_LEN < 256
327
-  && TEMPTABLE_4_LEN < 256 && TEMPTABLE_5_LEN < 256
328
-  && TEMPTABLE_6_LEN < 256 && TEMPTABLE_7_LEN < 256
329
-  && TEMPTABLE_BED_LEN < 256 && TEMPTABLE_CHAMBER_LEN < 256
330
-  && TEMPTABLE_COOLER_LEN < 256 && TEMPTABLE_PROBE_LEN < 256,
331
-  "Temperature conversion tables over 255 entries need special consideration."
316
+static_assert(255 > TEMPTABLE_0_LEN || 255 > TEMPTABLE_1_LEN || 255 > TEMPTABLE_2_LEN || 255 > TEMPTABLE_3_LEN
317
+           || 255 > TEMPTABLE_4_LEN || 255 > TEMPTABLE_5_LEN || 255 > TEMPTABLE_6_LEN || 255 > TEMPTABLE_7_LEN
318
+           || 255 > TEMPTABLE_BED_LEN
319
+           || 255 > TEMPTABLE_CHAMBER_LEN
320
+           || 255 > TEMPTABLE_COOLER_LEN
321
+           || 255 > TEMPTABLE_PROBE_LEN
322
+           || 255 > TEMPTABLE_REDUNDANT_LEN
323
+  , "Temperature conversion tables over 255 entries need special consideration."
332 324
 );
333 325
 
334 326
 // Set the high and low raw values for the heaters
335 327
 // For thermistors the highest temperature results in the lowest ADC value
336 328
 // For thermocouples the highest temperature results in the highest ADC value
337 329
 
338
-#define __TT_REV(N)   REVERSE_TEMP_SENSOR_RANGE_##N
339
-#define _TT_REV(N)    __TT_REV(N)
340
-#define TT_REV(N)     _TT_REV(TEMP_SENSOR_##N##_THERMISTOR_ID)
330
+#define _TT_REV(N)    REVERSE_TEMP_SENSOR_RANGE_##N
331
+#define TT_REV(N)     TERN0(TEMP_SENSOR_##N##_IS_THERMISTOR, DEFER4(_TT_REV)(TEMP_SENSOR_##N))
341 332
 #define _TT_REVRAW(N) !TEMP_SENSOR_##N##_IS_THERMISTOR
342 333
 #define TT_REVRAW(N)  (TT_REV(N) || _TT_REVRAW(N))
343 334
 
@@ -522,6 +513,15 @@ static_assert(
522 513
     #define TEMP_SENSOR_PROBE_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
523 514
   #endif
524 515
 #endif
516
+#ifndef TEMP_SENSOR_REDUNDANT_RAW_HI_TEMP
517
+  #if TT_REVRAW(REDUNDANT)
518
+    #define TEMP_SENSOR_REDUNDANT_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
519
+    #define TEMP_SENSOR_REDUNDANT_RAW_LO_TEMP 0
520
+  #else
521
+    #define TEMP_SENSOR_REDUNDANT_RAW_HI_TEMP 0
522
+    #define TEMP_SENSOR_REDUNDANT_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
523
+  #endif
524
+#endif
525 525
 
526 526
 #undef __TT_REV
527 527
 #undef _TT_REV

+ 1
- 1
buildroot/bin/mftest View File

@@ -37,7 +37,7 @@ env shortcuts: tree due esp lin lpc|lpc8 lpc9 m128 m256|mega stm|f1 f4 f7 s6 tee
37 37
 TESTPATH=buildroot/tests
38 38
 
39 39
 STATE_FILE="./.pio/.mftestrc"
40
-SED=$(which gsed || which sed)
40
+SED=$(which gsed sed | head -n1)
41 41
 
42 42
 shopt -s extglob nocasematch
43 43
 

+ 1
- 1
buildroot/bin/opt_disable View File

@@ -3,7 +3,7 @@
3 3
 # exit on first failure
4 4
 set -e
5 5
 
6
-SED=$(which gsed || which sed)
6
+SED=$(which gsed sed | head -n1)
7 7
 
8 8
 for opt in "$@" ; do
9 9
   DID=0 ; FOUND=0

+ 1
- 1
buildroot/bin/opt_enable View File

@@ -3,7 +3,7 @@
3 3
 # exit on first failure
4 4
 set -e
5 5
 
6
-SED=$(which gsed || which sed)
6
+SED=$(which gsed sed | head -n1)
7 7
 
8 8
 for opt in "$@" ; do
9 9
   DID=0 ; FOUND=0

+ 1
- 1
buildroot/bin/opt_set View File

@@ -3,7 +3,7 @@
3 3
 # exit on first failure
4 4
 set -e
5 5
 
6
-SED=$(which gsed || which sed)
6
+SED=$(which gsed sed | head -n1)
7 7
 
8 8
 while [[ $# > 1 ]]; do
9 9
   DID=0

+ 1
- 1
buildroot/bin/pins_set View File

@@ -6,6 +6,6 @@ NAM=${PINPATH[1]}
6 6
 PIN=$2
7 7
 VAL=$3
8 8
 
9
-SED=$(which gsed || which sed)
9
+SED=$(which gsed sed | head -n1)
10 10
 eval "${SED} -i '/^[[:blank:]]*\(\/\/\)*[[:blank:]]*\(#define \+${PIN}\b\).*$/{s//\2 ${VAL}/;h};\${x;/./{x;q0};x;q9}' Marlin/src/pins/$DIR/pins_${NAM}.h" ||
11 11
 (echo "ERROR: pins_set Can't find ${PIN}" >&2 && exit 9)

+ 1
- 1
buildroot/share/git/mfconfig View File

@@ -149,7 +149,7 @@ if [[ $ACTION == "init" ]]; then
149 149
   ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset TPARA..." >/dev/null
150 150
 
151 151
   # Update the %VERSION% in the README.md file
152
-  SED=$(which gsed || which sed)
152
+  SED=$(which gsed sed | head -n1)
153 153
   VERS=$( echo $EXPORT | $SED 's/release-//' )
154 154
   eval "${SED} -E -i~ -e 's/%VERSION%/$VERS/g' README.md"
155 155
   rm -f README.md~

Loading…
Cancel
Save