Browse Source

SOFT_PWM: Do not switch off heaters twice on pwm_count wraparound

After wraparound, pwm_count <= pwm_mask holds, thus soft_pwm_X <= pwm_count
guarantees soft_pwm_X < pwm_mask is true, and the heater will be switched
off in the first branch.
Do not evaluate the pwm conditions a second time, this reduces the
instruction count (4 instructions per PWM) and text size (6 byte).

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
pull/1/head
Stefan Brüns 7 years ago
committed by Scott Lahteine
parent
commit
6a040a6967
  1. 43
      Marlin/temperature.cpp

43
Marlin/temperature.cpp

@ -1594,33 +1594,34 @@ void Temperature::isr() {
#endif
#endif
}
if (soft_pwm_0 <= pwm_count_tmp) WRITE_HEATER_0(0);
#if HOTENDS > 1
if (soft_pwm_1 <= pwm_count_tmp) WRITE_HEATER_1(0);
else {
if (soft_pwm_0 <= pwm_count_tmp) WRITE_HEATER_0(0);
#if HOTENDS > 1
if (soft_pwm_1 <= pwm_count_tmp) WRITE_HEATER_1(0);
#endif
#if HOTENDS > 2
if (soft_pwm_2 <= pwm_count_tmp) WRITE_HEATER_2(0);
#if HOTENDS > 3
if (soft_pwm_3 <= pwm_count_tmp) WRITE_HEATER_3(0);
#endif
#endif
#endif
#if HAS_HEATER_BED
if (soft_pwm_BED <= pwm_count_tmp) WRITE_HEATER_BED(0);
#endif
#if ENABLED(FAN_SOFT_PWM)
#if HAS_FAN0
if (soft_pwm_fan[0] <= pwm_count_tmp) WRITE_FAN(0);
#if HOTENDS > 3
if (soft_pwm_3 <= pwm_count_tmp) WRITE_HEATER_3(0);
#endif
#if HAS_FAN1
if (soft_pwm_fan[1] <= pwm_count_tmp) WRITE_FAN1(0);
#if HAS_HEATER_BED
if (soft_pwm_BED <= pwm_count_tmp) WRITE_HEATER_BED(0);
#endif
#if HAS_FAN2
if (soft_pwm_fan[2] <= pwm_count_tmp) WRITE_FAN2(0);
#if ENABLED(FAN_SOFT_PWM)
#if HAS_FAN0
if (soft_pwm_fan[0] <= pwm_count_tmp) WRITE_FAN(0);
#endif
#if HAS_FAN1
if (soft_pwm_fan[1] <= pwm_count_tmp) WRITE_FAN1(0);
#endif
#if HAS_FAN2
if (soft_pwm_fan[2] <= pwm_count_tmp) WRITE_FAN2(0);
#endif
#endif
#endif
}
// SOFT_PWM_SCALE to frequency:
//

Loading…
Cancel
Save