Skip to content

Commit

Permalink
Fix for power limiter performance loss Aircoookie#3978
Browse files Browse the repository at this point in the history
  • Loading branch information
jw2013 committed May 15, 2024
1 parent f2a25e8 commit 8aa5c95
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
13 changes: 7 additions & 6 deletions wled00/FX_fcn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1337,18 +1337,19 @@ void WS2812FX::show(void) {
if (callback) callback();

uint8_t newBri = estimateCurrentAndLimitBri();
busses.setBrightness(newBri); // "repaints" all pixels if brightness changed
if (newBri < _brightness) {
busses.setBrightness(newBri); // "repaints" all pixels if brightness changed
}
else {
// restore bus brightness to its original value
busses.setBrightness(_brightness);
}

// some buses send asynchronously and this method will return before
// all of the data has been sent.
// See https://github.com/Makuna/NeoPixelBus/wiki/ESP32-NeoMethods#neoesp32rmt-methods
busses.show();

// restore bus brightness to its original value
// this is done right after show, so this is only OK if LED updates are completed before show() returns
// or async show has a separate buffer (ESP32 RMT and I2S are ok)
if (newBri < _brightness) busses.setBrightness(_brightness);

unsigned long showNow = millis();
size_t diff = showNow - _lastShow;
size_t fpsCurr = 200;
Expand Down
1 change: 1 addition & 0 deletions wled00/bus_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ void BusDigital::setBrightness(uint8_t b) {
PolyBus::setBrightness(_busPtr, _iType, b);

if (_buffering) return;
if (prevBri < b) return; // only repaint immediately if brightness decreases

// must update/repaint every LED in the NeoPixelBus buffer to the new brightness
// the only case where repainting is unnecessary is when all pixels are set after the brightness change but before the next show
Expand Down

0 comments on commit 8aa5c95

Please sign in to comment.