Browse Source

Merge pull request #5814 from thinkyhead/hotend_loop_always

Make HOTEND_LOOP more consistent, let compiler optimize it
Scott Lahteine 7 years ago
parent
commit
7176de8605
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

@@ -735,7 +735,7 @@ void Temperature::manage_heater() {
735 735
       }
736 736
     #endif
737 737
 
738
-  } // Hotends Loop
738
+  } // HOTEND_LOOP
739 739
 
740 740
   #if HAS_AUTO_FAN
741 741
     if (ELAPSED(ms, next_auto_fan_check_ms)) { // only need to check fan state very infrequently
@@ -889,9 +889,8 @@ void Temperature::updateTemperaturesFromRawValues() {
889 889
   #if ENABLED(HEATER_0_USES_MAX6675)
890 890
     current_temperature_raw[0] = read_max6675();
891 891
   #endif
892
-  HOTEND_LOOP() {
892
+  HOTEND_LOOP()
893 893
     current_temperature[e] = Temperature::analog2temp(current_temperature_raw[e], e);
894
-  }
895 894
   current_temperature_bed = Temperature::analog2tempBed(current_temperature_bed_raw);
896 895
   #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
897 896
     redundant_temperature = Temperature::analog2temp(redundant_temperature_raw, 1);
@@ -943,15 +942,7 @@ void Temperature::init() {
943 942
   #endif
944 943
 
945 944
   // Finish init of mult hotend arrays
946
-  HOTEND_LOOP() {
947
-    // populate with the first value
948
-    maxttemp[e] = maxttemp[0];
949
-    #if ENABLED(PIDTEMP)
950
-      #if ENABLED(PID_EXTRUSION_SCALING)
951
-        last_e_position = 0;
952
-      #endif
953
-    #endif //PIDTEMP
954
-  }
945
+  HOTEND_LOOP() maxttemp[e] = maxttemp[0];
955 946
 
956 947
   #if ENABLED(PIDTEMP) && ENABLED(PID_EXTRUSION_SCALING)
957 948
     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