Browse Source

Fans loop macro

pull/1/head
Scott Lahteine 6 years ago
parent
commit
95d154a91f
  1. 3
      Marlin/src/Marlin.h
  2. 2
      Marlin/src/feature/power.cpp
  3. 2
      Marlin/src/feature/power_loss_recovery.cpp
  4. 6
      Marlin/src/module/planner.cpp

3
Marlin/src/Marlin.h

@ -210,11 +210,12 @@ extern millis_t max_inactive_time, stepper_inactive_time;
extern bool fans_paused; extern bool fans_paused;
extern uint8_t paused_fan_speed[FAN_COUNT]; extern uint8_t paused_fan_speed[FAN_COUNT];
#endif #endif
#define FANS_LOOP(I) LOOP_L_N(I, FAN_COUNT)
#endif #endif
inline void zero_fan_speeds() { inline void zero_fan_speeds() {
#if FAN_COUNT > 0 #if FAN_COUNT > 0
LOOP_L_N(i, FAN_COUNT) fan_speed[i] = 0; FANS_LOOP(i) fan_speed[i] = 0;
#endif #endif
} }

2
Marlin/src/feature/power.cpp

@ -39,7 +39,7 @@ millis_t Power::lastPowerOn;
bool Power::is_power_needed() { bool Power::is_power_needed() {
#if ENABLED(AUTO_POWER_FANS) #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 #endif
#if ENABLED(AUTO_POWER_E_FANS) #if ENABLED(AUTO_POWER_E_FANS)

2
Marlin/src/feature/power_loss_recovery.cpp

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

6
Marlin/src/module/planner.cpp

@ -1181,7 +1181,7 @@ void Planner::check_axes_activity() {
if (has_blocks_queued()) { if (has_blocks_queued()) {
#if FAN_COUNT > 0 #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]; tail_fan_speed[i] = block_buffer[block_buffer_tail].fan_speed[i];
#endif #endif
@ -1204,7 +1204,7 @@ void Planner::check_axes_activity() {
} }
else { else {
#if FAN_COUNT > 0 #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 #endif
#if ENABLED(BARICUDA) #if ENABLED(BARICUDA)
@ -1751,7 +1751,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
#endif #endif
#if FAN_COUNT > 0 #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 #endif
#if ENABLED(BARICUDA) #if ENABLED(BARICUDA)

Loading…
Cancel
Save