Skip to content

Commit cb8dae1

Browse files
committed
PWM: Revert always apply dead time
1 parent 59deebc commit cb8dae1

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

wled00/bus_manager.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -573,11 +573,6 @@ void BusPwm::show() {
573573
const unsigned maxBri = (1<<_depth); // possible values: 16384 (14), 8192 (13), 4096 (12), 2048 (11), 1024 (10), 512 (9) and 256 (8)
574574
const unsigned bitShift = dithering * 4; // if dithering, _depth is 12 bit but LEDC channel is set to 8 bit (using 4 fractional bits)
575575
#endif
576-
// add dead time between signals (when using dithering, two full 8bit pulses are required)
577-
// this is needed for 2CH, but also adds some slack for ESP8266 which has less precise
578-
// PWM timing.
579-
const int deadTime = (1+dithering) << bitShift;
580-
581576
// use CIE brightness formula (cubic) to fit (or approximate linearity of) human eye perceived brightness
582577
// the formula is based on 12 bit resolution as there is no need for greater precision
583578
// see: https://en.wikipedia.org/wiki/Lightness
@@ -601,9 +596,12 @@ void BusPwm::show() {
601596
// Phase shifting requires that LEDC timers are synchronised (see setup()). For PWM CCT (and H-bridge) it is
602597
// also mandatory that both channels use the same timer (pinManager takes care of that).
603598
for (unsigned i = 0; i < numPins; i++) {
604-
unsigned duty = (_data[i] * pwmBri) / 255;
599+
unsigned duty = (_data[i] * pwmBri) / 255;
600+
unsigned deadTime = 0;
605601

606602
if (_type == TYPE_ANALOG_2CH && Bus::getCCTBlend() == 0) {
603+
// add dead time between signals (when using dithering, two full 8bit pulses are required)
604+
deadTime = (1+dithering) << bitShift;
607605
// we only need to take care of shortening the signal at (almost) full brightness otherwise pulses may overlap
608606
if (_bri >= 254 && duty >= maxBri / 2 && duty < maxBri) {
609607
duty -= deadTime << 1; // shorten duty of larger signal except if full on

0 commit comments

Comments
 (0)