Browse Source

Fans loop macro

Scott Lahteine 5 years ago
parent
commit
95d154a91f

+ 2
- 1
Marlin/src/Marlin.h View File

@@ -210,11 +210,12 @@ extern millis_t max_inactive_time, stepper_inactive_time;
210 210
     extern bool fans_paused;
211 211
     extern uint8_t paused_fan_speed[FAN_COUNT];
212 212
   #endif
213
+  #define FANS_LOOP(I) LOOP_L_N(I, FAN_COUNT)
213 214
 #endif
214 215
 
215 216
 inline void zero_fan_speeds() {
216 217
   #if FAN_COUNT > 0
217
-    LOOP_L_N(i, FAN_COUNT) fan_speed[i] = 0;
218
+    FANS_LOOP(i) fan_speed[i] = 0;
218 219
   #endif
219 220
 }
220 221
 

+ 1
- 1
Marlin/src/feature/power.cpp View File

@@ -39,7 +39,7 @@ millis_t Power::lastPowerOn;
39 39
 
40 40
 bool Power::is_power_needed() {
41 41
   #if ENABLED(AUTO_POWER_FANS)
42
-    for (uint8_t i = 0; i < FAN_COUNT; i++) if (fan_speed[i]) return true;
42
+    FANS_LOOP(i) if (fan_speed[i]) return true;
43 43
   #endif
44 44
 
45 45
   #if ENABLED(AUTO_POWER_E_FANS)

+ 1
- 1
Marlin/src/feature/power_loss_recovery.cpp View File

@@ -277,7 +277,7 @@ void PrintJobRecovery::resume() {
277 277
   }
278 278
 
279 279
   // Restore print cooling fan speeds
280
-  for (uint8_t i = 0; i < FAN_COUNT; i++) {
280
+  FANS_LOOP(i) {
281 281
     uint8_t f = info.fan_speed[i];
282 282
     if (f) {
283 283
       sprintf_P(cmd, PSTR("M106 P%i S%i"), i, f);

+ 3
- 3
Marlin/src/module/planner.cpp View File

@@ -1181,7 +1181,7 @@ void Planner::check_axes_activity() {
1181 1181
   if (has_blocks_queued()) {
1182 1182
 
1183 1183
     #if FAN_COUNT > 0
1184
-      for (uint8_t i = 0; i < FAN_COUNT; i++)
1184
+      FANS_LOOP(i)
1185 1185
         tail_fan_speed[i] = block_buffer[block_buffer_tail].fan_speed[i];
1186 1186
     #endif
1187 1187
 
@@ -1204,7 +1204,7 @@ void Planner::check_axes_activity() {
1204 1204
   }
1205 1205
   else {
1206 1206
     #if FAN_COUNT > 0
1207
-      for (uint8_t i = 0; i < FAN_COUNT; i++) tail_fan_speed[i] = fan_speed[i];
1207
+      FANS_LOOP(i) tail_fan_speed[i] = fan_speed[i];
1208 1208
     #endif
1209 1209
 
1210 1210
     #if ENABLED(BARICUDA)
@@ -1751,7 +1751,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
1751 1751
   #endif
1752 1752
 
1753 1753
   #if FAN_COUNT > 0
1754
-    for (uint8_t i = 0; i < FAN_COUNT; i++) block->fan_speed[i] = fan_speed[i];
1754
+    FANS_LOOP(i) block->fan_speed[i] = fan_speed[i];
1755 1755
   #endif
1756 1756
 
1757 1757
   #if ENABLED(BARICUDA)

Loading…
Cancel
Save