@@ -153,6 +153,10 @@ BusDigital::BusDigital(const BusConfig &bc, uint8_t nr)
153153 if (bc.type == TYPE_WS2812_1CH_X3) lenToCreate = NUM_ICS_WS2812_1CH_3X (bc.count ); // only needs a third of "RGB" LEDs for NeoPixelBus
154154 _busPtr = PolyBus::create (_iType, _pins, lenToCreate + _skip, nr);
155155 _valid = (_busPtr != nullptr ) && bc.count > 0 ;
156+ // fix for wled#4759
157+ if (_valid) for (unsigned i = 0 ; i < _skip; i++) {
158+ PolyBus::setPixelColor (_busPtr, _iType, i, 0 , COL_ORDER_GRB); // set sacrificial pixels to black (CO does not matter here)
159+ }
156160 DEBUGBUS_PRINTF_P (PSTR (" Bus: %successfully inited #%u (len:%u, type:%u (RGB:%d, W:%d, CCT:%d), pins:%u,%u [itype:%u] mA=%d/%d)\n " ),
157161 _valid?" S" :" Uns" ,
158162 (int )nr,
@@ -230,18 +234,18 @@ void BusDigital::show() {
230234
231235 uint8_t cctWW = 0 , cctCW = 0 ;
232236 unsigned newBri = estimateCurrentAndLimitBri (); // will fill _milliAmpsTotal (TODO: could use PolyBus::CalcTotalMilliAmpere())
233- if (newBri < _bri) PolyBus::setBrightness (_busPtr, _iType, newBri); // limit brightness to stay within current limits
234- if (newBri < _bri) {
235- unsigned hwLen = _len;
236- if (_type == TYPE_WS2812_1CH_X3) hwLen = NUM_ICS_WS2812_1CH_3X (_len); // only needs a third of "RGB" LEDs for NeoPixelBus
237- for (unsigned i = 0 ; i < hwLen; i++) {
238- // use 0 as color order, actual order does not matter here as we just update the channel values as-is
239- uint32_t c = restoreColorLossy (PolyBus::getPixelColor (_busPtr, _iType, i, 0 ), _bri);
240- if (hasCCT ()) Bus::calculateCCT (c, cctWW, cctCW); // this will unfortunately corrupt (segment) CCT data on every bus
241- PolyBus::setPixelColor (_busPtr, _iType, i, c, 0 , (cctCW<<8 ) | cctWW); // repaint all pixels with new brightness
242- }
237+ if (newBri < _bri) {
238+ PolyBus::setBrightness (_busPtr, _iType, newBri); // limit brightness to stay within current limits
239+ unsigned hwLen = _len;
240+ if (_type == TYPE_WS2812_1CH_X3) hwLen = NUM_ICS_WS2812_1CH_3X (_len); // only needs a third of "RGB" LEDs for NeoPixelBus
241+ for (unsigned i = 0 ; i < hwLen; i++) {
242+ // use 0 as color order, actual order does not matter here as we just update the channel values as-is
243+ uint32_t c = restoreColorLossy (PolyBus::getPixelColor (_busPtr, _iType, i, 0 ), _bri);
244+ if (hasCCT ()) Bus::calculateCCT (c, cctWW, cctCW); // this will unfortunately corrupt (segment) CCT data on every bus
245+ PolyBus::setPixelColor (_busPtr, _iType, i, c, 0 , (cctCW<<8 ) | cctWW); // repaint all pixels with new brightness
243246 }
244- PolyBus::show (_busPtr, _iType, false ); // faster if buffer consistency is not important
247+ }
248+ PolyBus::show (_busPtr, _iType, _skip); // faster if buffer consistency is not important (no skipped LEDs)
245249 // restore bus brightness to its original value
246250 // this is done right after show, so this is only OK if LED updates are completed before show() returns
247251 // or async show has a separate buffer (ESP32 RMT and I2S are ok)
@@ -326,7 +330,7 @@ size_t BusDigital::getPins(uint8_t* pinArray) const {
326330}
327331
328332size_t BusDigital::getBusSize () const {
329- return sizeof (BusDigital) + (isOk () ? PolyBus::getDataSize (_busPtr, _iType) /* + (_data ? _len * getNumberOfChannels() : 0) */ : 0 );
333+ return sizeof (BusDigital) + (isOk () ? PolyBus::getDataSize (_busPtr, _iType) : 0 );
330334}
331335
332336void BusDigital::setColorOrder (uint8_t colorOrder) {
0 commit comments