@@ -1591,7 +1591,11 @@ void WS2812FX::show() {
15911591 size_t diff = showNow - _lastShow;
15921592
15931593 size_t totalLen = getLengthTotal ();
1594- _pixelCCT = static_cast <uint8_t *>(d_malloc (totalLen * sizeof (uint8_t ))); // allocate CCT buffer if necessary
1594+ // WARNING: as WLED doesn't handle CCT on pixel level but on Segment level instead
1595+ // we need to keep track of each pixel's CCT when blending segments (if CCT is present)
1596+ // and then set appropriate CCT from that pixel during paint (see below).
1597+ if ((hasCCTBus () || correctWB) && !cctFromRgb)
1598+ _pixelCCT = static_cast <uint8_t *>(d_malloc (totalLen * sizeof (uint8_t ))); // allocate CCT buffer if necessary
15951599 if (_pixelCCT) memset (_pixelCCT, 127 , totalLen); // set neutral (50:50) CCT
15961600
15971601 if (realtimeMode == REALTIME_MODE_INACTIVE || useMainSegmentOnly || realtimeOverride > REALTIME_OVERRIDE_NONE) {
@@ -1612,16 +1616,14 @@ void WS2812FX::show() {
16121616 if (newBri != _brightness) BusManager::setBrightness (newBri);
16131617
16141618 // paint actuall pixels
1615- // WARNING: as WLED doesn't handle CCT on pixel level but on Segment level instead
1616- // we need to determine to which segment a pixel belongs (may belong to several!!!)
1617- // and then set appropriate CCT from that segment for a particular pixel.
16181619 int oldCCT = Bus::getCCT (); // store original CCT value (since it is global)
1620+ // when cctFromRgb is true we implicitly calculate WW and CW from RGB values (cct==-1)
1621+ if (cctFromRgb) BusManager::setSegmentCCT (-1 );
16191622 for (size_t i = 0 ; i < totalLen; i++) {
1620- // when cctFromRgb is true we implicitly calculate WW and CW from RGB values (cct==-1)
16211623 // when correctWB is true setSegmentCCT() will convert CCT into K with which we can then
16221624 // correct/adjust RGB value according to desired CCT value, it will still affect actual WW/CW ratio
1623- if (_pixelCCT) {
1624- if (i == 0 || _pixelCCT[i-1 ] != _pixelCCT[i]) BusManager::setSegmentCCT (cctFromRgb ? - 1 : _pixelCCT[i], correctWB);
1625+ if (_pixelCCT) { // cctFromRgb already exluded at allocation
1626+ if (i == 0 || _pixelCCT[i-1 ] != _pixelCCT[i]) BusManager::setSegmentCCT (_pixelCCT[i], correctWB);
16251627 }
16261628 BusManager::setPixelColor (getMappedPixelIndex (i), realtimeMode && arlsDisableGammaCorrection ? _pixels[i] : gamma32 (_pixels[i]));
16271629 }
0 commit comments