Browse Source

Let compiler do Temperature inlining

Scott Lahteine 4 years ago
parent
commit
54ad22a455
1 changed files with 47 additions and 47 deletions
  1. 47
    47
      Marlin/src/module/temperature.h

+ 47
- 47
Marlin/src/module/temperature.h View File

324
       #define HOTEND_TEMPS (HOTENDS + ENABLED(TEMP_SENSOR_1_AS_REDUNDANT))
324
       #define HOTEND_TEMPS (HOTENDS + ENABLED(TEMP_SENSOR_1_AS_REDUNDANT))
325
       static hotend_info_t temp_hotend[HOTEND_TEMPS];
325
       static hotend_info_t temp_hotend[HOTEND_TEMPS];
326
       static const celsius_t hotend_maxtemp[HOTENDS];
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
     #endif
328
     #endif
329
     #if ENABLED(HAS_HEATED_BED)
329
     #if ENABLED(HAS_HEATED_BED)
330
       static bed_info_t temp_bed;
330
       static bed_info_t temp_bed;
357
     #if ENABLED(PREVENT_COLD_EXTRUSION)
357
     #if ENABLED(PREVENT_COLD_EXTRUSION)
358
       static bool allow_cold_extrude;
358
       static bool allow_cold_extrude;
359
       static celsius_t extrude_min_temp;
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
         return tooCold(degHotend(HOTEND_INDEX));
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
         return tooCold(degTargetHotend(HOTEND_INDEX));
365
         return tooCold(degTargetHotend(HOTEND_INDEX));
366
       }
366
       }
367
     #else
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
     #endif
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
     #if ENABLED(SINGLENOZZLE_STANDBY_FAN)
375
     #if ENABLED(SINGLENOZZLE_STANDBY_FAN)
376
       static celsius_t singlenozzle_temp[EXTRUDERS];
376
       static celsius_t singlenozzle_temp[EXTRUDERS];
506
       static void log_user_thermistor(const uint8_t t_index, const bool eprom=false);
506
       static void log_user_thermistor(const uint8_t t_index, const bool eprom=false);
507
       static void reset_user_thermistors();
507
       static void reset_user_thermistors();
508
       static celsius_t user_thermistor_to_deg_c(const uint8_t t_index, const int raw);
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
         //if (!WITHIN(t_index, 0, USER_THERMISTORS - 1)) return false;
510
         //if (!WITHIN(t_index, 0, USER_THERMISTORS - 1)) return false;
511
         if (!WITHIN(value, 1, 1000000)) return false;
511
         if (!WITHIN(value, 1, 1000000)) return false;
512
         user_thermistor[t_index].series_res = value;
512
         user_thermistor[t_index].series_res = value;
513
         return true;
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
         if (!WITHIN(value, 1, 10000000)) return false;
516
         if (!WITHIN(value, 1, 10000000)) return false;
517
         user_thermistor[t_index].res_25 = value;
517
         user_thermistor[t_index].res_25 = value;
518
         user_thermistor[t_index].pre_calc = true;
518
         user_thermistor[t_index].pre_calc = true;
519
         return true;
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
         if (!WITHIN(value, 1, 1000000)) return false;
522
         if (!WITHIN(value, 1, 1000000)) return false;
523
         user_thermistor[t_index].beta = value;
523
         user_thermistor[t_index].beta = value;
524
         user_thermistor[t_index].pre_calc = true;
524
         user_thermistor[t_index].pre_calc = true;
525
         return true;
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
         if (!WITHIN(value, -0.01f, 0.01f)) return false;
528
         if (!WITHIN(value, -0.01f, 0.01f)) return false;
529
         user_thermistor[t_index].sh_c_coeff = value;
529
         user_thermistor[t_index].sh_c_coeff = value;
530
         user_thermistor[t_index].pre_calc = true;
530
         user_thermistor[t_index].pre_calc = true;
614
      * Preheating hotends
614
      * Preheating hotends
615
      */
615
      */
616
     #ifdef MILLISECONDS_PREHEAT_TIME
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
         return preheat_end_time[HOTEND_INDEX] && PENDING(millis(), preheat_end_time[HOTEND_INDEX]);
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
         preheat_end_time[HOTEND_INDEX] = millis() + MILLISECONDS_PREHEAT_TIME;
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
         preheat_end_time[HOTEND_INDEX] = 0;
624
         preheat_end_time[HOTEND_INDEX] = 0;
625
       }
625
       }
626
     #else
626
     #else
631
     //inline so that there is no performance decrease.
631
     //inline so that there is no performance decrease.
632
     //deg=degreeCelsius
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
       return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].celsius);
635
       return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].celsius);
636
     }
636
     }
637
 
637
 
638
     #if ENABLED(SHOW_TEMP_ADC_VALUES)
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
         return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].raw);
640
         return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].raw);
641
       }
641
       }
642
     #endif
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
       return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].target);
645
       return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].target);
646
     }
646
     }
647
 
647
 
666
         start_watching_hotend(ee);
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
         return temp_hotend[HOTEND_INDEX].target > temp_hotend[HOTEND_INDEX].celsius;
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
         return temp_hotend[HOTEND_INDEX].target < temp_hotend[HOTEND_INDEX].celsius;
674
         return temp_hotend[HOTEND_INDEX].target < temp_hotend[HOTEND_INDEX].celsius;
675
       }
675
       }
676
 
676
 
686
         #endif
686
         #endif
687
       #endif
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
         return degTargetHotend(e) > TEMP_HYSTERESIS && ABS(degHotend(e) - degTargetHotend(e)) > TEMP_HYSTERESIS;
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
         return ABS(degHotend(e) - temp) < (TEMP_HYSTERESIS);
694
         return ABS(degHotend(e) - temp) < (TEMP_HYSTERESIS);
695
       }
695
       }
696
 
696
 
699
     #if HAS_HEATED_BED
699
     #if HAS_HEATED_BED
700
 
700
 
701
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
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
       #endif
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
       #if WATCH_BED
709
       #if WATCH_BED
710
         static void start_watching_bed();
710
         static void start_watching_bed();
726
 
726
 
727
       static void wait_for_bed_heating();
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
         return ABS(degBed() - temp) < (TEMP_BED_HYSTERESIS);
730
         return ABS(degBed() - temp) < (TEMP_BED_HYSTERESIS);
731
       }
731
       }
732
 
732
 
734
 
734
 
735
     #if HAS_TEMP_PROBE
735
     #if HAS_TEMP_PROBE
736
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
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
       #endif
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
       static bool wait_for_probe(const_float_t target_temp, bool no_wait_for_cooling=true);
742
       static bool wait_for_probe(const_float_t target_temp, bool no_wait_for_cooling=true);
743
     #endif
743
     #endif
744
 
744
 
750
 
750
 
751
     #if HAS_TEMP_CHAMBER
751
     #if HAS_TEMP_CHAMBER
752
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
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
       #endif
754
       #endif
755
-      FORCE_INLINE static celsius_t degChamber()          { return temp_chamber.celsius; }
755
+      static inline celsius_t degChamber()          { return temp_chamber.celsius; }
756
       #if HAS_HEATED_CHAMBER
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
         static bool wait_for_chamber(const bool no_wait_for_cooling=true);
760
         static bool wait_for_chamber(const bool no_wait_for_cooling=true);
761
       #endif
761
       #endif
762
     #endif
762
     #endif
776
 
776
 
777
     #if HAS_TEMP_COOLER
777
     #if HAS_TEMP_COOLER
778
       #if ENABLED(SHOW_TEMP_ADC_VALUES)
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
       #endif
780
       #endif
781
-      FORCE_INLINE static celsius_t degCooler()         { return temp_cooler.celsius; }
781
+      static inline celsius_t degCooler()         { return temp_cooler.celsius; }
782
       #if HAS_COOLER
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
         static bool wait_for_cooler(const bool no_wait_for_cooling=true);
786
         static bool wait_for_cooler(const bool no_wait_for_cooling=true);
787
       #endif
787
       #endif
788
     #endif
788
     #endif
794
     #endif
794
     #endif
795
 
795
 
796
     #if HAS_COOLER
796
     #if HAS_COOLER
797
-      static void setTargetCooler(const celsius_t celsius) {
797
+      static inline void setTargetCooler(const celsius_t celsius) {
798
         temp_cooler.target = constrain(celsius, COOLER_MIN_TARGET, COOLER_MAX_TARGET);
798
         temp_cooler.target = constrain(celsius, COOLER_MIN_TARGET, COOLER_MAX_TARGET);
799
         start_watching_cooler();
799
         start_watching_cooler();
800
       }
800
       }
839
        * Update the temp manager when PID values change
839
        * Update the temp manager when PID values change
840
        */
840
        */
841
       #if ENABLED(PIDTEMP)
841
       #if ENABLED(PIDTEMP)
842
-        FORCE_INLINE static void updatePID() {
842
+        static inline void updatePID() {
843
           TERN_(PID_EXTRUSION_SCALING, last_e_position = 0);
843
           TERN_(PID_EXTRUSION_SCALING, last_e_position = 0);
844
         }
844
         }
845
       #endif
845
       #endif
848
 
848
 
849
     #if ENABLED(PROBING_HEATERS_OFF)
849
     #if ENABLED(PROBING_HEATERS_OFF)
850
       static void pause(const bool p);
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
     #endif
852
     #endif
853
 
853
 
854
     #if HEATER_IDLE_HANDLER
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
         heater_idle[HOTEND_INDEX].reset();
857
         heater_idle[HOTEND_INDEX].reset();
858
         start_watching_hotend(HOTEND_INDEX);
858
         start_watching_hotend(HOTEND_INDEX);
859
       }
859
       }
860
 
860
 
861
       #if HAS_HEATED_BED
861
       #if HAS_HEATED_BED
862
-        static void reset_bed_idle_timer() {
862
+        static inline void reset_bed_idle_timer() {
863
           heater_idle[IDLE_INDEX_BED].reset();
863
           heater_idle[IDLE_INDEX_BED].reset();
864
           start_watching_bed();
864
           start_watching_bed();
865
         }
865
         }

Loading…
Cancel
Save