浏览代码

Fix Celsius precision, current temp accessors (#21678)

Victor Oliveira 4 年前
父节点
当前提交
46f272b669
没有帐户链接到提交者的电子邮件
共有 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
    * temperature to succeed.
500
    * temperature to succeed.
501
    */
501
    */
502
   void Temperature::PID_autotune(const celsius_t target, const heater_id_t heater_id, const int8_t ncycles, const bool set_result/*=false*/) {
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
     int cycles = 0;
504
     int cycles = 0;
505
     bool heating = true;
505
     bool heating = true;
506
 
506
 
1668
     SERIAL_EOL();
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
     //#if (MOTHERBOARD == BOARD_RAMPS_14_EFB)
1672
     //#if (MOTHERBOARD == BOARD_RAMPS_14_EFB)
1673
     //  static uint32_t clocks_total = 0;
1673
     //  static uint32_t clocks_total = 0;
1674
     //  static uint32_t calls = 0;
1674
     //  static uint32_t calls = 0;
1717
 #if HAS_HOTEND
1717
 #if HAS_HOTEND
1718
   // Derived from RepRap FiveD extruder::getTemperature()
1718
   // Derived from RepRap FiveD extruder::getTemperature()
1719
   // For hot end temperature measurement.
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
       if (e > HOTENDS - DISABLED(TEMP_SENSOR_1_AS_REDUNDANT)) {
1721
       if (e > HOTENDS - DISABLED(TEMP_SENSOR_1_AS_REDUNDANT)) {
1722
         SERIAL_ERROR_START();
1722
         SERIAL_ERROR_START();
1723
         SERIAL_ECHO(e);
1723
         SERIAL_ECHO(e);
1826
 
1826
 
1827
 #if HAS_HEATED_BED
1827
 #if HAS_HEATED_BED
1828
   // For bed temperature measurement.
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
     #if TEMP_SENSOR_BED_IS_CUSTOM
1830
     #if TEMP_SENSOR_BED_IS_CUSTOM
1831
       return user_thermistor_to_deg_c(CTI_BED, raw);
1831
       return user_thermistor_to_deg_c(CTI_BED, raw);
1832
     #elif TEMP_SENSOR_BED_IS_THERMISTOR
1832
     #elif TEMP_SENSOR_BED_IS_THERMISTOR
1844
 
1844
 
1845
 #if HAS_TEMP_CHAMBER
1845
 #if HAS_TEMP_CHAMBER
1846
   // For chamber temperature measurement.
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
     #if TEMP_SENSOR_CHAMBER_IS_CUSTOM
1848
     #if TEMP_SENSOR_CHAMBER_IS_CUSTOM
1849
       return user_thermistor_to_deg_c(CTI_CHAMBER, raw);
1849
       return user_thermistor_to_deg_c(CTI_CHAMBER, raw);
1850
     #elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR
1850
     #elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR
1862
 
1862
 
1863
 #if HAS_TEMP_COOLER
1863
 #if HAS_TEMP_COOLER
1864
   // For cooler temperature measurement.
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
     #if TEMP_SENSOR_COOLER_IS_CUSTOM
1866
     #if TEMP_SENSOR_COOLER_IS_CUSTOM
1867
       return user_thermistor_to_deg_c(CTI_COOLER, raw);
1867
       return user_thermistor_to_deg_c(CTI_COOLER, raw);
1868
     #elif TEMP_SENSOR_COOLER_IS_THERMISTOR
1868
     #elif TEMP_SENSOR_COOLER_IS_THERMISTOR
1880
 
1880
 
1881
 #if HAS_TEMP_PROBE
1881
 #if HAS_TEMP_PROBE
1882
   // For probe temperature measurement.
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
     #if TEMP_SENSOR_PROBE_IS_CUSTOM
1884
     #if TEMP_SENSOR_PROBE_IS_CUSTOM
1885
       return user_thermistor_to_deg_c(CTI_PROBE, raw);
1885
       return user_thermistor_to_deg_c(CTI_PROBE, raw);
1886
     #elif TEMP_SENSOR_PROBE_IS_THERMISTOR
1886
     #elif TEMP_SENSOR_PROBE_IS_THERMISTOR

+ 12
- 12
Marlin/src/module/temperature.h 查看文件

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

正在加载...
取消
保存