@@ -216,18 +216,35 @@ void IRAM_ATTR_YN Segment::setPixelColorXY(int x, int y, uint32_t col) //WLEDMM:
216216 if (Segment::maxHeight==1 ) return ; // not a matrix set-up
217217 if (x<0 || y<0 || x >= virtualWidth () || y >= virtualHeight ()) return ; // if pixel would fall out of virtual segment just exit
218218
219- if (ledsrgb) ledsrgb[XY (x,y)] = col;
220-
219+ unsigned i = UINT_MAX;
220+ bool sameColor = false ;
221+ if (ledsrgb) { // WLEDMM small optimization
222+ i = XY (x,y);
223+ CRGB fastled_col = CRGB (col);
224+ if (ledsrgb[i] == fastled_col) sameColor = true ;
225+ else ledsrgb[i] = fastled_col;
226+ }
221227 uint8_t _bri_t = currentBri (on ? opacity : 0 );
222228 if (!_bri_t && !transitional) return ;
223229 if (_bri_t < 255 ) {
224230 col = color_fade (col, _bri_t );
225231 }
226232
233+ #if 0 // this is a dangerous optimization
234+ if ((i < UINT_MAX) && sameColor && (call > 0) && (ledsrgb[i] == CRGB(col)) && (_globalLeds == nullptr)) return; // WLEDMM looks like nothing to do (but we don't trust globalleds)
235+ #endif
236+
227237 if (reverse ) x = virtualWidth () - x - 1 ;
228238 if (reverse_y) y = virtualHeight () - y - 1 ;
229239 if (transpose) { uint16_t t = x; x = y; y = t; } // swap X & Y if segment transposed
230240
241+ // WLEDMM shortcut when no grouping/spacing used
242+ bool simpleSegment = !mirror && !mirror_y && (grouping == 1 ) && (spacing == 0 );
243+ if (simpleSegment) {
244+ strip.setPixelColorXY (start + x, startY + y, col);
245+ return ;
246+ }
247+
231248 x *= groupLength (); // expand to physical pixels
232249 y *= groupLength (); // expand to physical pixels
233250 if (x >= width () || y >= height ()) return ; // if pixel would fall out of segment just exit
@@ -308,8 +325,10 @@ void Segment::setPixelColorXY(float x, float y, uint32_t col, bool aa, bool fast
308325// returns RGBW values of pixel
309326uint32_t IRAM_ATTR_YN Segment::getPixelColorXY (int x, int y) {
310327 if (x<0 || y<0 || !isActive ()) return 0 ; // not active or out-of range
311- int i = XY (x,y);
312- if (ledsrgb) return RGBW32 (ledsrgb[i].r , ledsrgb[i].g , ledsrgb[i].b , 0 );
328+ if (ledsrgb) {
329+ int i = XY (x,y);
330+ return RGBW32 (ledsrgb[i].r , ledsrgb[i].g , ledsrgb[i].b , 0 );
331+ }
313332 if (reverse ) x = virtualWidth () - x - 1 ;
314333 if (reverse_y) y = virtualHeight () - y - 1 ;
315334 if (transpose) { uint16_t t = x; x = y; y = t; } // swap X & Y if segment transposed
@@ -325,23 +344,11 @@ void Segment::blendPixelColorXY(uint16_t x, uint16_t y, uint32_t color, uint8_t
325344}
326345
327346// Adds the specified color with the existing pixel color perserving color balance.
328- void Segment::addPixelColorXY (int x, int y, uint32_t color, bool fast) {
347+ void IRAM_ATTR_YN Segment::addPixelColorXY (int x, int y, uint32_t color, bool fast) {
329348 if (!isActive ()) return ; // not active
330349 if (x >= virtualWidth () || y >= virtualHeight () || x<0 || y<0 ) return ; // if pixel would fall out of virtual segment just exit
331350 uint32_t col = getPixelColorXY (x,y);
332- uint8_t r = R (col);
333- uint8_t g = G (col);
334- uint8_t b = B (col);
335- uint8_t w = W (col);
336- if (fast) {
337- r = qadd8 (r, R (color));
338- g = qadd8 (g, G (color));
339- b = qadd8 (b, B (color));
340- w = qadd8 (w, W (color));
341- col = RGBW32 (r,g,b,w);
342- } else {
343- col = color_add (col, color);
344- }
351+ col = color_add (col, color, fast);
345352 setPixelColorXY (x, y, col);
346353}
347354
0 commit comments