Browse Source

Make HOTEND_LOOP more consistent, let compiler optimize it

Scott Lahteine 7 years ago
parent
commit
e44294bb4d
4 changed files with 6 additions and 17 deletions
  1. 0
    2
      Marlin/configuration_store.cpp
  2. 3
    12
      Marlin/temperature.cpp
  3. 2
    2
      Marlin/temperature.h
  4. 1
    1
      Marlin/ultralcd.cpp

+ 0
- 2
Marlin/configuration_store.cpp View File

@@ -787,8 +787,6 @@ void Config_ResetDefault() {
787 787
   #if ENABLED(PIDTEMP)
788 788
     #if ENABLED(PID_PARAMS_PER_HOTEND) && HOTENDS > 1
789 789
       HOTEND_LOOP()
790
-    #else
791
-      int e = 0; UNUSED(e); // only need to write once
792 790
     #endif
793 791
     {
794 792
       PID_PARAM(Kp, e) = DEFAULT_Kp;

+ 3
- 12
Marlin/temperature.cpp View File

@@ -731,7 +731,7 @@ void Temperature::manage_heater() {
731 731
       }
732 732
     #endif
733 733
 
734
-  } // Hotends Loop
734
+  } // HOTEND_LOOP
735 735
 
736 736
   #if HAS_AUTO_FAN
737 737
     if (ELAPSED(ms, next_auto_fan_check_ms)) { // only need to check fan state very infrequently
@@ -885,9 +885,8 @@ void Temperature::updateTemperaturesFromRawValues() {
885 885
   #if ENABLED(HEATER_0_USES_MAX6675)
886 886
     current_temperature_raw[0] = read_max6675();
887 887
   #endif
888
-  HOTEND_LOOP() {
888
+  HOTEND_LOOP()
889 889
     current_temperature[e] = Temperature::analog2temp(current_temperature_raw[e], e);
890
-  }
891 890
   current_temperature_bed = Temperature::analog2tempBed(current_temperature_bed_raw);
892 891
   #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
893 892
     redundant_temperature = Temperature::analog2temp(redundant_temperature_raw, 1);
@@ -939,15 +938,7 @@ void Temperature::init() {
939 938
   #endif
940 939
 
941 940
   // Finish init of mult hotend arrays
942
-  HOTEND_LOOP() {
943
-    // populate with the first value
944
-    maxttemp[e] = maxttemp[0];
945
-    #if ENABLED(PIDTEMP)
946
-      #if ENABLED(PID_EXTRUSION_SCALING)
947
-        last_e_position = 0;
948
-      #endif
949
-    #endif //PIDTEMP
950
-  }
941
+  HOTEND_LOOP() maxttemp[e] = maxttemp[0];
951 942
 
952 943
   #if ENABLED(PIDTEMP) && ENABLED(PID_EXTRUSION_SCALING)
953 944
     last_e_position = 0;

+ 2
- 2
Marlin/temperature.h View File

@@ -40,12 +40,12 @@
40 40
   #define SOFT_PWM_SCALE 0
41 41
 #endif
42 42
 
43
+#define HOTEND_LOOP() for (int8_t e = 0; e < HOTENDS; e++)
44
+
43 45
 #if HOTENDS == 1
44
-  #define HOTEND_LOOP() const int8_t e = 0;
45 46
   #define HOTEND_INDEX  0
46 47
   #define EXTRUDER_IDX  0
47 48
 #else
48
-  #define HOTEND_LOOP() for (int8_t e = 0; e < HOTENDS; e++)
49 49
   #define HOTEND_INDEX  e
50 50
   #define EXTRUDER_IDX  active_extruder
51 51
 #endif

+ 1
- 1
Marlin/ultralcd.cpp View File

@@ -1403,7 +1403,7 @@ KeepDrawing:
1403 1403
     // Cooldown
1404 1404
     //
1405 1405
     bool has_heat = false;
1406
-    HOTEND_LOOP() if (thermalManager.target_temperature[HOTEND_INDEX]) { has_heat = true; }
1406
+    HOTEND_LOOP() if (thermalManager.target_temperature[HOTEND_INDEX]) { has_heat = true; break; }
1407 1407
     #if HAS_TEMP_BED
1408 1408
       if (thermalManager.target_temperature_bed) has_heat = true;
1409 1409
     #endif

Loading…
Cancel
Save