Преглед изворни кода

Fix Celsius precision, current temp accessors (#21678)

Victor Oliveira пре 3 година
родитељ
комит
46f272b669
No account linked to committer's email address
2 измењених фајлова са 19 додато и 19 уклоњено
  1. 7
    7
      Marlin/src/module/temperature.cpp
  2. 12
    12
      Marlin/src/module/temperature.h

+ 7
- 7
Marlin/src/module/temperature.cpp Прегледај датотеку

@@ -500,7 +500,7 @@ volatile bool Temperature::raw_temps_ready = false;
500 500
    * temperature to succeed.
501 501
    */
502 502
   void Temperature::PID_autotune(const celsius_t target, const heater_id_t heater_id, const int8_t ncycles, const bool set_result/*=false*/) {
503
-    float current_temp = 0.0;
503
+    celsius_float_t current_temp = 0.0;
504 504
     int cycles = 0;
505 505
     bool heating = true;
506 506
 
@@ -1668,7 +1668,7 @@ void Temperature::manage_heater() {
1668 1668
     SERIAL_EOL();
1669 1669
   }
1670 1670
 
1671
-  celsius_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int raw) {
1671
+  celsius_float_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int raw) {
1672 1672
     //#if (MOTHERBOARD == BOARD_RAMPS_14_EFB)
1673 1673
     //  static uint32_t clocks_total = 0;
1674 1674
     //  static uint32_t calls = 0;
@@ -1717,7 +1717,7 @@ void Temperature::manage_heater() {
1717 1717
 #if HAS_HOTEND
1718 1718
   // Derived from RepRap FiveD extruder::getTemperature()
1719 1719
   // For hot end temperature measurement.
1720
-  celsius_t Temperature::analog_to_celsius_hotend(const int raw, const uint8_t e) {
1720
+  celsius_float_t Temperature::analog_to_celsius_hotend(const int raw, const uint8_t e) {
1721 1721
       if (e > HOTENDS - DISABLED(TEMP_SENSOR_1_AS_REDUNDANT)) {
1722 1722
         SERIAL_ERROR_START();
1723 1723
         SERIAL_ECHO(e);
@@ -1826,7 +1826,7 @@ void Temperature::manage_heater() {
1826 1826
 
1827 1827
 #if HAS_HEATED_BED
1828 1828
   // For bed temperature measurement.
1829
-  celsius_t Temperature::analog_to_celsius_bed(const int raw) {
1829
+  celsius_float_t Temperature::analog_to_celsius_bed(const int raw) {
1830 1830
     #if TEMP_SENSOR_BED_IS_CUSTOM
1831 1831
       return user_thermistor_to_deg_c(CTI_BED, raw);
1832 1832
     #elif TEMP_SENSOR_BED_IS_THERMISTOR
@@ -1844,7 +1844,7 @@ void Temperature::manage_heater() {
1844 1844
 
1845 1845
 #if HAS_TEMP_CHAMBER
1846 1846
   // For chamber temperature measurement.
1847
-  celsius_t Temperature::analog_to_celsius_chamber(const int raw) {
1847
+  celsius_float_t Temperature::analog_to_celsius_chamber(const int raw) {
1848 1848
     #if TEMP_SENSOR_CHAMBER_IS_CUSTOM
1849 1849
       return user_thermistor_to_deg_c(CTI_CHAMBER, raw);
1850 1850
     #elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR
@@ -1862,7 +1862,7 @@ void Temperature::manage_heater() {
1862 1862
 
1863 1863
 #if HAS_TEMP_COOLER
1864 1864
   // For cooler temperature measurement.
1865
-  celsius_t Temperature::analog_to_celsius_cooler(const int raw) {
1865
+  celsius_float_t Temperature::analog_to_celsius_cooler(const int raw) {
1866 1866
     #if TEMP_SENSOR_COOLER_IS_CUSTOM
1867 1867
       return user_thermistor_to_deg_c(CTI_COOLER, raw);
1868 1868
     #elif TEMP_SENSOR_COOLER_IS_THERMISTOR
@@ -1880,7 +1880,7 @@ void Temperature::manage_heater() {
1880 1880
 
1881 1881
 #if HAS_TEMP_PROBE
1882 1882
   // For probe temperature measurement.
1883
-  celsius_t Temperature::analog_to_celsius_probe(const int raw) {
1883
+  celsius_float_t Temperature::analog_to_celsius_probe(const int raw) {
1884 1884
     #if TEMP_SENSOR_PROBE_IS_CUSTOM
1885 1885
       return user_thermistor_to_deg_c(CTI_PROBE, raw);
1886 1886
     #elif TEMP_SENSOR_PROBE_IS_THERMISTOR

+ 12
- 12
Marlin/src/module/temperature.h Прегледај датотеку

@@ -179,7 +179,7 @@ enum ADCSensorState : char {
179 179
 typedef struct TempInfo {
180 180
   uint16_t acc;
181 181
   int16_t raw;
182
-  celsius_t celsius;
182
+  celsius_float_t celsius;
183 183
   inline void reset() { acc = 0; }
184 184
   inline void sample(const uint16_t s) { acc += s; }
185 185
   inline void update() { raw = acc; }
@@ -501,7 +501,7 @@ class Temperature {
501 501
       static user_thermistor_t user_thermistor[USER_THERMISTORS];
502 502
       static void log_user_thermistor(const uint8_t t_index, const bool eprom=false);
503 503
       static void reset_user_thermistors();
504
-      static celsius_t user_thermistor_to_deg_c(const uint8_t t_index, const int raw);
504
+      static celsius_float_t user_thermistor_to_deg_c(const uint8_t t_index, const int raw);
505 505
       static inline bool set_pull_up_res(int8_t t_index, float value) {
506 506
         //if (!WITHIN(t_index, 0, USER_THERMISTORS - 1)) return false;
507 507
         if (!WITHIN(value, 1, 1000000)) return false;
@@ -529,19 +529,19 @@ class Temperature {
529 529
     #endif
530 530
 
531 531
     #if HAS_HOTEND
532
-      static celsius_t analog_to_celsius_hotend(const int raw, const uint8_t e);
532
+      static celsius_float_t analog_to_celsius_hotend(const int raw, const uint8_t e);
533 533
     #endif
534 534
     #if HAS_HEATED_BED
535
-      static celsius_t analog_to_celsius_bed(const int raw);
535
+      static celsius_float_t analog_to_celsius_bed(const int raw);
536 536
     #endif
537 537
     #if HAS_TEMP_PROBE
538
-      static celsius_t analog_to_celsius_probe(const int raw);
538
+      static celsius_float_t analog_to_celsius_probe(const int raw);
539 539
     #endif
540 540
     #if HAS_TEMP_CHAMBER
541
-      static celsius_t analog_to_celsius_chamber(const int raw);
541
+      static celsius_float_t analog_to_celsius_chamber(const int raw);
542 542
     #endif
543 543
     #if HAS_TEMP_COOLER
544
-      static celsius_t analog_to_celsius_cooler(const int raw);
544
+      static celsius_float_t analog_to_celsius_cooler(const int raw);
545 545
     #endif
546 546
 
547 547
     #if HAS_FAN
@@ -627,7 +627,7 @@ class Temperature {
627 627
     //inline so that there is no performance decrease.
628 628
     //deg=degreeCelsius
629 629
 
630
-    static inline celsius_t degHotend(const uint8_t E_NAME) {
630
+    static inline celsius_float_t degHotend(const uint8_t E_NAME) {
631 631
       return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].celsius);
632 632
     }
633 633
 
@@ -701,7 +701,7 @@ class Temperature {
701 701
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
702 702
         static inline int16_t rawBedTemp()    { return temp_bed.raw; }
703 703
       #endif
704
-      static inline celsius_t degBed()        { return temp_bed.celsius; }
704
+      static inline celsius_float_t degBed()  { return temp_bed.celsius; }
705 705
       static inline celsius_t wholeDegBed()   { return static_cast<celsius_t>(degBed() + 0.5f); }
706 706
       static inline celsius_t degTargetBed()  { return temp_bed.target; }
707 707
       static inline bool isHeatingBed()       { return temp_bed.target > temp_bed.celsius; }
@@ -737,7 +737,7 @@ class Temperature {
737 737
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
738 738
         static inline int16_t rawProbeTemp()    { return temp_probe.raw; }
739 739
       #endif
740
-      static inline celsius_t degProbe()        { return temp_probe.celsius; }
740
+      static inline celsius_float_t degProbe()  { return temp_probe.celsius; }
741 741
       static inline celsius_t wholeDegProbe()   { return static_cast<celsius_t>(degProbe() + 0.5f); }
742 742
       static inline bool isProbeBelowTemp(const celsius_t target_temp) { return wholeDegProbe() < target_temp; }
743 743
       static inline bool isProbeAboveTemp(const celsius_t target_temp) { return wholeDegProbe() > target_temp; }
@@ -754,7 +754,7 @@ class Temperature {
754 754
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
755 755
         static inline int16_t rawChamberTemp()      { return temp_chamber.raw; }
756 756
       #endif
757
-      static inline celsius_t degChamber()          { return temp_chamber.celsius; }
757
+      static inline celsius_float_t degChamber()    { return temp_chamber.celsius; }
758 758
       static inline celsius_t wholeDegChamber()     { return static_cast<celsius_t>(degChamber() + 0.5f); }
759 759
       #if HAS_HEATED_CHAMBER
760 760
         static inline celsius_t degTargetChamber()  { return temp_chamber.target; }
@@ -781,7 +781,7 @@ class Temperature {
781 781
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
782 782
         static inline int16_t rawCoolerTemp()     { return temp_cooler.raw; }
783 783
       #endif
784
-      static inline celsius_t degCooler()         { return temp_cooler.celsius; }
784
+      static inline celsius_float_t degCooler()   { return temp_cooler.celsius; }
785 785
       static inline celsius_t wholeDegCooler()    { return static_cast<celsius_t>(temp_cooler.celsius + 0.5f); }
786 786
       #if HAS_COOLER
787 787
         static inline celsius_t degTargetCooler() { return temp_cooler.target; }

Loading…
Откажи
Сачувај