Revert to comparing _data for double buffering
- warning: test for potential FPS drop (regression)
This commit is contained in:
parent
3975fe0f02
commit
d0d399bdfc
@ -118,7 +118,7 @@ BusDigital::BusDigital(BusConfig &bc, uint8_t nr, const ColorOrderMap &com)
|
|||||||
_iType = PolyBus::getI(bc.type, _pins, nr);
|
_iType = PolyBus::getI(bc.type, _pins, nr);
|
||||||
if (_iType == I_NONE) return;
|
if (_iType == I_NONE) return;
|
||||||
if (bc.doubleBuffer && !allocData(bc.count * (Bus::hasWhite(_type) + 3*Bus::hasRGB(_type)))) return; //warning: hardcoded channel count
|
if (bc.doubleBuffer && !allocData(bc.count * (Bus::hasWhite(_type) + 3*Bus::hasRGB(_type)))) return; //warning: hardcoded channel count
|
||||||
_buffering = bc.doubleBuffer;
|
//_buffering = bc.doubleBuffer;
|
||||||
uint16_t lenToCreate = bc.count;
|
uint16_t lenToCreate = bc.count;
|
||||||
if (bc.type == TYPE_WS2812_1CH_X3) lenToCreate = NUM_ICS_WS2812_1CH_3X(bc.count); // only needs a third of "RGB" LEDs for NeoPixelBus
|
if (bc.type == TYPE_WS2812_1CH_X3) lenToCreate = NUM_ICS_WS2812_1CH_3X(bc.count); // only needs a third of "RGB" LEDs for NeoPixelBus
|
||||||
_busPtr = PolyBus::create(_iType, _pins, lenToCreate + _skip, nr, _frequencykHz);
|
_busPtr = PolyBus::create(_iType, _pins, lenToCreate + _skip, nr, _frequencykHz);
|
||||||
@ -128,7 +128,7 @@ BusDigital::BusDigital(BusConfig &bc, uint8_t nr, const ColorOrderMap &com)
|
|||||||
|
|
||||||
void BusDigital::show() {
|
void BusDigital::show() {
|
||||||
if (!_valid) return;
|
if (!_valid) return;
|
||||||
if (_buffering) { // should be _data != nullptr, but that causes ~20% FPS drop
|
if (_data) { // use _buffering this causes ~20% FPS drop
|
||||||
size_t channels = Bus::hasWhite(_type) + 3*Bus::hasRGB(_type);
|
size_t channels = Bus::hasWhite(_type) + 3*Bus::hasRGB(_type);
|
||||||
for (size_t i=0; i<_len; i++) {
|
for (size_t i=0; i<_len; i++) {
|
||||||
size_t offset = i*channels;
|
size_t offset = i*channels;
|
||||||
@ -153,7 +153,7 @@ void BusDigital::show() {
|
|||||||
#endif
|
#endif
|
||||||
for (int i=1; i<_skip; i++) PolyBus::setPixelColor(_busPtr, _iType, i, 0, _colorOrderMap.getPixelColorOrder(_start, _colorOrder)); // paint skipped pixels black
|
for (int i=1; i<_skip; i++) PolyBus::setPixelColor(_busPtr, _iType, i, 0, _colorOrderMap.getPixelColorOrder(_start, _colorOrder)); // paint skipped pixels black
|
||||||
}
|
}
|
||||||
PolyBus::show(_busPtr, _iType, !_buffering); // faster if buffer consistency is not important
|
PolyBus::show(_busPtr, _iType, !_data); // faster if buffer consistency is not important (use !_buffering this causes 20% FPS drop)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BusDigital::canShow() {
|
bool BusDigital::canShow() {
|
||||||
@ -173,7 +173,7 @@ void BusDigital::setBrightness(uint8_t b) {
|
|||||||
Bus::setBrightness(b);
|
Bus::setBrightness(b);
|
||||||
PolyBus::setBrightness(_busPtr, _iType, b);
|
PolyBus::setBrightness(_busPtr, _iType, b);
|
||||||
|
|
||||||
if (_buffering) return;
|
if (_data) return; // use _buffering this causes ~20% FPS drop
|
||||||
|
|
||||||
// must update/repaint every LED in the NeoPixelBus buffer to the new brightness
|
// 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
|
// the only case where repainting is unnecessary is when all pixels are set after the brightness change but before the next show
|
||||||
@ -200,7 +200,7 @@ void IRAM_ATTR BusDigital::setPixelColor(uint16_t pix, uint32_t c) {
|
|||||||
if (!_valid) return;
|
if (!_valid) return;
|
||||||
if (Bus::hasWhite(_type)) c = autoWhiteCalc(c);
|
if (Bus::hasWhite(_type)) c = autoWhiteCalc(c);
|
||||||
if (_cct >= 1900) c = colorBalanceFromKelvin(_cct, c); //color correction from CCT
|
if (_cct >= 1900) c = colorBalanceFromKelvin(_cct, c); //color correction from CCT
|
||||||
if (_buffering) { // should be _data != nullptr, but that causes ~20% FPS drop
|
if (_data) { // use _buffering this causes ~20% FPS drop
|
||||||
size_t channels = Bus::hasWhite(_type) + 3*Bus::hasRGB(_type);
|
size_t channels = Bus::hasWhite(_type) + 3*Bus::hasRGB(_type);
|
||||||
size_t offset = pix*channels;
|
size_t offset = pix*channels;
|
||||||
if (Bus::hasRGB(_type)) {
|
if (Bus::hasRGB(_type)) {
|
||||||
@ -228,9 +228,9 @@ void IRAM_ATTR BusDigital::setPixelColor(uint16_t pix, uint32_t c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// returns original color if global buffering is enabled, else returns lossly restored color from bus
|
// returns original color if global buffering is enabled, else returns lossly restored color from bus
|
||||||
uint32_t BusDigital::getPixelColor(uint16_t pix) {
|
uint32_t IRAM_ATTR BusDigital::getPixelColor(uint16_t pix) {
|
||||||
if (!_valid) return 0;
|
if (!_valid) return 0;
|
||||||
if (_buffering) { // should be _data != nullptr, but that causes ~20% FPS drop
|
if (_data) { // use _buffering this causes ~20% FPS drop
|
||||||
size_t channels = Bus::hasWhite(_type) + 3*Bus::hasRGB(_type);
|
size_t channels = Bus::hasWhite(_type) + 3*Bus::hasRGB(_type);
|
||||||
size_t offset = pix*channels;
|
size_t offset = pix*channels;
|
||||||
uint32_t c;
|
uint32_t c;
|
||||||
|
@ -222,7 +222,7 @@ class BusDigital : public Bus {
|
|||||||
uint16_t _frequencykHz;
|
uint16_t _frequencykHz;
|
||||||
void * _busPtr;
|
void * _busPtr;
|
||||||
const ColorOrderMap &_colorOrderMap;
|
const ColorOrderMap &_colorOrderMap;
|
||||||
bool _buffering; // temporary until we figure out why comparison "_data != nullptr" causes severe FPS drop
|
//bool _buffering; // temporary until we figure out why comparison "_data" causes severe FPS drop
|
||||||
|
|
||||||
inline uint32_t restoreColorLossy(uint32_t c, uint8_t restoreBri) {
|
inline uint32_t restoreColorLossy(uint32_t c, uint8_t restoreBri) {
|
||||||
if (restoreBri < 255) {
|
if (restoreBri < 255) {
|
||||||
|
Loading…
Reference in New Issue
Block a user