Merge branch 'ledsArrayToSGPC' into integrationMergeOnly

This commit is contained in:
ewowi
2022-08-01 16:25:51 +02:00
4 changed files with 214 additions and 262 deletions

View File

@@ -475,6 +475,8 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
}
indexSet += offset; // offset/phase
if (indexSet >= stop) indexSet -= len; // wrap
if (strip.useLedsArray)
strip.leds[XY(indexSet%virtualWidth(), indexSet/virtualWidth())] = col;
strip.setPixelColor(indexSet, col);
}
}
@@ -538,7 +540,12 @@ uint32_t Segment::getPixelColor(uint16_t i)
/* offset/phase */
i += offset;
if (i >= stop) i -= length();
return strip.getPixelColor(i);
if (strip.useLedsArray) {
CRGB led = strip.leds[XY(i%virtualWidth(), i/virtualWidth())];
return RGBW32(led.r, led.g, led.b, 0);
}
else
return strip.getPixelColor(i);
}
uint8_t Segment::differs(Segment& b) {
@@ -839,6 +846,22 @@ void WS2812FX::service() {
if (nowUp - _lastShow < MIN_SHOW_DELAY) return;
bool doShow = false;
//initialize leds array. Move to better place then service??? TBD: realloc if nr of leds change
// if (useLedsArray) {
// if (leds != nullptr && sizeof(leds) / sizeof(uint32_t) != _length) {
// free(leds);
// leds = nullptr;
// }
if (leds == nullptr) {
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM)
if (psramFound())
leds = (CRGB*) ps_malloc(sizeof(CRGB) * _length);
else
#endif
leds = (CRGB*) malloc(sizeof(CRGB) * _length);
}
// }
_isServicing = true;
_segment_index = 0;
for (segment &seg : _segments) {
@@ -984,7 +1007,7 @@ uint32_t WS2812FX::getPixelColor(uint16_t i)
//if (isMatrix) return getPixelColorXY(i%matrixWidth, i/matrixWidth); // compatibility w/ non-effect fn
//#endif
if (i < customMappingSize) i = customMappingTable[i];
return busses.getPixelColor(i);
return busses.getPixelColor(i);
}