Speed optimisations.
This commit is contained in:
parent
1be6223a31
commit
f329a5950e
@ -220,7 +220,8 @@ build_flags =
|
|||||||
; restrict to minimal mime-types
|
; restrict to minimal mime-types
|
||||||
-DMIMETYPE_MINIMAL
|
-DMIMETYPE_MINIMAL
|
||||||
; other special-purpose framework flags (see https://docs.platformio.org/en/latest/platforms/espressif8266.html)
|
; other special-purpose framework flags (see https://docs.platformio.org/en/latest/platforms/espressif8266.html)
|
||||||
; -D PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48 ;; in case of linker errors like "section `.text1' will not fit in region `iram1_0_seg'"
|
; decrease code cache size and increase IRAM to fit all pixel functions
|
||||||
|
-D PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48 ;; in case of linker errors like "section `.text1' will not fit in region `iram1_0_seg'"
|
||||||
; -D PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED ;; (experimental) adds some extra heap, but may cause slowdown
|
; -D PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED ;; (experimental) adds some extra heap, but may cause slowdown
|
||||||
|
|
||||||
lib_deps =
|
lib_deps =
|
||||||
|
123
wled00/FX.h
123
wled00/FX.h
@ -572,24 +572,24 @@ typedef struct Segment {
|
|||||||
// 1D strip
|
// 1D strip
|
||||||
uint16_t virtualLength(void) const;
|
uint16_t virtualLength(void) const;
|
||||||
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(unsigned n, uint32_t c) { setPixelColor(int(n), c); }
|
inline void setPixelColor(unsigned n, uint32_t c) { setPixelColor(int(n), c); }
|
||||||
void setPixelColor(int n, byte r, byte g, byte b, byte w = 0) { setPixelColor(n, RGBW32(r,g,b,w)); } // automatically inline
|
inline void setPixelColor(int n, byte r, byte g, byte b, byte w = 0) { setPixelColor(n, RGBW32(r,g,b,w)); }
|
||||||
void setPixelColor(int n, CRGB c) { setPixelColor(n, RGBW32(c.r,c.g,c.b,0)); } // automatically inline
|
inline void setPixelColor(int n, CRGB c) { setPixelColor(n, RGBW32(c.r,c.g,c.b,0)); }
|
||||||
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); }
|
inline 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, RGBW32(c.r,c.g,c.b,0), aa); }
|
inline void setPixelColor(float i, CRGB c, bool aa = true) { setPixelColor(i, RGBW32(c.r,c.g,c.b,0), aa); }
|
||||||
uint32_t getPixelColor(int i);
|
uint32_t getPixelColor(int 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);
|
||||||
void fill(uint32_t c);
|
void fill(uint32_t c);
|
||||||
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);
|
inline void blendPixelColor(int n, uint32_t color, uint8_t blend) { setPixelColor(n, color_blend(getPixelColor(n), color, blend)); }
|
||||||
void blendPixelColor(int n, CRGB c, uint8_t blend) { blendPixelColor(n, RGBW32(c.r,c.g,c.b,0), blend); }
|
inline 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, bool fast = false);
|
inline void addPixelColor(int n, uint32_t color, bool fast = false) { setPixelColor(n, color_add(getPixelColor(n), color, fast)); }
|
||||||
void addPixelColor(int n, byte r, byte g, byte b, byte w = 0, bool fast = false) { addPixelColor(n, RGBW32(r,g,b,w), fast); } // automatically inline
|
inline void addPixelColor(int n, byte r, byte g, byte b, byte w = 0, bool fast = false) { addPixelColor(n, RGBW32(r,g,b,w), fast); }
|
||||||
void addPixelColor(int n, CRGB c, bool fast = false) { addPixelColor(n, RGBW32(c.r,c.g,c.b,0), fast); } // automatically inline
|
inline void addPixelColor(int n, CRGB c, bool fast = false) { addPixelColor(n, RGBW32(c.r,c.g,c.b,0), fast); }
|
||||||
void fadePixelColor(uint16_t n, uint8_t fade);
|
inline void fadePixelColor(uint16_t n, uint8_t fade) { setPixelColor(n, color_fade(getPixelColor(n), fade, true)); }
|
||||||
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);
|
||||||
uint32_t color_wheel(uint8_t pos);
|
uint32_t color_wheel(uint8_t pos);
|
||||||
|
|
||||||
@ -600,20 +600,20 @@ typedef struct Segment {
|
|||||||
#ifndef WLED_DISABLE_2D
|
#ifndef WLED_DISABLE_2D
|
||||||
uint16_t XY(uint16_t x, uint16_t y); // support function to get relative index within segment
|
uint16_t XY(uint16_t x, uint16_t y); // support function to get relative index within segment
|
||||||
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(unsigned x, unsigned y, uint32_t c) { setPixelColorXY(int(x), int(y), c); }
|
inline void setPixelColorXY(unsigned x, unsigned y, uint32_t c) { setPixelColorXY(int(x), int(y), c); }
|
||||||
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)); }
|
||||||
void setPixelColorXY(int x, int y, CRGB c) { setPixelColorXY(x, y, RGBW32(c.r,c.g,c.b,0)); } // automatically inline
|
inline void setPixelColorXY(int x, int y, CRGB c) { setPixelColorXY(x, y, RGBW32(c.r,c.g,c.b,0)); }
|
||||||
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); }
|
inline 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, RGBW32(c.r,c.g,c.b,0), aa); }
|
inline 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);
|
inline void blendPixelColorXY(uint16_t x, uint16_t y, uint32_t color, uint8_t blend) { setPixelColorXY(x, y, color_blend(getPixelColorXY(x,y), color, 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); }
|
inline 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, bool fast = false);
|
inline void addPixelColorXY(int x, int y, uint32_t color, bool fast = false) { setPixelColorXY(x, y, color_add(getPixelColorXY(x,y), color, fast)); }
|
||||||
void addPixelColorXY(int x, int y, byte r, byte g, byte b, byte w = 0, bool fast = false) { addPixelColorXY(x, y, RGBW32(r,g,b,w), fast); } // automatically inline
|
inline void addPixelColorXY(int x, int y, byte r, byte g, byte b, byte w = 0, bool fast = false) { addPixelColorXY(x, y, RGBW32(r,g,b,w), fast); }
|
||||||
void addPixelColorXY(int x, int y, CRGB c, bool fast = false) { addPixelColorXY(x, y, RGBW32(c.r,c.g,c.b,0), fast); }
|
inline void addPixelColorXY(int x, int y, CRGB c, bool fast = false) { addPixelColorXY(x, y, RGBW32(c.r,c.g,c.b,0), fast); }
|
||||||
void fadePixelColorXY(uint16_t x, uint16_t y, uint8_t fade);
|
inline void fadePixelColorXY(uint16_t x, uint16_t y, uint8_t fade) { setPixelColorXY(x, y, color_fade(getPixelColorXY(x,y), fade, true)); }
|
||||||
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 blurRow(uint16_t row, fract8 blur_amount);
|
void blurRow(uint16_t row, fract8 blur_amount);
|
||||||
void blurCol(uint16_t col, fract8 blur_amount);
|
void blurCol(uint16_t col, fract8 blur_amount);
|
||||||
@ -623,43 +623,43 @@ typedef struct Segment {
|
|||||||
void draw_circle(uint16_t cx, uint16_t cy, uint8_t radius, CRGB c);
|
void draw_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 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, 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
|
inline 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, uint32_t col2 = 0, int8_t rotate = 0);
|
void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, uint32_t color, uint32_t col2 = 0, int8_t rotate = 0);
|
||||||
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
|
inline 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 drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB c, CRGB c2, int8_t rotate = 0) { drawCharacter(chr, x, y, w, h, RGBW32(c.r,c.g,c.b,0), RGBW32(c2.r,c2.g,c2.b,0), rotate); } // automatic inline
|
inline void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB c, CRGB c2, int8_t rotate = 0) { drawCharacter(chr, x, y, w, h, RGBW32(c.r,c.g,c.b,0), RGBW32(c2.r,c2.g,c2.b,0), rotate); } // automatic inline
|
||||||
void wu_pixel(uint32_t x, uint32_t y, CRGB c);
|
void wu_pixel(uint32_t x, uint32_t y, CRGB c);
|
||||||
void blur1d(fract8 blur_amount); // blur all rows in 1 dimension
|
void blur1d(fract8 blur_amount); // blur all rows in 1 dimension
|
||||||
void blur2d(fract8 blur_amount) { blur(blur_amount); }
|
inline void blur2d(fract8 blur_amount) { blur(blur_amount); }
|
||||||
void fill_solid(CRGB c) { fill(RGBW32(c.r,c.g,c.b,0)); }
|
inline void fill_solid(CRGB c) { fill(RGBW32(c.r,c.g,c.b,0)); }
|
||||||
void nscale8(uint8_t scale);
|
void nscale8(uint8_t scale);
|
||||||
#else
|
#else
|
||||||
uint16_t XY(uint16_t x, uint16_t y) { return x; }
|
inline uint16_t XY(uint16_t x, uint16_t y) { return x; }
|
||||||
void setPixelColorXY(int x, int y, uint32_t c) { setPixelColor(x, c); }
|
inline void setPixelColorXY(int x, int y, uint32_t c) { setPixelColor(x, 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 setPixelColorXY(int x, int y, byte r, byte g, byte b, byte w = 0) { setPixelColor(x, RGBW32(r,g,b,w)); }
|
||||||
void setPixelColorXY(int x, int y, CRGB c) { setPixelColor(x, RGBW32(c.r,c.g,c.b,0)); }
|
inline 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); }
|
inline 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); }
|
inline 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); }
|
inline 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); }
|
inline 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); }
|
inline 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); }
|
inline 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, bool fast = false) { addPixelColor(x, color, fast); }
|
inline void addPixelColorXY(int x, int y, uint32_t color, bool fast = false) { addPixelColor(x, color, fast); }
|
||||||
void addPixelColorXY(int x, int y, byte r, byte g, byte b, byte w = 0, bool fast = false) { addPixelColor(x, RGBW32(r,g,b,w), fast); }
|
inline void addPixelColorXY(int x, int y, byte r, byte g, byte b, byte w = 0, bool fast = false) { addPixelColor(x, RGBW32(r,g,b,w), fast); }
|
||||||
void addPixelColorXY(int x, int y, CRGB c, bool fast = false) { addPixelColor(x, RGBW32(c.r,c.g,c.b,0), fast); }
|
inline void addPixelColorXY(int x, int y, CRGB c, bool fast = false) { addPixelColor(x, RGBW32(c.r,c.g,c.b,0), fast); }
|
||||||
void fadePixelColorXY(uint16_t x, uint16_t y, uint8_t fade) { fadePixelColor(x, fade); }
|
inline 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) {}
|
inline void box_blur(uint16_t i, bool vertical, fract8 blur_amount) {}
|
||||||
void blurRow(uint16_t row, fract8 blur_amount) {}
|
inline void blurRow(uint16_t row, fract8 blur_amount) {}
|
||||||
void blurCol(uint16_t col, fract8 blur_amount) {}
|
inline void blurCol(uint16_t col, fract8 blur_amount) {}
|
||||||
void moveX(int8_t delta, bool wrap = false) {}
|
inline void moveX(int8_t delta, bool wrap = false) {}
|
||||||
void moveY(int8_t delta, bool wrap = false) {}
|
inline void moveY(int8_t delta, bool wrap = false) {}
|
||||||
void move(uint8_t dir, uint8_t delta, bool wrap = false) {}
|
inline void move(uint8_t dir, uint8_t delta, bool wrap = false) {}
|
||||||
void fill_circle(uint16_t cx, uint16_t cy, uint8_t radius, CRGB c) {}
|
inline 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) {}
|
inline 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) {}
|
inline 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, uint32_t = 0, int8_t = 0) {}
|
inline void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, uint32_t color, uint32_t = 0, int8_t = 0) {}
|
||||||
void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB color) {}
|
inline void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB color) {}
|
||||||
void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB c, CRGB c2, int8_t rotate = 0) {}
|
inline void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB c, CRGB c2, int8_t rotate = 0) {}
|
||||||
void wu_pixel(uint32_t x, uint32_t y, CRGB c) {}
|
inline void wu_pixel(uint32_t x, uint32_t y, CRGB c) {}
|
||||||
#endif
|
#endif
|
||||||
} segment;
|
} segment;
|
||||||
//static int segSize = sizeof(Segment);
|
//static int segSize = sizeof(Segment);
|
||||||
@ -754,23 +754,22 @@ class WS2812FX { // 96 bytes
|
|||||||
setCCT(uint16_t k),
|
setCCT(uint16_t k),
|
||||||
setBrightness(uint8_t b, bool direct = false),
|
setBrightness(uint8_t b, bool direct = false),
|
||||||
setRange(uint16_t i, uint16_t i2, uint32_t col),
|
setRange(uint16_t i, uint16_t i2, uint32_t col),
|
||||||
setTransitionMode(bool t),
|
|
||||||
purgeSegments(bool force = false),
|
purgeSegments(bool force = false),
|
||||||
setSegment(uint8_t n, uint16_t start, uint16_t stop, uint8_t grouping = 1, uint8_t spacing = 0, uint16_t offset = UINT16_MAX, uint16_t startY=0, uint16_t stopY=1),
|
setSegment(uint8_t n, uint16_t start, uint16_t stop, uint8_t grouping = 1, uint8_t spacing = 0, uint16_t offset = UINT16_MAX, uint16_t startY=0, uint16_t stopY=1),
|
||||||
setMainSegmentId(uint8_t n),
|
setMainSegmentId(uint8_t n),
|
||||||
restartRuntime(),
|
|
||||||
resetSegments(),
|
resetSegments(),
|
||||||
makeAutoSegments(bool forceReset = false),
|
makeAutoSegments(bool forceReset = false),
|
||||||
fixInvalidSegments(),
|
fixInvalidSegments(),
|
||||||
setPixelColor(int n, uint32_t c),
|
setPixelColor(int n, uint32_t c),
|
||||||
show(void),
|
show(void),
|
||||||
setTargetFps(uint8_t fps);
|
setTargetFps(uint8_t fps),
|
||||||
|
addEffect(uint8_t id, mode_ptr mode_fn, const char *mode_name), // add effect to the list; defined in FX.cpp
|
||||||
void setColor(uint8_t slot, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0) { setColor(slot, RGBW32(r,g,b,w)); }
|
setupEffectData(void); // add default effects to the list; defined in FX.cpp
|
||||||
void fill(uint32_t c) { for (int i = 0; i < getLengthTotal(); i++) setPixelColor(i, c); } // fill whole strip with color (inline)
|
|
||||||
void addEffect(uint8_t id, mode_ptr mode_fn, const char *mode_name); // add effect to the list; defined in FX.cpp
|
|
||||||
void setupEffectData(void); // add default effects to the list; defined in FX.cpp
|
|
||||||
|
|
||||||
|
inline void restartRuntime() { for (Segment &seg : _segments) seg.markForReset(); }
|
||||||
|
inline void setTransitionMode(bool t) { for (Segment &seg : _segments) seg.startTransition(t ? _transitionDur : 0); }
|
||||||
|
inline void setColor(uint8_t slot, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0) { setColor(slot, RGBW32(r,g,b,w)); }
|
||||||
|
inline void fill(uint32_t c) { for (int i = 0; i < getLengthTotal(); i++) setPixelColor(i, c); } // fill whole strip with color (inline)
|
||||||
// outsmart the compiler :) by correctly overloading
|
// outsmart the compiler :) by correctly overloading
|
||||||
inline void setPixelColor(int n, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0) { setPixelColor(n, RGBW32(r,g,b,w)); }
|
inline void setPixelColor(int n, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0) { setPixelColor(n, RGBW32(r,g,b,w)); }
|
||||||
inline void setPixelColor(int n, CRGB c) { setPixelColor(n, c.red, c.green, c.blue); }
|
inline void setPixelColor(int n, CRGB c) { setPixelColor(n, c.red, c.green, c.blue); }
|
||||||
|
@ -265,7 +265,7 @@ void Segment::setPixelColorXY(float x, float y, uint32_t col, bool aa)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// returns RGBW values of pixel
|
// returns RGBW values of pixel
|
||||||
uint32_t Segment::getPixelColorXY(uint16_t x, uint16_t y) {
|
uint32_t IRAM_ATTR Segment::getPixelColorXY(uint16_t x, uint16_t y) {
|
||||||
if (!isActive()) return 0; // not active
|
if (!isActive()) return 0; // not active
|
||||||
if (x >= virtualWidth() || y >= virtualHeight() || x<0 || y<0) return 0; // if pixel would fall out of virtual segment just exit
|
if (x >= virtualWidth() || y >= virtualHeight() || x<0 || y<0) return 0; // if pixel would fall out of virtual segment just exit
|
||||||
if (reverse ) x = virtualWidth() - x - 1;
|
if (reverse ) x = virtualWidth() - x - 1;
|
||||||
@ -277,23 +277,6 @@ uint32_t Segment::getPixelColorXY(uint16_t x, uint16_t y) {
|
|||||||
return strip.getPixelColorXY(start + x, startY + y);
|
return strip.getPixelColorXY(start + x, startY + y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Blends the specified color with the existing pixel color.
|
|
||||||
void Segment::blendPixelColorXY(uint16_t x, uint16_t y, uint32_t color, uint8_t blend) {
|
|
||||||
setPixelColorXY(x, y, color_blend(getPixelColorXY(x,y), color, blend));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adds the specified color with the existing pixel color perserving color balance.
|
|
||||||
void Segment::addPixelColorXY(int x, int y, uint32_t color, bool fast) {
|
|
||||||
if (!isActive()) return; // not active
|
|
||||||
if (x >= virtualWidth() || y >= virtualHeight() || x<0 || y<0) return; // if pixel would fall out of virtual segment just exit
|
|
||||||
setPixelColorXY(x, y, color_add(getPixelColorXY(x,y), color, fast));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Segment::fadePixelColorXY(uint16_t x, uint16_t y, uint8_t fade) {
|
|
||||||
if (!isActive()) return; // not active
|
|
||||||
setPixelColorXY(x, y, color_fade(getPixelColorXY(x,y), fade, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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) {
|
void Segment::blurRow(uint16_t row, fract8 blur_amount) {
|
||||||
if (!isActive() || blur_amount == 0) return; // not active
|
if (!isActive() || blur_amount == 0) return; // not active
|
||||||
|
@ -152,7 +152,7 @@ Segment& Segment::operator= (Segment &&orig) noexcept {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Segment::allocateData(size_t len) {
|
bool IRAM_ATTR Segment::allocateData(size_t len) {
|
||||||
if (data && _dataLen == len) return true; //already allocated
|
if (data && _dataLen == len) return true; //already allocated
|
||||||
//DEBUG_PRINTF("-- Allocating data (%d): %p\n", len, this);
|
//DEBUG_PRINTF("-- Allocating data (%d): %p\n", len, this);
|
||||||
deallocateData();
|
deallocateData();
|
||||||
@ -173,7 +173,7 @@ bool Segment::allocateData(size_t len) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Segment::deallocateData() {
|
void IRAM_ATTR Segment::deallocateData() {
|
||||||
if (!data) { _dataLen = 0; return; }
|
if (!data) { _dataLen = 0; return; }
|
||||||
//DEBUG_PRINTF("--- Released data (%p): %d/%d -> %p\n", this, _dataLen, Segment::getUsedSegmentData(), data);
|
//DEBUG_PRINTF("--- Released data (%p): %d/%d -> %p\n", this, _dataLen, Segment::getUsedSegmentData(), data);
|
||||||
if ((Segment::getUsedSegmentData() > 0) && (_dataLen > 0)) { // check that we don't have a dangling / inconsistent data pointer
|
if ((Segment::getUsedSegmentData() > 0) && (_dataLen > 0)) { // check that we don't have a dangling / inconsistent data pointer
|
||||||
@ -205,7 +205,7 @@ void Segment::resetIfRequired() {
|
|||||||
reset = false;
|
reset = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CRGBPalette16 &Segment::loadPalette(CRGBPalette16 &targetPalette, uint8_t pal) {
|
CRGBPalette16 IRAM_ATTR &Segment::loadPalette(CRGBPalette16 &targetPalette, uint8_t pal) {
|
||||||
if (pal < 245 && pal > GRADIENT_PALETTE_COUNT+13) pal = 0;
|
if (pal < 245 && pal > GRADIENT_PALETTE_COUNT+13) pal = 0;
|
||||||
if (pal > 245 && (strip.customPalettes.size() == 0 || 255U-pal > strip.customPalettes.size()-1)) pal = 0;
|
if (pal > 245 && (strip.customPalettes.size() == 0 || 255U-pal > strip.customPalettes.size()-1)) pal = 0;
|
||||||
//default palette. Differs depending on effect
|
//default palette. Differs depending on effect
|
||||||
@ -347,7 +347,7 @@ void Segment::handleTransition() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// transition progression between 0-65535
|
// transition progression between 0-65535
|
||||||
uint16_t Segment::progress() {
|
uint16_t IRAM_ATTR Segment::progress() {
|
||||||
if (isInTransition()) {
|
if (isInTransition()) {
|
||||||
unsigned long timeNow = millis();
|
unsigned long timeNow = millis();
|
||||||
if (_t->_dur > 0 && timeNow - _t->_start < _t->_dur) return (timeNow - _t->_start) * 0xFFFFU / _t->_dur;
|
if (_t->_dur > 0 && timeNow - _t->_start < _t->_dur) return (timeNow - _t->_start) * 0xFFFFU / _t->_dur;
|
||||||
@ -428,7 +428,7 @@ void Segment::restoreSegenv(tmpsegd_t &tmpSeg) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t Segment::currentBri(bool useCct) {
|
uint8_t IRAM_ATTR Segment::currentBri(bool useCct) {
|
||||||
uint32_t prog = progress();
|
uint32_t prog = progress();
|
||||||
if (prog < 0xFFFFU) {
|
if (prog < 0xFFFFU) {
|
||||||
uint32_t curBri = (useCct ? cct : (on ? opacity : 0)) * prog;
|
uint32_t curBri = (useCct ? cct : (on ? opacity : 0)) * prog;
|
||||||
@ -438,7 +438,7 @@ uint8_t Segment::currentBri(bool useCct) {
|
|||||||
return (useCct ? cct : (on ? opacity : 0));
|
return (useCct ? cct : (on ? opacity : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Segment::currentMode() {
|
uint8_t IRAM_ATTR Segment::currentMode() {
|
||||||
#ifndef WLED_DISABLE_MODE_BLEND
|
#ifndef WLED_DISABLE_MODE_BLEND
|
||||||
uint16_t prog = progress();
|
uint16_t prog = progress();
|
||||||
if (modeBlending && prog < 0xFFFFU) return _t->_modeT;
|
if (modeBlending && prog < 0xFFFFU) return _t->_modeT;
|
||||||
@ -446,7 +446,7 @@ uint8_t Segment::currentMode() {
|
|||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Segment::currentColor(uint8_t slot) {
|
uint32_t IRAM_ATTR Segment::currentColor(uint8_t slot) {
|
||||||
#ifndef WLED_DISABLE_MODE_BLEND
|
#ifndef WLED_DISABLE_MODE_BLEND
|
||||||
return isInTransition() ? color_blend(_t->_segT._colorT[slot], colors[slot], progress(), true) : colors[slot];
|
return isInTransition() ? color_blend(_t->_segT._colorT[slot], colors[slot], progress(), true) : colors[slot];
|
||||||
#else
|
#else
|
||||||
@ -454,7 +454,7 @@ uint32_t Segment::currentColor(uint8_t slot) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
CRGBPalette16 &Segment::currentPalette(CRGBPalette16 &targetPalette, uint8_t pal) {
|
CRGBPalette16 IRAM_ATTR &Segment::currentPalette(CRGBPalette16 &targetPalette, uint8_t pal) {
|
||||||
loadPalette(targetPalette, pal);
|
loadPalette(targetPalette, pal);
|
||||||
uint16_t prog = progress();
|
uint16_t prog = progress();
|
||||||
if (strip.paletteFade && prog < 0xFFFFU) {
|
if (strip.paletteFade && prog < 0xFFFFU) {
|
||||||
@ -612,21 +612,21 @@ void Segment::setPalette(uint8_t pal) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 2D matrix
|
// 2D matrix
|
||||||
uint16_t Segment::virtualWidth() const {
|
uint16_t IRAM_ATTR Segment::virtualWidth() const {
|
||||||
uint16_t groupLen = groupLength();
|
uint16_t groupLen = groupLength();
|
||||||
uint16_t vWidth = ((transpose ? height() : width()) + groupLen - 1) / groupLen;
|
uint16_t vWidth = ((transpose ? height() : width()) + groupLen - 1) / groupLen;
|
||||||
if (mirror) vWidth = (vWidth + 1) /2; // divide by 2 if mirror, leave at least a single LED
|
if (mirror) vWidth = (vWidth + 1) /2; // divide by 2 if mirror, leave at least a single LED
|
||||||
return vWidth;
|
return vWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Segment::virtualHeight() const {
|
uint16_t IRAM_ATTR Segment::virtualHeight() const {
|
||||||
uint16_t groupLen = groupLength();
|
uint16_t groupLen = groupLength();
|
||||||
uint16_t vHeight = ((transpose ? width() : height()) + groupLen - 1) / groupLen;
|
uint16_t vHeight = ((transpose ? width() : height()) + groupLen - 1) / groupLen;
|
||||||
if (mirror_y) vHeight = (vHeight + 1) /2; // divide by 2 if mirror, leave at least a single LED
|
if (mirror_y) vHeight = (vHeight + 1) /2; // divide by 2 if mirror, leave at least a single LED
|
||||||
return vHeight;
|
return vHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Segment::nrOfVStrips() const {
|
uint16_t IRAM_ATTR Segment::nrOfVStrips() const {
|
||||||
uint16_t vLen = 1;
|
uint16_t vLen = 1;
|
||||||
#ifndef WLED_DISABLE_2D
|
#ifndef WLED_DISABLE_2D
|
||||||
if (is2D()) {
|
if (is2D()) {
|
||||||
@ -641,7 +641,7 @@ uint16_t Segment::nrOfVStrips() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 1D strip
|
// 1D strip
|
||||||
uint16_t Segment::virtualLength() const {
|
uint16_t IRAM_ATTR Segment::virtualLength() const {
|
||||||
#ifndef WLED_DISABLE_2D
|
#ifndef WLED_DISABLE_2D
|
||||||
if (is2D()) {
|
if (is2D()) {
|
||||||
uint16_t vW = virtualWidth();
|
uint16_t vW = virtualWidth();
|
||||||
@ -813,7 +813,7 @@ void Segment::setPixelColor(float i, uint32_t col, bool aa)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Segment::getPixelColor(int i)
|
uint32_t IRAM_ATTR Segment::getPixelColor(int i)
|
||||||
{
|
{
|
||||||
if (!isActive()) return 0; // not active
|
if (!isActive()) return 0; // not active
|
||||||
#ifndef WLED_DISABLE_2D
|
#ifndef WLED_DISABLE_2D
|
||||||
@ -942,22 +942,6 @@ void Segment::fill(uint32_t c) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Blends the specified color with the existing pixel color.
|
|
||||||
void Segment::blendPixelColor(int n, uint32_t color, uint8_t blend) {
|
|
||||||
setPixelColor(n, color_blend(getPixelColor(n), color, blend));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adds the specified color with the existing pixel color perserving color balance.
|
|
||||||
void Segment::addPixelColor(int n, uint32_t color, bool fast) {
|
|
||||||
if (!isActive()) return; // not active
|
|
||||||
setPixelColor(n, color_add(getPixelColor(n), color, fast));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Segment::fadePixelColor(uint16_t n, uint8_t fade) {
|
|
||||||
if (!isActive()) return; // not active
|
|
||||||
setPixelColor(n, color_fade(getPixelColor(n), fade, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fade out function, higher rate = quicker fade
|
* fade out function, higher rate = quicker fade
|
||||||
*/
|
*/
|
||||||
@ -1013,8 +997,7 @@ void Segment::fadeToBlackBy(uint8_t fadeBy) {
|
|||||||
/*
|
/*
|
||||||
* blurs segment content, source: FastLED colorutils.cpp
|
* blurs segment content, source: FastLED colorutils.cpp
|
||||||
*/
|
*/
|
||||||
void Segment::blur(uint8_t blur_amount)
|
void Segment::blur(uint8_t blur_amount) {
|
||||||
{
|
|
||||||
if (!isActive() || blur_amount == 0) return; // optimization: 0 means "don't blur"
|
if (!isActive() || blur_amount == 0) return; // optimization: 0 means "don't blur"
|
||||||
#ifndef WLED_DISABLE_2D
|
#ifndef WLED_DISABLE_2D
|
||||||
if (is2D()) {
|
if (is2D()) {
|
||||||
@ -1071,8 +1054,7 @@ uint32_t Segment::color_wheel(uint8_t pos) {
|
|||||||
* @param pbri Value to scale the brightness of the returned color by. Default is 255. (no scaling)
|
* @param pbri Value to scale the brightness of the returned color by. Default is 255. (no scaling)
|
||||||
* @returns Single color from palette
|
* @returns Single color from palette
|
||||||
*/
|
*/
|
||||||
uint32_t Segment::color_from_palette(uint16_t i, bool mapping, bool wrap, uint8_t mcol, uint8_t pbri)
|
uint32_t Segment::color_from_palette(uint16_t i, bool mapping, bool wrap, uint8_t mcol, uint8_t pbri) {
|
||||||
{
|
|
||||||
// default palette or no RGB support on segment
|
// default palette or no RGB support on segment
|
||||||
if ((palette == 0 && mcol < NUM_COLORS) || !_isRGB) {
|
if ((palette == 0 && mcol < NUM_COLORS) || !_isRGB) {
|
||||||
uint32_t color = currentColor(mcol);
|
uint32_t color = currentColor(mcol);
|
||||||
@ -1086,8 +1068,6 @@ uint32_t Segment::color_from_palette(uint16_t i, bool mapping, bool wrap, uint8_
|
|||||||
if (!wrap && strip.paletteBlend != 3) paletteIndex = scale8(paletteIndex, 240); //cut off blend at palette "end"
|
if (!wrap && strip.paletteBlend != 3) paletteIndex = scale8(paletteIndex, 240); //cut off blend at palette "end"
|
||||||
CRGBPalette16 curPal;
|
CRGBPalette16 curPal;
|
||||||
curPal = currentPalette(curPal, palette);
|
curPal = currentPalette(curPal, palette);
|
||||||
//if (isInTransition()) curPal = _t->_palT;
|
|
||||||
//else loadPalette(curPal, palette);
|
|
||||||
CRGB fastled_col = ColorFromPalette(curPal, paletteIndex, pbri, (strip.paletteBlend == 3)? NOBLEND:LINEARBLEND); // NOTE: paletteBlend should be global
|
CRGB fastled_col = ColorFromPalette(curPal, paletteIndex, pbri, (strip.paletteBlend == 3)? NOBLEND:LINEARBLEND); // NOTE: paletteBlend should be global
|
||||||
|
|
||||||
return RGBW32(fastled_col.r, fastled_col.g, fastled_col.b, 0);
|
return RGBW32(fastled_col.r, fastled_col.g, fastled_col.b, 0);
|
||||||
@ -1099,8 +1079,7 @@ uint32_t Segment::color_from_palette(uint16_t i, bool mapping, bool wrap, uint8_
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//do not call this method from system context (network callback)
|
//do not call this method from system context (network callback)
|
||||||
void WS2812FX::finalizeInit(void)
|
void WS2812FX::finalizeInit(void) {
|
||||||
{
|
|
||||||
//reset segment runtimes
|
//reset segment runtimes
|
||||||
for (segment &seg : _segments) {
|
for (segment &seg : _segments) {
|
||||||
seg.markForReset();
|
seg.markForReset();
|
||||||
@ -1243,15 +1222,13 @@ void WS2812FX::service() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR WS2812FX::setPixelColor(int i, uint32_t col)
|
void IRAM_ATTR WS2812FX::setPixelColor(int i, uint32_t col) {
|
||||||
{
|
|
||||||
if (i < customMappingSize) i = customMappingTable[i];
|
if (i < customMappingSize) i = customMappingTable[i];
|
||||||
if (i >= _length) return;
|
if (i >= _length) return;
|
||||||
busses.setPixelColor(i, col);
|
busses.setPixelColor(i, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t WS2812FX::getPixelColor(uint16_t i)
|
uint32_t IRAM_ATTR WS2812FX::getPixelColor(uint16_t i) {
|
||||||
{
|
|
||||||
if (i < customMappingSize) i = customMappingTable[i];
|
if (i < customMappingSize) i = customMappingTable[i];
|
||||||
if (i >= _length) return 0;
|
if (i >= _length) return 0;
|
||||||
return busses.getPixelColor(i);
|
return busses.getPixelColor(i);
|
||||||
@ -1442,8 +1419,7 @@ uint8_t WS2812FX::getActiveSegsLightCapabilities(bool selectedOnly) {
|
|||||||
return totalLC;
|
return totalLC;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t WS2812FX::getFirstSelectedSegId(void)
|
uint8_t WS2812FX::getFirstSelectedSegId(void) {
|
||||||
{
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
for (segment &seg : _segments) {
|
for (segment &seg : _segments) {
|
||||||
if (seg.isActive() && seg.isSelected()) return i;
|
if (seg.isActive() && seg.isSelected()) return i;
|
||||||
@ -1567,10 +1543,6 @@ void WS2812FX::setUpSegmentFromQueuedChanges() {
|
|||||||
_queuedChangesSegId = 255;
|
_queuedChangesSegId = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::restartRuntime() {
|
|
||||||
for (segment &seg : _segments) seg.markForReset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WS2812FX::resetSegments() {
|
void WS2812FX::resetSegments() {
|
||||||
_segments.clear(); // destructs all Segment as part of clearing
|
_segments.clear(); // destructs all Segment as part of clearing
|
||||||
#ifndef WLED_DISABLE_2D
|
#ifndef WLED_DISABLE_2D
|
||||||
@ -1714,10 +1686,6 @@ void WS2812FX::setRange(uint16_t i, uint16_t i2, uint32_t col) {
|
|||||||
for (unsigned x = i; x <= i2; x++) setPixelColor(x, col);
|
for (unsigned x = i; x <= i2; x++) setPixelColor(x, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::setTransitionMode(bool t) {
|
|
||||||
for (segment &seg : _segments) seg.startTransition(t ? _transitionDur : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WLED_DEBUG
|
#ifdef WLED_DEBUG
|
||||||
void WS2812FX::printSize() {
|
void WS2812FX::printSize() {
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// version code in format yymmddb (b = daily build)
|
// version code in format yymmddb (b = daily build)
|
||||||
#define VERSION 2310141
|
#define VERSION 2310150
|
||||||
|
|
||||||
//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
|
||||||
|
Loading…
Reference in New Issue
Block a user