浏览代码

Let compiler do Temperature inlining

Scott Lahteine 4 年前
父节点
当前提交
54ad22a455
共有 1 个文件被更改,包括 47 次插入47 次删除
  1. 47
    47
      Marlin/src/module/temperature.h

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

@@ -324,7 +324,7 @@ class Temperature {
324 324
       #define HOTEND_TEMPS (HOTENDS + ENABLED(TEMP_SENSOR_1_AS_REDUNDANT))
325 325
       static hotend_info_t temp_hotend[HOTEND_TEMPS];
326 326
       static const celsius_t hotend_maxtemp[HOTENDS];
327
-      FORCE_INLINE static celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); }
327
+      static inline celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); }
328 328
     #endif
329 329
     #if ENABLED(HAS_HEATED_BED)
330 330
       static bed_info_t temp_bed;
@@ -357,20 +357,20 @@ class Temperature {
357 357
     #if ENABLED(PREVENT_COLD_EXTRUSION)
358 358
       static bool allow_cold_extrude;
359 359
       static celsius_t extrude_min_temp;
360
-      FORCE_INLINE static bool tooCold(const celsius_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp - (TEMP_WINDOW); }
361
-      FORCE_INLINE static bool tooColdToExtrude(const uint8_t E_NAME) {
360
+      static inline bool tooCold(const celsius_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp - (TEMP_WINDOW); }
361
+      static inline bool tooColdToExtrude(const uint8_t E_NAME) {
362 362
         return tooCold(degHotend(HOTEND_INDEX));
363 363
       }
364
-      FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t E_NAME) {
364
+      static inline bool targetTooColdToExtrude(const uint8_t E_NAME) {
365 365
         return tooCold(degTargetHotend(HOTEND_INDEX));
366 366
       }
367 367
     #else
368
-      FORCE_INLINE static bool tooColdToExtrude(const uint8_t) { return false; }
369
-      FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t) { return false; }
368
+      static inline bool tooColdToExtrude(const uint8_t) { return false; }
369
+      static inline bool targetTooColdToExtrude(const uint8_t) { return false; }
370 370
     #endif
371 371
 
372
-    FORCE_INLINE static bool hotEnoughToExtrude(const uint8_t e) { return !tooColdToExtrude(e); }
373
-    FORCE_INLINE static bool targetHotEnoughToExtrude(const uint8_t e) { return !targetTooColdToExtrude(e); }
372
+    static inline bool hotEnoughToExtrude(const uint8_t e) { return !tooColdToExtrude(e); }
373
+    static inline bool targetHotEnoughToExtrude(const uint8_t e) { return !targetTooColdToExtrude(e); }
374 374
 
375 375
     #if ENABLED(SINGLENOZZLE_STANDBY_FAN)
376 376
       static celsius_t singlenozzle_temp[EXTRUDERS];
@@ -506,25 +506,25 @@ class Temperature {
506 506
       static void log_user_thermistor(const uint8_t t_index, const bool eprom=false);
507 507
       static void reset_user_thermistors();
508 508
       static celsius_t user_thermistor_to_deg_c(const uint8_t t_index, const int raw);
509
-      static bool set_pull_up_res(int8_t t_index, float value) {
509
+      static inline bool set_pull_up_res(int8_t t_index, float value) {
510 510
         //if (!WITHIN(t_index, 0, USER_THERMISTORS - 1)) return false;
511 511
         if (!WITHIN(value, 1, 1000000)) return false;
512 512
         user_thermistor[t_index].series_res = value;
513 513
         return true;
514 514
       }
515
-      static bool set_res25(int8_t t_index, float value) {
515
+      static inline bool set_res25(int8_t t_index, float value) {
516 516
         if (!WITHIN(value, 1, 10000000)) return false;
517 517
         user_thermistor[t_index].res_25 = value;
518 518
         user_thermistor[t_index].pre_calc = true;
519 519
         return true;
520 520
       }
521
-      static bool set_beta(int8_t t_index, float value) {
521
+      static inline bool set_beta(int8_t t_index, float value) {
522 522
         if (!WITHIN(value, 1, 1000000)) return false;
523 523
         user_thermistor[t_index].beta = value;
524 524
         user_thermistor[t_index].pre_calc = true;
525 525
         return true;
526 526
       }
527
-      static bool set_sh_coeff(int8_t t_index, float value) {
527
+      static inline bool set_sh_coeff(int8_t t_index, float value) {
528 528
         if (!WITHIN(value, -0.01f, 0.01f)) return false;
529 529
         user_thermistor[t_index].sh_c_coeff = value;
530 530
         user_thermistor[t_index].pre_calc = true;
@@ -614,13 +614,13 @@ class Temperature {
614 614
      * Preheating hotends
615 615
      */
616 616
     #ifdef MILLISECONDS_PREHEAT_TIME
617
-      static bool is_preheating(const uint8_t E_NAME) {
617
+      static inline bool is_preheating(const uint8_t E_NAME) {
618 618
         return preheat_end_time[HOTEND_INDEX] && PENDING(millis(), preheat_end_time[HOTEND_INDEX]);
619 619
       }
620
-      static void start_preheat_time(const uint8_t E_NAME) {
620
+      static inline void start_preheat_time(const uint8_t E_NAME) {
621 621
         preheat_end_time[HOTEND_INDEX] = millis() + MILLISECONDS_PREHEAT_TIME;
622 622
       }
623
-      static void reset_preheat_time(const uint8_t E_NAME) {
623
+      static inline void reset_preheat_time(const uint8_t E_NAME) {
624 624
         preheat_end_time[HOTEND_INDEX] = 0;
625 625
       }
626 626
     #else
@@ -631,17 +631,17 @@ class Temperature {
631 631
     //inline so that there is no performance decrease.
632 632
     //deg=degreeCelsius
633 633
 
634
-    FORCE_INLINE static celsius_t degHotend(const uint8_t E_NAME) {
634
+    static inline celsius_t degHotend(const uint8_t E_NAME) {
635 635
       return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].celsius);
636 636
     }
637 637
 
638 638
     #if ENABLED(SHOW_TEMP_ADC_VALUES)
639
-      FORCE_INLINE static int16_t rawHotendTemp(const uint8_t E_NAME) {
639
+      static inline int16_t rawHotendTemp(const uint8_t E_NAME) {
640 640
         return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].raw);
641 641
       }
642 642
     #endif
643 643
 
644
-    FORCE_INLINE static celsius_t degTargetHotend(const uint8_t E_NAME) {
644
+    static inline celsius_t degTargetHotend(const uint8_t E_NAME) {
645 645
       return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].target);
646 646
     }
647 647
 
@@ -666,11 +666,11 @@ class Temperature {
666 666
         start_watching_hotend(ee);
667 667
       }
668 668
 
669
-      FORCE_INLINE static bool isHeatingHotend(const uint8_t E_NAME) {
669
+      static inline bool isHeatingHotend(const uint8_t E_NAME) {
670 670
         return temp_hotend[HOTEND_INDEX].target > temp_hotend[HOTEND_INDEX].celsius;
671 671
       }
672 672
 
673
-      FORCE_INLINE static bool isCoolingHotend(const uint8_t E_NAME) {
673
+      static inline bool isCoolingHotend(const uint8_t E_NAME) {
674 674
         return temp_hotend[HOTEND_INDEX].target < temp_hotend[HOTEND_INDEX].celsius;
675 675
       }
676 676
 
@@ -686,11 +686,11 @@ class Temperature {
686 686
         #endif
687 687
       #endif
688 688
 
689
-      FORCE_INLINE static bool still_heating(const uint8_t e) {
689
+      static inline bool still_heating(const uint8_t e) {
690 690
         return degTargetHotend(e) > TEMP_HYSTERESIS && ABS(degHotend(e) - degTargetHotend(e)) > TEMP_HYSTERESIS;
691 691
       }
692 692
 
693
-      FORCE_INLINE static bool degHotendNear(const uint8_t e, const_float_t temp) {
693
+      static inline bool degHotendNear(const uint8_t e, const_float_t temp) {
694 694
         return ABS(degHotend(e) - temp) < (TEMP_HYSTERESIS);
695 695
       }
696 696
 
@@ -699,12 +699,12 @@ class Temperature {
699 699
     #if HAS_HEATED_BED
700 700
 
701 701
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
702
-        FORCE_INLINE static int16_t rawBedTemp()    { return temp_bed.raw; }
702
+        static inline int16_t rawBedTemp()    { return temp_bed.raw; }
703 703
       #endif
704
-      FORCE_INLINE static celsius_t degBed()        { return temp_bed.celsius; }
705
-      FORCE_INLINE static celsius_t degTargetBed()  { return temp_bed.target; }
706
-      FORCE_INLINE static bool isHeatingBed()       { return temp_bed.target > temp_bed.celsius; }
707
-      FORCE_INLINE static bool isCoolingBed()       { return temp_bed.target < temp_bed.celsius; }
704
+      static inline celsius_t degBed()        { return temp_bed.celsius; }
705
+      static inline celsius_t degTargetBed()  { return temp_bed.target; }
706
+      static inline bool isHeatingBed()       { return temp_bed.target > temp_bed.celsius; }
707
+      static inline bool isCoolingBed()       { return temp_bed.target < temp_bed.celsius; }
708 708
 
709 709
       #if WATCH_BED
710 710
         static void start_watching_bed();
@@ -726,7 +726,7 @@ class Temperature {
726 726
 
727 727
       static void wait_for_bed_heating();
728 728
 
729
-      FORCE_INLINE static bool degBedNear(const_float_t temp) {
729
+      static inline bool degBedNear(const_float_t temp) {
730 730
         return ABS(degBed() - temp) < (TEMP_BED_HYSTERESIS);
731 731
       }
732 732
 
@@ -734,11 +734,11 @@ class Temperature {
734 734
 
735 735
     #if HAS_TEMP_PROBE
736 736
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
737
-        FORCE_INLINE static int16_t rawProbeTemp()    { return temp_probe.raw; }
737
+        static inline int16_t rawProbeTemp()    { return temp_probe.raw; }
738 738
       #endif
739
-      FORCE_INLINE static celsius_t degProbe()        { return temp_probe.celsius; }
740
-      FORCE_INLINE static bool isProbeBelowTemp(const_float_t target_temp) { return temp_probe.celsius < target_temp; }
741
-      FORCE_INLINE static bool isProbeAboveTemp(const_float_t target_temp) { return temp_probe.celsius > target_temp; }
739
+      static inline celsius_t degProbe()        { return temp_probe.celsius; }
740
+      static inline bool isProbeBelowTemp(const_float_t target_temp) { return temp_probe.celsius < target_temp; }
741
+      static inline bool isProbeAboveTemp(const_float_t target_temp) { return temp_probe.celsius > target_temp; }
742 742
       static bool wait_for_probe(const_float_t target_temp, bool no_wait_for_cooling=true);
743 743
     #endif
744 744
 
@@ -750,13 +750,13 @@ class Temperature {
750 750
 
751 751
     #if HAS_TEMP_CHAMBER
752 752
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
753
-        FORCE_INLINE static int16_t rawChamberTemp()      { return temp_chamber.raw; }
753
+        static inline int16_t rawChamberTemp()      { return temp_chamber.raw; }
754 754
       #endif
755
-      FORCE_INLINE static celsius_t degChamber()          { return temp_chamber.celsius; }
755
+      static inline celsius_t degChamber()          { return temp_chamber.celsius; }
756 756
       #if HAS_HEATED_CHAMBER
757
-        FORCE_INLINE static celsius_t degTargetChamber()  { return temp_chamber.target; }
758
-        FORCE_INLINE static bool isHeatingChamber()       { return temp_chamber.target > temp_chamber.celsius; }
759
-        FORCE_INLINE static bool isCoolingChamber()       { return temp_chamber.target < temp_chamber.celsius; }
757
+        static inline celsius_t degTargetChamber()  { return temp_chamber.target; }
758
+        static inline bool isHeatingChamber()       { return temp_chamber.target > temp_chamber.celsius; }
759
+        static inline bool isCoolingChamber()       { return temp_chamber.target < temp_chamber.celsius; }
760 760
         static bool wait_for_chamber(const bool no_wait_for_cooling=true);
761 761
       #endif
762 762
     #endif
@@ -776,13 +776,13 @@ class Temperature {
776 776
 
777 777
     #if HAS_TEMP_COOLER
778 778
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
779
-        FORCE_INLINE static int16_t rawCoolerTemp()     { return temp_cooler.raw; }
779
+        static inline int16_t rawCoolerTemp()     { return temp_cooler.raw; }
780 780
       #endif
781
-      FORCE_INLINE static celsius_t degCooler()         { return temp_cooler.celsius; }
781
+      static inline celsius_t degCooler()         { return temp_cooler.celsius; }
782 782
       #if HAS_COOLER
783
-        FORCE_INLINE static celsius_t degTargetCooler() { return temp_cooler.target; }
784
-        FORCE_INLINE static bool isLaserHeating()       { return temp_cooler.target > temp_cooler.celsius; }
785
-        FORCE_INLINE static bool isLaserCooling()       { return temp_cooler.target < temp_cooler.celsius; }
783
+        static inline celsius_t degTargetCooler() { return temp_cooler.target; }
784
+        static inline bool isLaserHeating()       { return temp_cooler.target > temp_cooler.celsius; }
785
+        static inline bool isLaserCooling()       { return temp_cooler.target < temp_cooler.celsius; }
786 786
         static bool wait_for_cooler(const bool no_wait_for_cooling=true);
787 787
       #endif
788 788
     #endif
@@ -794,7 +794,7 @@ class Temperature {
794 794
     #endif
795 795
 
796 796
     #if HAS_COOLER
797
-      static void setTargetCooler(const celsius_t celsius) {
797
+      static inline void setTargetCooler(const celsius_t celsius) {
798 798
         temp_cooler.target = constrain(celsius, COOLER_MIN_TARGET, COOLER_MAX_TARGET);
799 799
         start_watching_cooler();
800 800
       }
@@ -839,7 +839,7 @@ class Temperature {
839 839
        * Update the temp manager when PID values change
840 840
        */
841 841
       #if ENABLED(PIDTEMP)
842
-        FORCE_INLINE static void updatePID() {
842
+        static inline void updatePID() {
843 843
           TERN_(PID_EXTRUSION_SCALING, last_e_position = 0);
844 844
         }
845 845
       #endif
@@ -848,18 +848,18 @@ class Temperature {
848 848
 
849 849
     #if ENABLED(PROBING_HEATERS_OFF)
850 850
       static void pause(const bool p);
851
-      FORCE_INLINE static bool is_paused() { return paused; }
851
+      static inline bool is_paused() { return paused; }
852 852
     #endif
853 853
 
854 854
     #if HEATER_IDLE_HANDLER
855 855
 
856
-      static void reset_hotend_idle_timer(const uint8_t E_NAME) {
856
+      static inline void reset_hotend_idle_timer(const uint8_t E_NAME) {
857 857
         heater_idle[HOTEND_INDEX].reset();
858 858
         start_watching_hotend(HOTEND_INDEX);
859 859
       }
860 860
 
861 861
       #if HAS_HEATED_BED
862
-        static void reset_bed_idle_timer() {
862
+        static inline void reset_bed_idle_timer() {
863 863
           heater_idle[IDLE_INDEX_BED].reset();
864 864
           start_watching_bed();
865 865
         }

正在加载...
取消
保存