diff --git a/Marlin/src/Marlin.h b/Marlin/src/Marlin.h index 1025d677c9..bafb1f8d48 100644 --- a/Marlin/src/Marlin.h +++ b/Marlin/src/Marlin.h @@ -210,11 +210,12 @@ extern millis_t max_inactive_time, stepper_inactive_time; extern bool fans_paused; extern uint8_t paused_fan_speed[FAN_COUNT]; #endif + #define FANS_LOOP(I) LOOP_L_N(I, FAN_COUNT) #endif inline void zero_fan_speeds() { #if FAN_COUNT > 0 - LOOP_L_N(i, FAN_COUNT) fan_speed[i] = 0; + FANS_LOOP(i) fan_speed[i] = 0; #endif } diff --git a/Marlin/src/feature/power.cpp b/Marlin/src/feature/power.cpp index 24f02041b2..892166ba1a 100644 --- a/Marlin/src/feature/power.cpp +++ b/Marlin/src/feature/power.cpp @@ -39,7 +39,7 @@ millis_t Power::lastPowerOn; bool Power::is_power_needed() { #if ENABLED(AUTO_POWER_FANS) - for (uint8_t i = 0; i < FAN_COUNT; i++) if (fan_speed[i]) return true; + FANS_LOOP(i) if (fan_speed[i]) return true; #endif #if ENABLED(AUTO_POWER_E_FANS) diff --git a/Marlin/src/feature/power_loss_recovery.cpp b/Marlin/src/feature/power_loss_recovery.cpp index d81911c39f..9302837af7 100644 --- a/Marlin/src/feature/power_loss_recovery.cpp +++ b/Marlin/src/feature/power_loss_recovery.cpp @@ -277,7 +277,7 @@ void PrintJobRecovery::resume() { } // Restore print cooling fan speeds - for (uint8_t i = 0; i < FAN_COUNT; i++) { + FANS_LOOP(i) { uint8_t f = info.fan_speed[i]; if (f) { sprintf_P(cmd, PSTR("M106 P%i S%i"), i, f); diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index c185678ad0..01eac0249d 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1181,7 +1181,7 @@ void Planner::check_axes_activity() { if (has_blocks_queued()) { #if FAN_COUNT > 0 - for (uint8_t i = 0; i < FAN_COUNT; i++) + FANS_LOOP(i) tail_fan_speed[i] = block_buffer[block_buffer_tail].fan_speed[i]; #endif @@ -1204,7 +1204,7 @@ void Planner::check_axes_activity() { } else { #if FAN_COUNT > 0 - for (uint8_t i = 0; i < FAN_COUNT; i++) tail_fan_speed[i] = fan_speed[i]; + FANS_LOOP(i) tail_fan_speed[i] = fan_speed[i]; #endif #if ENABLED(BARICUDA) @@ -1751,7 +1751,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif #if FAN_COUNT > 0 - for (uint8_t i = 0; i < FAN_COUNT; i++) block->fan_speed[i] = fan_speed[i]; + FANS_LOOP(i) block->fan_speed[i] = fan_speed[i]; #endif #if ENABLED(BARICUDA)