mirror of
https://github.com/wled/WLED.git
synced 2025-07-22 18:26:32 +00:00
2D Haloween eyes
Misc fix.
This commit is contained in:
parent
4963a5797b
commit
4484721a9f
@ -2506,6 +2506,7 @@ uint16_t WS2812FX::mode_halloween_eyes()
|
|||||||
if (state == 0) { //spawn eyes
|
if (state == 0) { //spawn eyes
|
||||||
SEGENV.aux0 = random16(0, SEGLEN - eyeLength); //start pos
|
SEGENV.aux0 = random16(0, SEGLEN - eyeLength); //start pos
|
||||||
SEGENV.aux1 = random8(); //color
|
SEGENV.aux1 = random8(); //color
|
||||||
|
if (isMatrix) SEGMENT.offset = random16(SEGMENT.virtualHeight()-1); // a hack: reuse offset since it is not used in matrices
|
||||||
state = 1;
|
state = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2517,20 +2518,22 @@ uint16_t WS2812FX::mode_halloween_eyes()
|
|||||||
if (fadestage > 255) fadestage = 255;
|
if (fadestage > 255) fadestage = 255;
|
||||||
uint32_t c = color_blend(color_from_palette(SEGENV.aux1 & 0xFF, false, false, 0), SEGCOLOR(1), fadestage);
|
uint32_t c = color_blend(color_from_palette(SEGENV.aux1 & 0xFF, false, false, 0), SEGCOLOR(1), fadestage);
|
||||||
|
|
||||||
for (uint16_t i = 0; i < HALLOWEEN_EYE_WIDTH; i++)
|
for (uint16_t i = 0; i < HALLOWEEN_EYE_WIDTH; i++) {
|
||||||
{
|
if (isMatrix) {
|
||||||
setPixelColor(startPos + i, c);
|
setPixelColorXY(startPos + i, SEGMENT.offset, c);
|
||||||
setPixelColor(start2ndEye + i, c);
|
setPixelColorXY(start2ndEye + i, SEGMENT.offset, c);
|
||||||
|
} else {
|
||||||
|
setPixelColor(startPos + i, c);
|
||||||
|
setPixelColor(start2ndEye + i, c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (now - SEGENV.step > stateTime)
|
if (now - SEGENV.step > stateTime) {
|
||||||
{
|
|
||||||
state++;
|
state++;
|
||||||
if (state > 2) state = 0;
|
if (state > 2) state = 0;
|
||||||
|
|
||||||
if (state < 2)
|
if (state < 2) {
|
||||||
{
|
|
||||||
stateTime = 100 + (255 - SEGMENT.intensity)*10; //eye fade time
|
stateTime = 100 + (255 - SEGMENT.intensity)*10; //eye fade time
|
||||||
} else {
|
} else {
|
||||||
uint16_t eyeOffTimeBase = (255 - SEGMENT.speed)*10;
|
uint16_t eyeOffTimeBase = (255 - SEGMENT.speed)*10;
|
||||||
|
@ -330,19 +330,19 @@ class WS2812FX {
|
|||||||
uint16_t virtualWidth() {
|
uint16_t virtualWidth() {
|
||||||
uint16_t groupLen = groupLength();
|
uint16_t groupLen = groupLength();
|
||||||
uint16_t vWidth = (width() + groupLen - 1) / groupLen;
|
uint16_t vWidth = (width() + groupLen - 1) / groupLen;
|
||||||
if (options & MIRROR) vWidth = (vWidth + 1) /2; // divide by 2 if mirror, leave at least a single LED
|
if (getOption(SEG_OPTION_MIRROR)) vWidth = (vWidth + 1) /2; // divide by 2 if mirror, leave at least a single LED
|
||||||
return vWidth;
|
return vWidth;
|
||||||
}
|
}
|
||||||
uint16_t virtualHeight() {
|
uint16_t virtualHeight() {
|
||||||
uint16_t groupLen = groupLength();
|
uint16_t groupLen = groupLength();
|
||||||
uint16_t vHeight = (height() + groupLen - 1) / groupLen;
|
uint16_t vHeight = (height() + groupLen - 1) / groupLen;
|
||||||
if (options & MIRROR_Y_2D) vHeight = (vHeight + 1) /2; // divide by 2 if mirror, leave at least a single LED
|
if (getOption(SEG_OPTION_MIRROR_Y)) vHeight = (vHeight + 1) /2; // divide by 2 if mirror, leave at least a single LED
|
||||||
return vHeight;
|
return vHeight;
|
||||||
}
|
}
|
||||||
uint16_t virtualLength() {
|
uint16_t virtualLength() {
|
||||||
uint16_t groupLen = groupLength();
|
uint16_t groupLen = groupLength();
|
||||||
uint16_t vLength = (length() + groupLen - 1) / groupLen;
|
uint16_t vLength = (length() + groupLen - 1) / groupLen;
|
||||||
if (options & MIRROR) vLength = (vLength + 1) /2; // divide by 2 if mirror, leave at least a single LED
|
if (getOption(SEG_OPTION_MIRROR)) vLength = (vLength + 1) /2; // divide by 2 if mirror, leave at least a single LED
|
||||||
return vLength;
|
return vLength;
|
||||||
}
|
}
|
||||||
uint8_t differs(Segment& b);
|
uint8_t differs(Segment& b);
|
||||||
@ -879,6 +879,7 @@ class WS2812FX {
|
|||||||
void
|
void
|
||||||
setUpMatrix(),
|
setUpMatrix(),
|
||||||
setPixelColorXY(uint16_t x, uint16_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0),
|
setPixelColorXY(uint16_t x, uint16_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0),
|
||||||
|
blendPixelColorXY(uint16_t x, uint16_t y, uint32_t color, uint8_t blend),
|
||||||
blur1d(CRGB* leds, fract8 blur_amount),
|
blur1d(CRGB* leds, fract8 blur_amount),
|
||||||
blur2d(CRGB* leds, fract8 blur_amount),
|
blur2d(CRGB* leds, fract8 blur_amount),
|
||||||
blurRow(uint16_t row, fract8 blur_amount, CRGB* leds=nullptr),
|
blurRow(uint16_t row, fract8 blur_amount, CRGB* leds=nullptr),
|
||||||
|
@ -187,8 +187,14 @@ uint32_t WS2812FX::getPixelColorXY(uint16_t x, uint16_t y) {
|
|||||||
return busses.getPixelColor(index);
|
return busses.getPixelColor(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Blends the specified color with the existing pixel color.
|
||||||
|
*/
|
||||||
|
void WS2812FX::blendPixelColorXY(uint16_t x, uint16_t y, uint32_t color, uint8_t blend) {
|
||||||
|
setPixelColorXY(x, y, color_blend(getPixelColorXY(x,y), color, blend));
|
||||||
|
}
|
||||||
|
|
||||||
// blurRows: perform a blur1d on every row of a rectangular matrix
|
// blurRow: perform a blur on a row of a rectangular matrix
|
||||||
void WS2812FX::blurRow(uint16_t row, fract8 blur_amount, CRGB* leds) {
|
void WS2812FX::blurRow(uint16_t row, fract8 blur_amount, CRGB* leds) {
|
||||||
uint16_t width = SEGMENT.virtualWidth();
|
uint16_t width = SEGMENT.virtualWidth();
|
||||||
uint16_t height = SEGMENT.virtualHeight();
|
uint16_t height = SEGMENT.virtualHeight();
|
||||||
@ -209,9 +215,8 @@ void WS2812FX::blurRow(uint16_t row, fract8 blur_amount, CRGB* leds) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// blurColumns: perform a blur1d on each column of a rectangular matrix
|
// blurCol: perform a blur on a column of a rectangular matrix
|
||||||
void WS2812FX::blurCol(uint16_t col, fract8 blur_amount, CRGB* leds)
|
void WS2812FX::blurCol(uint16_t col, fract8 blur_amount, CRGB* leds) {
|
||||||
{
|
|
||||||
uint16_t width = SEGMENT.virtualWidth();
|
uint16_t width = SEGMENT.virtualWidth();
|
||||||
uint16_t height = SEGMENT.virtualHeight();
|
uint16_t height = SEGMENT.virtualHeight();
|
||||||
if (col >= width) return;
|
if (col >= width) return;
|
||||||
|
@ -1367,7 +1367,7 @@ const char JSON_mode_names[] PROGMEM = R"=====([
|
|||||||
"Two Dots@!,Dot size;1,2,Bg;!",
|
"Two Dots@!,Dot size;1,2,Bg;!",
|
||||||
"Fairy Twinkle",
|
"Fairy Twinkle",
|
||||||
"Running Dual",
|
"Running Dual",
|
||||||
"Halloween",
|
"Halloween@Duration,Eye fade time;Fx,Bg,;!",
|
||||||
"Chase 3@!,Size;1,2,3;0",
|
"Chase 3@!,Size;1,2,3;0",
|
||||||
"Tri Wipe@!,Width;1,2,3;0",
|
"Tri Wipe@!,Width;1,2,3;0",
|
||||||
"Tri Fade",
|
"Tri Fade",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user