Compile optimisations, code reduction.

2D peek resize.
This commit is contained in:
Blaž Kristan 2022-08-03 14:23:24 +02:00
parent f58ff68f3c
commit c5f3e76b21
7 changed files with 237 additions and 282 deletions

View File

@ -550,10 +550,10 @@ typedef struct Segment {
uint16_t virtualLength(void); uint16_t virtualLength(void);
void setPixelColor(int n, uint32_t c); // set relative pixel within segment with color void setPixelColor(int n, uint32_t c); // set relative pixel within segment with color
void setPixelColor(int n, byte r, byte g, byte b, byte w = 0) { setPixelColor(n, RGBW32(r,g,b,w)); } // automatically inline void setPixelColor(int n, byte r, byte g, byte b, byte w = 0) { setPixelColor(n, RGBW32(r,g,b,w)); } // automatically inline
void setPixelColor(int n, CRGB c) { setPixelColor(n, c.red, c.green, c.blue); } // automatically inline void setPixelColor(int n, CRGB c) { setPixelColor(n, RGBW32(c.r,c.g,c.b,0)); } // automatically inline
void setPixelColor(float i, uint32_t c, bool aa = true); void setPixelColor(float i, uint32_t c, bool aa = true);
void setPixelColor(float i, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0, bool aa = true) { setPixelColor(i, RGBW32(r,g,b,w), aa); } void setPixelColor(float i, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0, bool aa = true) { setPixelColor(i, RGBW32(r,g,b,w), aa); }
void setPixelColor(float i, CRGB c, bool aa = true) { setPixelColor(i, c.red, c.green, c.blue, 0, aa); } void setPixelColor(float i, CRGB c, bool aa = true) { setPixelColor(i, RGBW32(c.r,c.g,c.b,0), aa); }
uint32_t getPixelColor(uint16_t i); uint32_t getPixelColor(uint16_t i);
// 1D support functions (some implement 2D as well) // 1D support functions (some implement 2D as well)
void blur(uint8_t); void blur(uint8_t);
@ -561,10 +561,10 @@ typedef struct Segment {
void fade_out(uint8_t r); void fade_out(uint8_t r);
void fadeToBlackBy(uint8_t fadeBy); void fadeToBlackBy(uint8_t fadeBy);
void blendPixelColor(int n, uint32_t color, uint8_t blend); void blendPixelColor(int n, uint32_t color, uint8_t blend);
void blendPixelColor(int n, CRGB c, uint8_t blend) { blendPixelColor(n, RGBW32(c.red, c.green, c.blue, 0), blend); } void blendPixelColor(int n, CRGB c, uint8_t blend) { blendPixelColor(n, RGBW32(c.r,c.g,c.b,0), blend); }
void addPixelColor(int n, uint32_t color); void addPixelColor(int n, uint32_t color);
void addPixelColor(int n, byte r, byte g, byte b, byte w = 0) { addPixelColor(n, RGBW32(r,g,b,w)); } // automatically inline void addPixelColor(int n, byte r, byte g, byte b, byte w = 0) { addPixelColor(n, RGBW32(r,g,b,w)); } // automatically inline
void addPixelColor(int n, CRGB c) { addPixelColor(n, RGBW32(c.red, c.green, c.blue, 0)); } // automatically inline void addPixelColor(int n, CRGB c) { addPixelColor(n, RGBW32(c.r,c.g,c.b,0)); } // automatically inline
void fadePixelColor(uint16_t n, uint8_t fade); void fadePixelColor(uint16_t n, uint8_t fade);
uint8_t get_random_wheel_index(uint8_t pos); uint8_t get_random_wheel_index(uint8_t pos);
uint32_t color_from_palette(uint16_t, bool mapping, bool wrap, uint8_t mcol, uint8_t pbri = 255); uint32_t color_from_palette(uint16_t, bool mapping, bool wrap, uint8_t mcol, uint8_t pbri = 255);
@ -573,39 +573,69 @@ typedef struct Segment {
// 2D matrix // 2D matrix
uint16_t virtualWidth(void); uint16_t virtualWidth(void);
uint16_t virtualHeight(void); uint16_t virtualHeight(void);
#ifndef WLED_DISABLE_2D
uint16_t XY(uint16_t x, uint16_t y); // support function to get relative index within segment (for leds[]) uint16_t XY(uint16_t x, uint16_t y); // support function to get relative index within segment (for leds[])
void setPixelColorXY(int x, int y, uint32_t c); // set relative pixel within segment with color void setPixelColorXY(int x, int y, uint32_t c); // set relative pixel within segment with color
void setPixelColorXY(int x, int y, byte r, byte g, byte b, byte w = 0) { setPixelColorXY(x, y, RGBW32(r,g,b,w)); } // automatically inline void setPixelColorXY(int x, int y, byte r, byte g, byte b, byte w = 0) { setPixelColorXY(x, y, RGBW32(r,g,b,w)); } // automatically inline
void setPixelColorXY(int x, int y, CRGB c) { setPixelColorXY(x, y, RGBW32(c.red, c.green, c.blue, 0)); } // automatically inline void setPixelColorXY(int x, int y, CRGB c) { setPixelColorXY(x, y, RGBW32(c.r,c.g,c.b,0)); } // automatically inline
void setPixelColorXY(float x, float y, uint32_t c, bool aa = true); void setPixelColorXY(float x, float y, uint32_t c, bool aa = true);
void setPixelColorXY(float x, float y, byte r, byte g, byte b, byte w = 0, bool aa = true) { setPixelColorXY(x, y, RGBW32(r,g,b,w), aa); } void setPixelColorXY(float x, float y, byte r, byte g, byte b, byte w = 0, bool aa = true) { setPixelColorXY(x, y, RGBW32(r,g,b,w), aa); }
void setPixelColorXY(float x, float y, CRGB c, bool aa = true) { setPixelColorXY(x, y, c.red, c.green, c.blue, 0, aa); } void setPixelColorXY(float x, float y, CRGB c, bool aa = true) { setPixelColorXY(x, y, RGBW32(c.r,c.g,c.b,0), aa); }
uint32_t getPixelColorXY(uint16_t x, uint16_t y); uint32_t getPixelColorXY(uint16_t x, uint16_t y);
// 2D support functions // 2D support functions
void blendPixelColorXY(uint16_t x, uint16_t y, uint32_t color, uint8_t blend); void blendPixelColorXY(uint16_t x, uint16_t y, uint32_t color, uint8_t blend);
void blendPixelColorXY(uint16_t x, uint16_t y, CRGB c, uint8_t blend) { blendPixelColorXY(x, y, RGBW32(c.red, c.green, c.blue,0), blend); } void blendPixelColorXY(uint16_t x, uint16_t y, CRGB c, uint8_t blend) { blendPixelColorXY(x, y, RGBW32(c.r,c.g,c.b,0), blend); }
void addPixelColorXY(int x, int y, uint32_t color); void addPixelColorXY(int x, int y, uint32_t color);
void addPixelColorXY(int x, int y, byte r, byte g, byte b, byte w = 0) { addPixelColorXY(x, y, RGBW32(r,g,b,w)); } // automatically inline void addPixelColorXY(int x, int y, byte r, byte g, byte b, byte w = 0) { addPixelColorXY(x, y, RGBW32(r,g,b,w)); } // automatically inline
void addPixelColorXY(int x, int y, CRGB c) { addPixelColorXY(x, y, RGBW32(c.red, c.green, c.blue,0)); } void addPixelColorXY(int x, int y, CRGB c) { addPixelColorXY(x, y, RGBW32(c.r,c.g,c.b,0)); }
void fadePixelColorXY(uint16_t x, uint16_t y, uint8_t fade); void fadePixelColorXY(uint16_t x, uint16_t y, uint8_t fade);
void box_blur(uint16_t i, bool vertical, fract8 blur_amount); // 1D box blur (with weight) void box_blur(uint16_t i, bool vertical, fract8 blur_amount); // 1D box blur (with weight)
void blur1d(CRGB* leds, fract8 blur_amount);
void blur2d(CRGB* leds, fract8 blur_amount);
void blurRow(uint16_t row, fract8 blur_amount, CRGB* leds=nullptr); void blurRow(uint16_t row, fract8 blur_amount, CRGB* leds=nullptr);
void blurCol(uint16_t col, fract8 blur_amount, CRGB* leds=nullptr); void blurCol(uint16_t col, fract8 blur_amount, CRGB* leds=nullptr);
void moveX(int8_t delta); void moveX(int8_t delta);
void moveY(int8_t delta); void moveY(int8_t delta);
void move(uint8_t dir, uint8_t delta); void move(uint8_t dir, uint8_t delta);
void fill_solid(CRGB* leds, CRGB c);
void fill_circle(uint16_t cx, uint16_t cy, uint8_t radius, CRGB c); void fill_circle(uint16_t cx, uint16_t cy, uint8_t radius, CRGB c);
void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint32_t c);
void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, CRGB c) { drawLine(x0, y0, x1, y1, RGBW32(c.r,c.g,c.b,0)); } // automatic inline
void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, uint32_t color);
void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB c) { drawCharacter(chr, x, y, w, h, RGBW32(c.r,c.g,c.b,0)); } // automatic inline
void wu_pixel(uint32_t x, uint32_t y, CRGB c);
// obsolete
void blur1d(CRGB* leds, fract8 blur_amount);
void blur2d(CRGB* leds, fract8 blur_amount);
void fill_solid(CRGB* leds, CRGB c);
void fadeToBlackBy(CRGB* leds, uint8_t fadeBy); void fadeToBlackBy(CRGB* leds, uint8_t fadeBy);
void nscale8(CRGB* leds, uint8_t scale); void nscale8(CRGB* leds, uint8_t scale);
void setPixels(CRGB* leds); void setPixels(CRGB* leds);
void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, CRGB c); #else
void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB color, CRGB *leds = nullptr); uint16_t XY(uint16_t x, uint16_t y) { return x; }
void wu_pixel(uint32_t x, uint32_t y, CRGB c); void setPixelColorXY(int x, int y, uint32_t c) { setPixelColor(x, c); }
inline void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint32_t c) { drawLine(x0, y0, x1, y1, CRGB(byte(c>>16), byte(c>>8), byte(c))); } void setPixelColorXY(int x, int y, byte r, byte g, byte b, byte w = 0) { setPixelColor(x, RGBW32(r,g,b,w)); }
inline void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, uint32_t c) { drawCharacter(chr, x, y, w, h, CRGB(byte(c>>16), byte(c>>8), byte(c))); } void setPixelColorXY(int x, int y, CRGB c) { setPixelColor(x, RGBW32(c.r,c.g,c.b,0)); }
void setPixelColorXY(float x, float y, uint32_t c, bool aa = true) { setPixelColor(x, c, aa); }
void setPixelColorXY(float x, float y, byte r, byte g, byte b, byte w = 0, bool aa = true) { setPixelColor(x, RGBW32(r,g,b,w), aa); }
void setPixelColorXY(float x, float y, CRGB c, bool aa = true) { setPixelColor(x, RGBW32(c.r,c.g,c.b,0), aa); }
uint32_t getPixelColorXY(uint16_t x, uint16_t y) { return getPixelColor(x); }
void blendPixelColorXY(uint16_t x, uint16_t y, uint32_t c, uint8_t blend) { blendPixelColor(x, c, blend); }
void blendPixelColorXY(uint16_t x, uint16_t y, CRGB c, uint8_t blend) { blendPixelColor(x, RGBW32(c.r,c.g,c.b,0), blend); }
void addPixelColorXY(int x, int y, uint32_t color) { addPixelColor(x, color); }
void addPixelColorXY(int x, int y, byte r, byte g, byte b, byte w = 0) { addPixelColor(x, RGBW32(r,g,b,w)); }
void addPixelColorXY(int x, int y, CRGB c) { addPixelColor(x, RGBW32(c.r,c.g,c.b,0)); }
void fadePixelColorXY(uint16_t x, uint16_t y, uint8_t fade) { fadePixelColor(x, fade); }
void box_blur(uint16_t i, bool vertical, fract8 blur_amount) {}
void blurRow(uint16_t row, fract8 blur_amount, CRGB* leds=nullptr) {}
void blurCol(uint16_t col, fract8 blur_amount, CRGB* leds=nullptr) {}
void moveX(int8_t delta) {}
void moveY(int8_t delta) {}
void move(uint8_t dir, uint8_t delta) {}
void fill_circle(uint16_t cx, uint16_t cy, uint8_t radius, CRGB c) {}
void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint32_t c) {}
void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, CRGB c) {}
void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, uint32_t color) {}
void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB color) {}
void wu_pixel(uint32_t x, uint32_t y, CRGB c) {}
#endif
} segment; } segment;
//static int i = sizeof(Segment); //static int i = sizeof(Segment);
@ -778,10 +808,10 @@ class WS2812FX { // 96 bytes
const char ** const char **
getModeDataSrc(void) { return &(_modeData[0]); } // vectors use arrays for underlying data getModeDataSrc(void) { return &(_modeData[0]); } // vectors use arrays for underlying data
Segment& getSegment(uint8_t id); Segment& getSegment(uint8_t id);
inline Segment& getFirstSelectedSeg(void) { return _segments[getFirstSelectedSegId()]; } inline Segment& getFirstSelectedSeg(void) { return _segments[getFirstSelectedSegId()]; }
inline Segment& getMainSegment(void) { return _segments[getMainSegmentId()]; } inline Segment& getMainSegment(void) { return _segments[getMainSegmentId()]; }
inline Segment* getSegments(void) { return &(_segments[0]); } inline Segment* getSegments(void) { return &(_segments[0]); }
// 2D support (panels) // 2D support (panels)
bool bool
@ -800,11 +830,10 @@ class WS2812FX { // 96 bytes
matrixHeight; matrixHeight;
typedef struct panel_bitfield_t { typedef struct panel_bitfield_t {
unsigned char bool bottomStart : 1; // starts at bottom?
bottomStart : 1, // starts at bottom? bool rightStart : 1; // starts on right?
rightStart : 1, // starts on right? bool vertical : 1; // is vertical?
vertical : 1, // is vertical? bool serpentine : 1; // is serpentine?
serpentine : 1; // is serpentine?
} Panel; } Panel;
Panel Panel
matrix, matrix,
@ -817,7 +846,7 @@ class WS2812FX { // 96 bytes
// outsmart the compiler :) by correctly overloading // outsmart the compiler :) by correctly overloading
inline void setPixelColorXY(int x, int y, byte r, byte g, byte b, byte w = 0) { setPixelColorXY(x, y, RGBW32(r,g,b,w)); } // automatically inline inline void setPixelColorXY(int x, int y, byte r, byte g, byte b, byte w = 0) { setPixelColorXY(x, y, RGBW32(r,g,b,w)); } // automatically inline
inline void setPixelColorXY(int x, int y, CRGB c) { setPixelColorXY(x, y, c.red, c.green, c.blue); } inline void setPixelColorXY(int x, int y, CRGB c) { setPixelColorXY(x, y, RGBW32(c.r,c.g,c.b,0)); }
uint32_t uint32_t
getPixelColorXY(uint16_t, uint16_t); getPixelColorXY(uint16_t, uint16_t);

View File

@ -138,20 +138,17 @@ uint32_t WS2812FX::getPixelColorXY(uint16_t x, uint16_t y) {
// Segment:: routines // Segment:: routines
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
#ifndef WLED_DISABLE_2D
// XY(x,y) - gets pixel index within current segment (often used to reference leds[] array element) // XY(x,y) - gets pixel index within current segment (often used to reference leds[] array element)
uint16_t IRAM_ATTR Segment::XY(uint16_t x, uint16_t y) { uint16_t IRAM_ATTR Segment::XY(uint16_t x, uint16_t y) {
#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 (x%width) + (y%height) * width;
#else
return x;
#endif
} }
void IRAM_ATTR Segment::setPixelColorXY(int x, int y, uint32_t col) void IRAM_ATTR Segment::setPixelColorXY(int x, int y, uint32_t col)
{ {
#ifndef WLED_DISABLE_2D
if (!strip.isMatrix) return; // not a matrix set-up if (!strip.isMatrix) return; // not a matrix set-up
if (leds) leds[XY(x,y)] = col; if (leds) leds[XY(x,y)] = col;
@ -193,15 +190,11 @@ void IRAM_ATTR Segment::setPixelColorXY(int x, int y, uint32_t col)
} }
} }
} }
#else
setPixelColor(x, col);
#endif
} }
// anti-aliased version of setPixelColorXY() // anti-aliased version of setPixelColorXY()
void Segment::setPixelColorXY(float x, float y, uint32_t col, bool aa) void Segment::setPixelColorXY(float x, float y, uint32_t col, bool aa)
{ {
#ifndef WLED_DISABLE_2D
if (!strip.isMatrix) return; // not a matrix set-up if (!strip.isMatrix) return; // not a matrix set-up
if (x<0.0f || x>1.0f || y<0.0f || y>1.0f) return; // not normalized if (x<0.0f || x>1.0f || y<0.0f || y>1.0f) return; // not normalized
@ -241,12 +234,10 @@ void Segment::setPixelColorXY(float x, float y, uint32_t col, bool aa)
} else { } else {
setPixelColorXY(uint16_t(roundf(fX)), uint16_t(roundf(fY)), col); setPixelColorXY(uint16_t(roundf(fX)), uint16_t(roundf(fY)), col);
} }
#endif
} }
// returns RGBW values of pixel // returns RGBW values of pixel
uint32_t Segment::getPixelColorXY(uint16_t x, uint16_t y) { uint32_t Segment::getPixelColorXY(uint16_t x, uint16_t y) {
#ifndef WLED_DISABLE_2D
if (leds) return RGBW32(leds[XY(x,y)].r, leds[XY(x,y)].g, leds[XY(x,y)].b, 0); if (leds) return RGBW32(leds[XY(x,y)].r, leds[XY(x,y)].g, leds[XY(x,y)].b, 0);
if (getOption(SEG_OPTION_REVERSED) ) x = virtualWidth() - x - 1; if (getOption(SEG_OPTION_REVERSED) ) x = virtualWidth() - x - 1;
if (getOption(SEG_OPTION_REVERSED_Y)) y = virtualHeight() - y - 1; if (getOption(SEG_OPTION_REVERSED_Y)) y = virtualHeight() - y - 1;
@ -255,41 +246,25 @@ uint32_t Segment::getPixelColorXY(uint16_t x, uint16_t y) {
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); return strip.getPixelColorXY(start + x, startY + y);
#else
return getPixelColor(x);
#endif
} }
// Blends the specified color with the existing pixel color. // Blends the specified color with the existing pixel color.
void Segment::blendPixelColorXY(uint16_t x, uint16_t y, uint32_t color, uint8_t blend) { void Segment::blendPixelColorXY(uint16_t x, uint16_t y, uint32_t color, uint8_t blend) {
#ifndef WLED_DISABLE_2D
setPixelColorXY(x, y, color_blend(getPixelColorXY(x,y), color, blend)); setPixelColorXY(x, y, color_blend(getPixelColorXY(x,y), color, blend));
#else
setPixelColor(x, color_blend(getPixelColor(x), color, blend));
#endif
} }
// Adds the specified color with the existing pixel color perserving color balance. // Adds the specified color with the existing pixel color perserving color balance.
void Segment::addPixelColorXY(int x, int y, uint32_t color) { void Segment::addPixelColorXY(int x, int y, uint32_t color) {
#ifndef WLED_DISABLE_2D
setPixelColorXY(x, y, color_add(getPixelColorXY(x,y), color)); setPixelColorXY(x, y, color_add(getPixelColorXY(x,y), color));
#else
setPixelColor(x, color_add(getPixelColor(x), color));
#endif
} }
void Segment::fadePixelColorXY(uint16_t x, uint16_t y, uint8_t fade) { void Segment::fadePixelColorXY(uint16_t x, uint16_t y, uint8_t fade) {
#ifndef WLED_DISABLE_2D
CRGB pix = CRGB(getPixelColorXY(x,y)).nscale8_video(fade); CRGB pix = CRGB(getPixelColorXY(x,y)).nscale8_video(fade);
setPixelColor(x, y, pix); setPixelColor(x, y, pix);
#else
setPixelColor(x, CRGB(getPixelColor(x)).nscale8_video(fade));
#endif
} }
// blurRow: perform a blur on a row of a rectangular matrix // blurRow: perform a blur on a row of a rectangular matrix
void Segment::blurRow(uint16_t row, fract8 blur_amount, CRGB* leds) { void Segment::blurRow(uint16_t row, fract8 blur_amount, CRGB* leds) {
#ifndef WLED_DISABLE_2D
const uint16_t cols = virtualWidth(); const uint16_t cols = virtualWidth();
const uint16_t rows = virtualHeight(); const uint16_t rows = virtualHeight();
@ -313,12 +288,10 @@ void Segment::blurRow(uint16_t row, fract8 blur_amount, CRGB* leds) {
else setPixelColorXY(x, row, cur); else setPixelColorXY(x, row, cur);
carryover = part; carryover = part;
} }
#endif
} }
// blurCol: perform a blur on a column of a rectangular matrix // blurCol: perform a blur on a column of a rectangular matrix
void Segment::blurCol(uint16_t col, fract8 blur_amount, CRGB* leds) { void Segment::blurCol(uint16_t col, fract8 blur_amount, CRGB* leds) {
#ifndef WLED_DISABLE_2D
const uint16_t cols = virtualWidth(); const uint16_t cols = virtualWidth();
const uint16_t rows = virtualHeight(); const uint16_t rows = virtualHeight();
@ -342,33 +315,10 @@ void Segment::blurCol(uint16_t col, fract8 blur_amount, CRGB* leds) {
else setPixelColorXY(col, i, cur); else setPixelColorXY(col, i, cur);
carryover = part; carryover = part;
} }
#endif
}
// blur1d: one-dimensional blur filter. Spreads light to 2 line neighbors.
// blur2d: two-dimensional blur filter. Spreads light to 8 XY neighbors.
//
// 0 = no spread at all
// 64 = moderate spreading
// 172 = maximum smooth, even spreading
//
// 173..255 = wider spreading, but increasing flicker
//
// Total light is NOT entirely conserved, so many repeated
// calls to 'blur' will also result in the light fading,
// eventually all the way to black; this is by design so that
// it can be used to (slowly) clear the LEDs to black.
void Segment::blur1d(CRGB* leds, fract8 blur_amount) {
#ifndef WLED_DISABLE_2D
const uint16_t rows = virtualHeight();
for (uint16_t y = 0; y < rows; y++) blurRow(y, blur_amount, leds);
#endif
} }
// 1D Box blur (with added weight - blur_amount: [0=no blur, 255=max blur]) // 1D Box blur (with added weight - blur_amount: [0=no blur, 255=max blur])
void Segment::box_blur(uint16_t i, bool vertical, fract8 blur_amount) { void Segment::box_blur(uint16_t i, bool vertical, fract8 blur_amount) {
#ifndef WLED_DISABLE_2D
const uint16_t cols = virtualWidth(); const uint16_t cols = virtualWidth();
const uint16_t rows = virtualHeight(); const uint16_t rows = virtualHeight();
const uint16_t dim1 = vertical ? rows : cols; const uint16_t dim1 = vertical ? rows : cols;
@ -399,20 +349,35 @@ void Segment::box_blur(uint16_t i, bool vertical, fract8 blur_amount) {
uint16_t y = vertical ? j : i; uint16_t y = vertical ? j : i;
setPixelColorXY(x, y, tmp[j]); setPixelColorXY(x, y, tmp[j]);
} }
#endif }
// blur1d: one-dimensional blur filter. Spreads light to 2 line neighbors.
// blur2d: two-dimensional blur filter. Spreads light to 8 XY neighbors.
//
// 0 = no spread at all
// 64 = moderate spreading
// 172 = maximum smooth, even spreading
//
// 173..255 = wider spreading, but increasing flicker
//
// Total light is NOT entirely conserved, so many repeated
// calls to 'blur' will also result in the light fading,
// eventually all the way to black; this is by design so that
// it can be used to (slowly) clear the LEDs to black.
void Segment::blur1d(CRGB* leds, fract8 blur_amount) {
const uint16_t rows = virtualHeight();
for (uint16_t y = 0; y < rows; y++) blurRow(y, blur_amount, leds);
} }
void Segment::blur2d(CRGB* leds, fract8 blur_amount) { void Segment::blur2d(CRGB* leds, fract8 blur_amount) {
#ifndef WLED_DISABLE_2D
const uint16_t cols = virtualWidth(); const uint16_t cols = virtualWidth();
const uint16_t rows = virtualHeight(); const uint16_t rows = virtualHeight();
for (uint16_t i = 0; i < rows; i++) blurRow(i, blur_amount, leds); // blur all rows for (uint16_t i = 0; i < rows; i++) blurRow(i, blur_amount, leds); // blur all rows
for (uint16_t k = 0; k < cols; k++) blurCol(k, blur_amount, leds); // blur all columns for (uint16_t k = 0; k < cols; k++) blurCol(k, blur_amount, leds); // blur all columns
#endif
} }
void Segment::moveX(int8_t delta) { void Segment::moveX(int8_t delta) {
#ifndef WLED_DISABLE_2D
const uint16_t cols = virtualWidth(); const uint16_t cols = virtualWidth();
const uint16_t rows = virtualHeight(); const uint16_t rows = virtualHeight();
if (!delta) return; if (!delta) return;
@ -427,11 +392,9 @@ void Segment::moveX(int8_t delta) {
setPixelColorXY(x, y, getPixelColorXY(x + delta, y)); setPixelColorXY(x, y, getPixelColorXY(x + delta, y));
} }
} }
#endif
} }
void Segment::moveY(int8_t delta) { void Segment::moveY(int8_t delta) {
#ifndef WLED_DISABLE_2D
const uint16_t cols = virtualWidth(); const uint16_t cols = virtualWidth();
const uint16_t rows = virtualHeight(); const uint16_t rows = virtualHeight();
if (!delta) return; if (!delta) return;
@ -446,14 +409,12 @@ void Segment::moveY(int8_t delta) {
setPixelColorXY(x, y, getPixelColorXY(x, y + delta)); setPixelColorXY(x, y, getPixelColorXY(x, y + delta));
} }
} }
#endif
} }
// move() - move all pixels in desired direction delta number of pixels // move() - move all pixels in desired direction delta number of pixels
// @param dir direction: 0=left, 1=left-up, 2=up, 3=right-up, 4=right, 5=right-down, 6=down, 7=left-down // @param dir direction: 0=left, 1=left-up, 2=up, 3=right-up, 4=right, 5=right-down, 6=down, 7=left-down
// @param delta number of pixels to move // @param delta number of pixels to move
void Segment::move(uint8_t dir, uint8_t delta) { void Segment::move(uint8_t dir, uint8_t delta) {
#ifndef WLED_DISABLE_2D
if (delta==0) return; if (delta==0) return;
switch (dir) { switch (dir) {
case 0: moveX( delta); break; case 0: moveX( delta); break;
@ -465,7 +426,20 @@ void Segment::move(uint8_t dir, uint8_t delta) {
case 6: moveY(-delta); break; case 6: moveY(-delta); break;
case 7: moveX( delta); moveY(-delta); break; case 7: moveX( delta); moveY(-delta); break;
} }
#endif }
// by stepko, taken from https://editor.soulmatelights.com/gallery/573-blobs
void Segment::fill_circle(uint16_t cx, uint16_t cy, uint8_t radius, CRGB col) {
const uint16_t cols = virtualWidth();
const uint16_t rows = virtualHeight();
for (int16_t y = -radius; y <= radius; y++) {
for (int16_t x = -radius; x <= radius; x++) {
if (x * x + y * y <= radius * radius &&
int16_t(cx)+x>=0 && int16_t(cy)+y>=0 &&
int16_t(cx)+x<cols && int16_t(cy)+y<rows)
setPixelColorXY(cx + x, cy + y, col);
}
}
} }
void Segment::fill_solid(CRGB* leds, CRGB color) { void Segment::fill_solid(CRGB* leds, CRGB color) {
@ -477,50 +451,27 @@ void Segment::fill_solid(CRGB* leds, CRGB color) {
} }
} }
// by stepko, taken from https://editor.soulmatelights.com/gallery/573-blobs
void Segment::fill_circle(uint16_t cx, uint16_t cy, uint8_t radius, CRGB col) {
#ifndef WLED_DISABLE_2D
const uint16_t cols = virtualWidth();
const uint16_t rows = virtualHeight();
for (int16_t y = -radius; y <= radius; y++) {
for (int16_t x = -radius; x <= radius; x++) {
if (x * x + y * y <= radius * radius &&
int16_t(cx)+x>=0 && int16_t(cy)+y>=0 &&
int16_t(cx)+x<cols && int16_t(cy)+y<rows)
setPixelColorXY(cx + x, cy + y, col);
}
}
#endif
}
void Segment::fadeToBlackBy(CRGB* leds, uint8_t fadeBy) { void Segment::fadeToBlackBy(CRGB* leds, uint8_t fadeBy) {
#ifndef WLED_DISABLE_2D
nscale8(leds, 255 - fadeBy); nscale8(leds, 255 - fadeBy);
#endif
} }
void Segment::nscale8(CRGB* leds, uint8_t scale) { void Segment::nscale8(CRGB* leds, uint8_t scale) {
#ifndef WLED_DISABLE_2D
const uint16_t cols = virtualWidth(); const uint16_t cols = virtualWidth();
const uint16_t rows = virtualHeight(); const uint16_t rows = virtualHeight();
for(uint16_t y = 0; y < rows; y++) for (uint16_t x = 0; x < cols; x++) { for(uint16_t y = 0; y < rows; y++) for (uint16_t x = 0; x < cols; x++) {
if (leds) leds[XY(x,y)].nscale8(scale); if (leds) leds[XY(x,y)].nscale8(scale);
else setPixelColorXY(x, y, CRGB(getPixelColorXY(x, y)).nscale8(scale)); else setPixelColorXY(x, y, CRGB(getPixelColorXY(x, y)).nscale8(scale));
} }
#endif
} }
void Segment::setPixels(CRGB* leds) { void Segment::setPixels(CRGB* leds) {
#ifndef WLED_DISABLE_2D
const uint16_t cols = virtualWidth(); const uint16_t cols = virtualWidth();
const uint16_t rows = virtualHeight(); const uint16_t rows = virtualHeight();
for (uint16_t y = 0; y < rows; y++) for (uint16_t x = 0; x < cols; x++) setPixelColorXY(x, y, leds[XY(x,y)]); for (uint16_t y = 0; y < rows; y++) for (uint16_t x = 0; x < cols; x++) setPixelColorXY(x, y, leds[XY(x,y)]);
#endif
} }
//line function //line function
void Segment::drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, CRGB c) { void Segment::drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint32_t c) {
#ifndef WLED_DISABLE_2D
const uint16_t cols = virtualWidth(); const uint16_t cols = virtualWidth();
const uint16_t rows = virtualHeight(); const uint16_t rows = virtualHeight();
if (x0 >= cols || x1 >= cols || y0 >= rows || y1 >= rows) return; if (x0 >= cols || x1 >= cols || y0 >= rows || y1 >= rows) return;
@ -534,10 +485,8 @@ void Segment::drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, CRGB
if (e2 >-dx) { err -= dy; x0 += sx; } if (e2 >-dx) { err -= dy; x0 += sx; }
if (e2 < dy) { err += dx; y0 += sy; } if (e2 < dy) { err += dx; y0 += sy; }
} }
#endif
} }
#ifndef WLED_DISABLE_2D
// font curtesy of https://github.com/idispatch/raster-fonts // font curtesy of https://github.com/idispatch/raster-fonts
static const unsigned char console_font_6x8[] PROGMEM = { static const unsigned char console_font_6x8[] PROGMEM = {
@ -6688,12 +6637,10 @@ static const unsigned char console_font_5x8[] PROGMEM = {
0x00, /* 00000 */ 0x00, /* 00000 */
0x00, /* 00000 */ 0x00, /* 00000 */
}; };
#endif
// draws a raster font character on canvas // draws a raster font character on canvas
// only supports 5x8 and 6x8 fonts ATM // only supports 5x8 and 6x8 fonts ATM
void Segment::drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB color, CRGB *leds) { void Segment::drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, uint32_t color) {
#ifndef WLED_DISABLE_2D
const uint16_t cols = virtualWidth(); const uint16_t cols = virtualWidth();
const uint16_t rows = virtualHeight(); const uint16_t rows = virtualHeight();
@ -6710,17 +6657,14 @@ void Segment::drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w,
for (uint8_t j = 0; j<w; j++) { // character width for (uint8_t j = 0; j<w; j++) { // character width
int16_t x0 = x + (w-1) - j; int16_t x0 = x + (w-1) - j;
if ((x0 >= 0 || x0 < cols) && ((bits>>(j+(8-w))) & 0x01)) { // bit set & drawing on-screen if ((x0 >= 0 || x0 < cols) && ((bits>>(j+(8-w))) & 0x01)) { // bit set & drawing on-screen
if (leds) leds[XY(x0,y0)] = color; setPixelColorXY(x0, y0, color);
else setPixelColorXY(x0, y0, color);
} }
} }
} }
#endif
} }
#define WU_WEIGHT(a,b) ((uint8_t) (((a)*(b)+(a)+(b))>>8)) #define WU_WEIGHT(a,b) ((uint8_t) (((a)*(b)+(a)+(b))>>8))
void Segment::wu_pixel(uint32_t x, uint32_t y, CRGB c) { //awesome wu_pixel procedure by reddit u/sutaburosu void Segment::wu_pixel(uint32_t x, uint32_t y, CRGB c) { //awesome wu_pixel procedure by reddit u/sutaburosu
#ifndef WLED_DISABLE_2D
// extract the fractional parts and derive their inverses // extract the fractional parts and derive their inverses
uint8_t xx = x & 0xff, yy = y & 0xff, ix = 255 - xx, iy = 255 - yy; uint8_t xx = x & 0xff, yy = y & 0xff, ix = 255 - xx, iy = 255 - yy;
// calculate the intensities for each affected pixel // calculate the intensities for each affected pixel
@ -6734,6 +6678,7 @@ void Segment::wu_pixel(uint32_t x, uint32_t y, CRGB c) { //awesome wu_pixel
led.b = qadd8(led.b, c.b * wu[i] >> 8); led.b = qadd8(led.b, c.b * wu[i] >> 8);
setPixelColorXY(int((x >> 8) + (i & 1)), int((y >> 8) + ((i >> 1) & 1)), led); setPixelColorXY(int((x >> 8) + (i & 1)), int((y >> 8) + ((i >> 1) & 1)), led);
} }
#endif
} }
#undef WU_WEIGHT #undef WU_WEIGHT
#endif // WLED_DISABLE_2D

View File

@ -1,110 +1,81 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="theme-color" content="#222222"> <meta name="theme-color" content="#222222">
<title>WLED Live Preview</title> <title>WLED Live Preview</title>
<style> <style>
body { body {
margin: 0; margin: 0;
} }
</style> </style>
</head> </head>
<body> <body>
<canvas id="liveviewCanvas">LiveView</canvas> <canvas id="liveviewCanvas">LiveView</canvas>
<script> <script>
var c = document.getElementById('liveviewCanvas'); var c = document.getElementById('liveviewCanvas');
c.width = window.innerWidth * 0.98; //remove scroll bars var leds = "";
c.height = window.innerHeight * 0.98; //remove scroll bars var mW = 0, mH = 0, pPL = 0, lOf = 0;
var leds = ""; var throttled = false;
var mW = 0; function setCanvas() {
var mH = 0; c.width = window.innerWidth * 0.98; //remove scroll bars
var pPL = 0; c.height = window.innerHeight * 0.98; //remove scroll bars
var lOf = 0; }
// Check for canvas support setCanvas();
if (c.getContext) { // Check for canvas support
// Access the rendering context if (c.getContext) {
var ctx = c.getContext('2d'); // Access the rendering context
var ctx = c.getContext('2d');
//In case of pixels function drawCircle(x, y, r, g, b, a) {
ctx.fillStyle = `rgb(${r},${g},${b})`;
// // ImageData object ctx.beginPath();
// var imageData = ctx.getImageData(0, 0, c.width, c.height); ctx.arc(x*pPL+pPL*0.5+lOf, y*pPL+pPL*0.5, pPL*0.4, 0, 2 * Math.PI);
// // One-dimensional array containing the data in the RGBA order ctx.fill();
// var data = imageData.data; }
// use parent WS or open new
// function drawLedPixels(x, y, r, g, b, a) { //old var ws;
// // console.log(x, y, r, g, b, a); try {
// for (right = 0; right < pPL; right++) { ws = top.window.ws;
// for (down = 0; down < pPL; down++) { } catch (e) {}
// ff = (x * pPL + right + (y * pPL + down) * mW * pPL) * 4; if (ws && ws.readyState === WebSocket.OPEN) {
// // if (x==15 && y==15) ws.send("{'lv':true}");
// // console.log("ff=" + x + " * " + pPL + " +" + right + " + (" + y + " * " + pPL + " +" + down + ") * " + mW + ") * 4 = " + ff, data.length); //(5*10+1 + (12*10+1) * 16) * 4 = (51 + 121*16) * 4 } else {
// data[ff + 0] = r; ws = new WebSocket((window.location.protocol == "https:"?"wss":"ws")+"://"+document.location.host+"/ws");
// data[ff + 1] = g; ws.onopen = ()=>{
// data[ff + 2] = b; ws.send("{'lv':true}");
// data[ff + 3] = a; }
// } }
// } ws.binaryType = "arraybuffer";
// } ws.addEventListener('message',(e)=>{
try {
function drawLedCircles(x, y, r, g, b, a) { if (toString.call(e.data) === '[object ArrayBuffer]') {
ctx.fillStyle = `rgb(${r},${g},${b})`; let leds = new Uint8Array(event.data);
ctx.beginPath(); if (leds[0] != 76) return; //'L', set in ws.cpp
ctx.arc(x*pPL+pPL*0.5+lOf, y*pPL+pPL*0.5, pPL*0.4, 0, 2 * Math.PI); mW = leds[2]; // matrix width
ctx.fill(); mH = leds[3]; // matrix height
} pPL = Math.min(c.width / mW, c.height / mH); // pixels per LED (width of circle)
lOf = Math.floor((c.width - pPL*mW)/2); //left offeset (to center matrix)
function paintLeds() { for (i = 4; i < leds.length; i+=3) {
// data represents the Uint8ClampedArray containing the data let ff = (i-4)/3; // pixel index
// in the RGBA order [r0, g0, b0, a0, r1, g1, b1, a1, ..., rn, gn, bn, an] drawCircle(ff%mW, Math.floor(ff/mW), leds[i], leds[i+1], leds[i+2], 255);
}
for (i = 4; i < leds.length; i+=3) { }
let ff = (i-4)/3; } catch (err) {
drawLedCircles(ff%mW, Math.floor(ff/mW), leds[i], leds[i+1], leds[i+2], 255) console.error("Peek WS error:",err);
} }
});
// ctx.putImageData(imageData, 0, 0); //in case of drawLedPixels }
} // window.resize event listener
} window.addEventListener('resize', (e)=>{
if (!throttled) { // only run if we're not throttled
function updatePreview(ledsp) { setCanvas(); // actual callback action
leds = ledsp; throttled = true; // we're throttled!
mW = leds[2]; setTimeout(()=>{ // set a timeout to un-throttle
mH = leds[3]; throttled = false;
pPL = Math.min(c.width / mW, c.height / mH); }, 250);
lOf = Math.floor((c.width - pPL*mW)/2); }
paintLeds(); });
} </script>
function getLiveJson(e) {
try {
if (toString.call(e.data) === '[object ArrayBuffer]') {
let leds = new Uint8Array(event.data);
if (leds[0] != 76) return; //'L', set in ws.cpp
updatePreview(leds);
}
}
catch (err) {
console.error("Peek WS error:",err);
}
}
var ws;
try {
ws = top.window.ws;
} catch (e) {}
if (ws && ws.readyState === WebSocket.OPEN) {
ws.send("{'lv':true}");
} else {
ws = new WebSocket((window.location.protocol == "https:"?"wss":"ws")+"://"+document.location.host+"/ws");
ws.onopen = function () {
ws.send("{'lv':true}");
}
}
ws.binaryType = "arraybuffer";
ws.addEventListener('message',getLiveJson);
</script>
</body> </body>
</html> </html>

View File

@ -282,63 +282,63 @@ const uint8_t PAGE_liveviewws[] PROGMEM = {
// Autogenerated from wled00/data/liveviewws2D.htm, do not edit!! // Autogenerated from wled00/data/liveviewws2D.htm, do not edit!!
const uint16_t PAGE_liveviewws2D_length = 865; const uint16_t PAGE_liveviewws2D_length = 878;
const uint8_t PAGE_liveviewws2D[] PROGMEM = { const uint8_t PAGE_liveviewws2D[] PROGMEM = {
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x13, 0x6d, 0x54, 0x6d, 0x6f, 0xdb, 0x36, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x0a, 0x6d, 0x54, 0x6d, 0x73, 0xda, 0x46,
0x10, 0xfe, 0xee, 0x5f, 0xa1, 0x72, 0x5d, 0x2b, 0xc6, 0xb4, 0xe4, 0x3a, 0xc9, 0x96, 0xd9, 0x92, 0x10, 0xfe, 0xce, 0xaf, 0x90, 0xaf, 0x69, 0xa2, 0x33, 0x42, 0xc2, 0xd8, 0x6e, 0x5d, 0xe0, 0xc8,
0x8b, 0x35, 0x35, 0x90, 0x0e, 0xde, 0x62, 0xc0, 0xdd, 0x8c, 0x21, 0x08, 0x50, 0x5a, 0x3a, 0x5b, 0x34, 0x0e, 0x33, 0xce, 0x8c, 0x13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, 0x05, 0x00, 0x00
}; };

View File

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2208011 #define VERSION 2208031
//uncomment this if you have a "my_config.h" file you'd like to use //uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG //#define WLED_USE_MY_CONFIG

View File

@ -103,6 +103,7 @@ void initServer()
request->send(response); request->send(response);
//request->send_P(200, "text/html", PAGE_liveviewws); //request->send_P(200, "text/html", PAGE_liveviewws);
}); });
#ifndef WLED_DISABLE_2D
server.on("/liveview2D", HTTP_GET, [](AsyncWebServerRequest *request){ server.on("/liveview2D", HTTP_GET, [](AsyncWebServerRequest *request){
if (handleIfNoneMatchCacheHeader(request)) return; if (handleIfNoneMatchCacheHeader(request)) return;
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", PAGE_liveviewws2D, PAGE_liveviewws2D_length); AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", PAGE_liveviewws2D, PAGE_liveviewws2D_length);
@ -111,6 +112,7 @@ void initServer()
request->send(response); request->send(response);
//request->send_P(200, "text/html", PAGE_liveviewws); //request->send_P(200, "text/html", PAGE_liveviewws);
}); });
#endif
#else #else
server.on("/liveview", HTTP_GET, [](AsyncWebServerRequest *request){ server.on("/liveview", HTTP_GET, [](AsyncWebServerRequest *request){
if (handleIfNoneMatchCacheHeader(request)) return; if (handleIfNoneMatchCacheHeader(request)) return;

View File

@ -138,7 +138,11 @@ void sendDataWs(AsyncWebSocketClient * client)
releaseJSONBufferLock(); releaseJSONBufferLock();
} }
#define MAX_LIVE_LEDS_WS 1024 #ifndef WLED_DISABLE_2D
#define MAX_LIVE_LEDS_WS 1024
#else
#define MAX_LIVE_LEDS_WS 256
#endif
bool sendLiveLedsWs(uint32_t wsClient) bool sendLiveLedsWs(uint32_t wsClient)
{ {
@ -153,10 +157,14 @@ bool sendLiveLedsWs(uint32_t wsClient)
uint8_t* buffer = wsBuf->get(); uint8_t* buffer = wsBuf->get();
buffer[0] = 'L'; buffer[0] = 'L';
buffer[1] = 1; //version buffer[1] = 1; //version
#ifndef WLED_DISABLE_2D
buffer[2] = strip.matrixWidth; buffer[2] = strip.matrixWidth;
buffer[3] = strip.matrixHeight; buffer[3] = strip.matrixHeight;
uint16_t pos = 4; uint16_t pos = 4;
#else
uint16_t pos = 2;
#endif
for (uint16_t i= 0; pos < bufSize -2; i += n) for (uint16_t i= 0; pos < bufSize -2; i += n)
{ {
uint32_t c = strip.getPixelColor(i); uint32_t c = strip.getPixelColor(i);