Merge branch 'ledsArrayToSGPC' into integrationMergeOnly

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

File diff suppressed because it is too large Load Diff

View File

@ -610,6 +610,9 @@ class WS2812FX { // 96 bytes
public: public:
// FastLED array, so we can refer to leds[i] instead of getPixel() and setPixel()
CRGB *leds = nullptr ; //See FX_fcn.cpp for init (wip).
WS2812FX() : WS2812FX() :
gammaCorrectBri(false), gammaCorrectBri(false),
gammaCorrectCol(true), gammaCorrectCol(true),
@ -713,7 +716,8 @@ class WS2812FX { // 96 bytes
hasRGBWBus(void), hasRGBWBus(void),
hasCCTBus(void), hasCCTBus(void),
// return true if the strip is being sent pixel updates // return true if the strip is being sent pixel updates
isUpdating(void); isUpdating(void),
useLedsArray = true;
inline bool isServicing(void) { return _isServicing; } inline bool isServicing(void) { return _isServicing; }
inline bool hasWhiteChannel(void) {return _hasWhiteChannel;} inline bool hasWhiteChannel(void) {return _hasWhiteChannel;}

View File

@ -143,9 +143,9 @@ uint16_t IRAM_ATTR Segment::XY(uint16_t x, uint16_t y) {
#ifndef WLED_DISABLE_2D #ifndef WLED_DISABLE_2D
uint16_t width = virtualWidth(); // segment width in logical pixels uint16_t width = virtualWidth(); // segment width in logical pixels
uint16_t height = virtualHeight(); // segment height in logical pixels uint16_t height = virtualHeight(); // segment height in logical pixels
return (x%width) + (y%height) * width; return (start + x%width) + (startY + y%height) * strip.matrixWidth;
#else #else
return x; return start + x;
#endif #endif
} }
@ -176,6 +176,8 @@ void IRAM_ATTR Segment::setPixelColorXY(int x, int y, uint32_t col)
uint16_t xX = (x+g), yY = (y+j); uint16_t xX = (x+g), yY = (y+j);
if (xX >= width() || yY >= height()) continue; // we have reached one dimension's end if (xX >= width() || yY >= height()) continue; // we have reached one dimension's end
if (strip.useLedsArray)
strip.leds[XY(xX, yY)] = col;
strip.setPixelColorXY(start + xX, startY + yY, col); strip.setPixelColorXY(start + xX, startY + yY, col);
if (getOption(SEG_OPTION_MIRROR)) { //set the corresponding horizontally mirrored pixel if (getOption(SEG_OPTION_MIRROR)) { //set the corresponding horizontally mirrored pixel
@ -251,7 +253,11 @@ uint32_t Segment::getPixelColorXY(uint16_t x, uint16_t y) {
x *= groupLength(); // expand to physical pixels x *= groupLength(); // expand to physical pixels
y *= groupLength(); // expand to physical pixels y *= groupLength(); // expand to physical pixels
if (x >= width() || y >= height()) return 0; if (x >= width() || y >= height()) return 0;
return strip.getPixelColorXY(start + x, startY + y); if (strip.useLedsArray) {
CRGB led = strip.leds[XY(x, y)];
return RGBW32(led.r, led.g, led.b, 0);
}
return strip.getPixelColorXY(start + x, startY + y);
#else #else
return 0; return 0;
#endif #endif

View File

@ -475,6 +475,8 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
} }
indexSet += offset; // offset/phase indexSet += offset; // offset/phase
if (indexSet >= stop) indexSet -= len; // wrap if (indexSet >= stop) indexSet -= len; // wrap
if (strip.useLedsArray)
strip.leds[XY(indexSet%virtualWidth(), indexSet/virtualWidth())] = col;
strip.setPixelColor(indexSet, col); strip.setPixelColor(indexSet, col);
} }
} }
@ -538,7 +540,12 @@ uint32_t Segment::getPixelColor(uint16_t i)
/* offset/phase */ /* offset/phase */
i += offset; i += offset;
if (i >= stop) i -= length(); 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) { uint8_t Segment::differs(Segment& b) {
@ -839,6 +846,22 @@ void WS2812FX::service() {
if (nowUp - _lastShow < MIN_SHOW_DELAY) return; if (nowUp - _lastShow < MIN_SHOW_DELAY) return;
bool doShow = false; 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; _isServicing = true;
_segment_index = 0; _segment_index = 0;
for (segment &seg : _segments) { 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 //if (isMatrix) return getPixelColorXY(i%matrixWidth, i/matrixWidth); // compatibility w/ non-effect fn
//#endif //#endif
if (i < customMappingSize) i = customMappingTable[i]; if (i < customMappingSize) i = customMappingTable[i];
return busses.getPixelColor(i); return busses.getPixelColor(i);
} }