Enhance API
- addPixelColorXY() - fadeToBlackBy()
This commit is contained in:
parent
5d12e2291c
commit
d2705f033d
@ -5067,7 +5067,7 @@ uint16_t WS2812FX::mode_2DLissajous(void) { // By: Andrew Tuline
|
||||
const uint16_t cols = SEGMENT.virtualWidth();
|
||||
const uint16_t rows = SEGMENT.virtualHeight();
|
||||
|
||||
fadeToBlackBy(nullptr, SEGMENT.intensity);
|
||||
fadeToBlackBy(SEGMENT.intensity);
|
||||
//fade_out(SEGMENT.intensity);
|
||||
|
||||
//for (int i=0; i < 4*(cols+rows); i ++) {
|
||||
|
@ -1097,6 +1097,7 @@ class WS2812FX {
|
||||
setPixelColorXY(uint16_t x, uint16_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0),
|
||||
setPixelColorXY(float x, float y, byte r, byte g, byte b, byte w = 0, bool aa = false),
|
||||
blendPixelColorXY(uint16_t x, uint16_t y, uint32_t color, uint8_t blend),
|
||||
addPixelColorXY(uint16_t x, uint16_t y, uint32_t color),
|
||||
blur1d(CRGB* leds, fract8 blur_amount),
|
||||
blur1d(uint16_t i, bool vertical, fract8 blur_amount, CRGB* leds=nullptr), // 1D box blur (with weight)
|
||||
blur2d(CRGB* leds, fract8 blur_amount),
|
||||
|
@ -274,6 +274,13 @@ void WS2812FX::blendPixelColorXY(uint16_t x, uint16_t y, uint32_t color, uint8_t
|
||||
setPixelColorXY(x, y, color_blend(getPixelColorXY(x,y), color, blend));
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds the specified color with the existing pixel color perserving color balance.
|
||||
*/
|
||||
void WS2812FX::addPixelColorXY(uint16_t x, uint16_t y, uint32_t color) {
|
||||
setPixelColorXY(x, y, color_add(getPixelColorXY(x,y), color));
|
||||
}
|
||||
|
||||
// blurRow: perform a blur on a row of a rectangular matrix
|
||||
void WS2812FX::blurRow(uint16_t row, fract8 blur_amount, CRGB* leds) {
|
||||
const uint16_t cols = SEGMENT.virtualWidth();
|
||||
|
@ -968,7 +968,7 @@ void WS2812FX::fade_out(uint8_t rate) {
|
||||
int g2 = G(color);
|
||||
int b2 = B(color);
|
||||
|
||||
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++) {
|
||||
color = isMatrix ? getPixelColorXY(x, y) : getPixelColor(x);
|
||||
int w1 = W(color);
|
||||
int r1 = R(color);
|
||||
@ -993,8 +993,12 @@ void WS2812FX::fade_out(uint8_t rate) {
|
||||
|
||||
// fades all pixels to black using nscale8()
|
||||
void WS2812FX::fadeToBlackBy(uint8_t fadeBy) {
|
||||
for (uint16_t i = 0; i < SEGLEN; i++) {
|
||||
setPixelColor(i, col_to_crgb(getPixelColor(i)).nscale8(255-fadeBy));
|
||||
const uint16_t cols = isMatrix ? SEGMENT.virtualWidth() : SEGMENT.virtualLength();
|
||||
const uint16_t rows = SEGMENT.virtualHeight(); // will be 1 for 1D
|
||||
|
||||
for (uint16_t y = 0; y < rows; y++) for (uint16_t x = 0; x < cols; x++) {
|
||||
if (isMatrix) setPixelColorXY(x, y, col_to_crgb(getPixelColorXY(x,y)).nscale8(255-fadeBy));
|
||||
else setPixelColor(x, col_to_crgb(getPixelColor(x)).nscale8(255-fadeBy));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user