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>
The compiler is not able to reuse the value of pwm_count, but reloads it
on every evaluation, if is stored in a static variable, as it cannot prove
it will be unchanged. A variable with local scope may not be modified from
the outside, so its value can be reused.
Doing so reduces text size and instruction count.
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
If dithering is enabled, the remainder of the soft_pwm_X duty value at
turnoff time is added to the next cycle. If e.g. the duty is set to 9 and
SCALE is set to 2, the PWM will be active for 8 counts for 3 cycles and
12 counts on each fourth cycle, i.e. the average is 9 cycles.
This compensates the resolution loss at higher scales and allows running
fans with SOFT_PWM with significantly reduced noise.
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
A 128 step PWM has 127 intervals (0/127 ... 127/127 duty). Currently, a
PWM setting of 1/127 is active for 2/128, i.e. double the expected time,
or, in general n+1/128 instead of n/127.
Fixes issue#6003.
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Made the double touch portion a conditional compile based on the
PROBE_DOUBLE_TOUCH flag.
==============================================
Bugfix
The current G38 only stopped a move if it involved the Z axis.
Moved all the G38 code to it's own section and put it where it would
always be executed no matter what axis was moving or if the endstop was
enabled.
Also added a comment to configuration_adv to alert the user the double
tap had to be turned on.
==============================================
Change G38 back to using Z_MIN_PROBE
There's no Z_MIN endstop if Z_DUAL_ENDSTOPS is enabled and you have them
set to the top of the gantry.
G38 started out as using the Z_MIN_PROBE pin. I don't remember why we
changed it to the Z_MIN endstop.