diff --git a/wled00/FX.h b/wled00/FX.h index 0d7be0bf..fbc84737 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -432,6 +432,7 @@ typedef struct Segment { }; size_t _dataLen; // WLEDMM uint16_t is too small static size_t _usedSegmentData; // WLEDMM uint16_t is too small + void setPixelColorXY_fast(int x, int y,uint32_t c, uint32_t scaled_col, int cols, int rows); // set relative pixel within segment with color - faster, but no error checking!!! // perhaps this should be per segment, not static static CRGBPalette16 _currentPalette; // palette used for current effect (includes transition, used in color_from_palette()) @@ -668,7 +669,6 @@ typedef struct Segment { } //void setPixelColorXY_fast(int x, int y,uint32_t c); // set relative pixel within segment with color - wrapper for _fast - void setPixelColorXY_fast(int x, int y,uint32_t c, uint32_t scaled_col, int cols, int rows); // set relative pixel within segment with color - faster, but no error checking!!! void setPixelColorXY(int x, int y, uint32_t c); // set relative pixel within segment with color inline void setPixelColorXY(unsigned x, unsigned y, uint32_t c) { setPixelColorXY(int(x), int(y), c); } inline void setPixelColorXY(int x, int y, byte r, byte g, byte b, byte w = 0) { setPixelColorXY(x, y, RGBW32(r,g,b,w)); } diff --git a/wled00/FX_2Dfcn.cpp b/wled00/FX_2Dfcn.cpp index f3bd6ce1..95786b8d 100644 --- a/wled00/FX_2Dfcn.cpp +++ b/wled00/FX_2Dfcn.cpp @@ -260,7 +260,7 @@ void IRAM_ATTR Segment::setPixelColorXY_fast(int x, int y, uint32_t col, uint32_ // set the requested pixel strip.setPixelColorXY_fast(start + x, startY + y, scaled_col); bool simpleSegment = !mirror && !mirror_y; - //if (simpleSegment) return; // WLEDMM shortcut when no mirroring needed + if (simpleSegment) return; // WLEDMM shortcut when no mirroring needed // handle mirroring const int_fast16_t wid_ = stop - start; @@ -683,15 +683,6 @@ void Segment::drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint3 const int rows = virtualHeight(); if (x0 >= cols || x1 >= cols || y0 >= rows || y1 >= rows) return; - const int dx = abs(x1-x0), sx = x0 dx; diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 34e59e40..fae5199e 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -920,7 +920,8 @@ void IRAM_ATTR_YN Segment::setPixelColor(int i, uint32_t col) //WLEDMM: IRAM_ATT case M12_pBar: // expand 1D effect vertically or have it play on virtual strips if (vStrip>0) setPixelColorXY(vStrip - 1, vH - i - 1, col); - else for (int x = 0; x < vW; x++) setPixelColorXY(x, vH - i - 1, col); + //else for (int x = 0; x < vW; x++) setPixelColorXY(x, vH - i - 1, col); + else drawLine(0, vH - i - 1, vW-1, vH - i - 1, col, false); // WLEDMM draw line instead of plotting each pixel break; case M12_pArc: // expand in circular fashion from center @@ -1315,15 +1316,29 @@ void Segment::refreshLightCapabilities() { } /* - * Fills segment with color + * Fills segment with color - WLEDMM using faster sPC if possible */ void Segment::fill(uint32_t c) { if (!isActive()) return; // not active const uint_fast16_t cols = is2D() ? virtualWidth() : virtualLength(); // WLEDMM use fast int types const uint_fast16_t rows = virtualHeight(); // will be 1 for 1D - for(uint_fast16_t y = 0; y < rows; y++) for (uint_fast16_t x = 0; x < cols; x++) { - if (is2D()) setPixelColorXY((uint16_t)x, (uint16_t)y, c); - else setPixelColor((uint16_t)x, c); + + if (is2D()) { + // pre-calculate scaled color + uint32_t scaled_col = c; + bool simpleSegment = !reverse && (grouping == 1) && (spacing == 0); // !reverse is just for back-to-back testing against "slow" functions + if (simpleSegment) { + uint8_t _bri_t = currentBri(on ? opacity : 0); + if (!_bri_t && !transitional) return; + if (_bri_t < 255) scaled_col = color_fade(c, _bri_t); + } + // fill 2D segment + for(int y = 0; y < rows; y++) for (int x = 0; x < cols; x++) { + if (simpleSegment) setPixelColorXY_fast(x, y, c, scaled_col, cols, rows); + else setPixelColorXY(x, y, c); + } + } else { // fill 1D strip + for (int x = 0; x < cols; x++) setPixelColor(x, c); } }