From d56a79e016e4eeb1e995b5f2417f10c58418c16d Mon Sep 17 00:00:00 2001 From: Ewowi Date: Fri, 2 Sep 2022 17:42:47 +0200 Subject: [PATCH 1/7] Drip to virtualStrip --- wled00/FX.cpp | 126 +++++++++++++++++++++++--------------------------- 1 file changed, 59 insertions(+), 67 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index b6069ebb1..497eab819 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -3375,91 +3375,83 @@ static const char _data_FX_MODE_EXPLODING_FIREWORKS[] PROGMEM = "Fireworks 1D@Gr */ uint16_t mode_drip(void) { - const uint16_t cols = strip.isMatrix ? SEGMENT.virtualWidth() : 1; - const uint16_t rows = strip.isMatrix ? SEGMENT.virtualHeight() : SEGMENT.virtualLength(); - //allocate segment data - uint8_t numDrops = 4; - uint16_t dataSize = sizeof(spark) * numDrops; - if (!SEGENV.allocateData(dataSize * cols)) return mode_static(); //allocation failed + uint8_t maxNumDrops = 4; + uint16_t dataSize = sizeof(spark) * maxNumDrops; + if (!SEGENV.allocateData(dataSize * SEGMENT.nrOfVStrips())) return mode_static(); //allocation failed + Spark* drops = reinterpret_cast(SEGENV.data); SEGMENT.fill(SEGCOLOR(1)); - Spark* drops = reinterpret_cast(SEGENV.data); + struct virtualStrip { + static void runStrip(uint16_t stripNr, Spark* drops) { - numDrops = 1 + (SEGMENT.intensity >> 6); // 255>>6 = 3 + uint8_t numDrops = 1 + (SEGMENT.intensity >> 6); // 255>>6 = 3 - float gravity = -0.0005 - (SEGMENT.speed/50000.0); - gravity *= rows-1; - int sourcedrop = 12; + float gravity = -0.0005 - (SEGMENT.speed/50000.0); + gravity *= (SEGLEN*1)-1; + int sourcedrop = 12; - for (int k=0; k < cols; k++) { - for (size_t j=0; j < numDrops; j++) { - uint16_t idx = k*numDrops + j; - - if (drops[idx].colIndex == 0) { //init - drops[idx].pos = rows-1; // start at end - drops[idx].vel = 0; // speed - drops[idx].col = sourcedrop; // brightness - drops[idx].colIndex = 1; // drop state (0 init, 1 forming, 2 falling, 5 bouncing) - } - - uint32_t col = color_blend(BLACK, SEGCOLOR(0), sourcedrop); - if (strip.isMatrix) SEGMENT.setPixelColorXY(k, 0, col); - else SEGMENT.setPixelColor(rows-1, col);// water source - - if (drops[idx].colIndex == 1) { - if (drops[idx].col > 255) drops[idx].col = 255; - col = color_blend(BLACK,SEGCOLOR(0),drops[idx].col); - if (strip.isMatrix) SEGMENT.setPixelColorXY(k, rows - 1 - uint16_t(drops[idx].pos), col); - else SEGMENT.setPixelColor(uint16_t(drops[idx].pos), col); - - drops[idx].col += map(SEGMENT.speed, 0, 255, 1, 6); // swelling - - if (random8() < drops[idx].col/10) { // random drop - drops[idx].colIndex = 2; //fall - drops[idx].col = 255; + for (int j=0;j 1) { // falling - if (drops[idx].pos > 0) { // fall until end of segment - drops[idx].pos += drops[idx].vel; - if (drops[idx].pos < 0) drops[idx].pos = 0; - drops[idx].vel += gravity; // gravity is negative - for (int i = 1; i < 7 - drops[idx].colIndex; i++) { // some minor math so we don't expand bouncing droplets - uint16_t pos = constrain(uint16_t(drops[idx].pos) +i, 0, rows-1); //this is BAD, returns a pos >= SEGLEN occasionally - col = color_blend(BLACK, SEGCOLOR(0), drops[idx].col/i); - if (strip.isMatrix) SEGMENT.setPixelColorXY(k, rows - 1 - pos, col); - else SEGMENT.setPixelColor(pos, col); //spread pixel with fade while falling + SEGMENT.setPixelColor(stripNr, (SEGLEN*1)-1, color_blend(BLACK,SEGCOLOR(0), sourcedrop));// water source + if (drops[j].colIndex==1) { + if (drops[j].col>255) drops[j].col=255; + SEGMENT.setPixelColor(stripNr, uint16_t(drops[j].pos), color_blend(BLACK,SEGCOLOR(0),drops[j].col)); + + drops[j].col += map(SEGMENT.speed, 0, 255, 1, 6); // swelling + + if (random8() < drops[j].col/10) { // random drop + drops[j].colIndex=2; //fall + drops[j].col=255; } + } + if (drops[j].colIndex > 1) { // falling + if (drops[j].pos > 0) { // fall until end of segment + drops[j].pos += drops[j].vel; + if (drops[j].pos < 0) drops[j].pos = 0; + drops[j].vel += gravity; // gravity is negative - if (drops[idx].colIndex > 2) { // during bounce, some water is on the floor - col = color_blend(SEGCOLOR(0), BLACK, drops[idx].col); - if (strip.isMatrix) SEGMENT.setPixelColorXY(k, rows - 1, col); - else SEGMENT.setPixelColor(0, col); - } - } else { // we hit bottom - if (drops[idx].colIndex > 2) { // already hit once, so back to forming - drops[idx].colIndex = 0; - drops[idx].col = sourcedrop; - - } else { + for (int i=1;i<7-drops[j].colIndex;i++) { // some minor math so we don't expand bouncing droplets + uint16_t pos = constrain(uint16_t(drops[j].pos) +i, 0, SEGLEN-1); //this is BAD, returns a pos >= SEGLEN occasionally + SEGMENT.setPixelColor(pos | int((stripNr+1)<<16), color_blend(BLACK,SEGCOLOR(0),drops[j].col/i)); //spread pixel with fade while falling + } - if (drops[idx].colIndex == 2) { // init bounce - drops[idx].vel = -drops[idx].vel/4;// reverse velocity with damping - drops[idx].pos += drops[idx].vel; - } - drops[idx].col = sourcedrop*2; - drops[idx].colIndex = 5; // bouncing + if (drops[j].colIndex > 2) { // during bounce, some water is on the floor + SEGMENT.setPixelColor(0 | int((stripNr+1)<<16), color_blend(SEGCOLOR(0),BLACK,drops[j].col)); + } + } else { // we hit bottom + if (drops[j].colIndex > 2) { // already hit once, so back to forming + drops[j].colIndex = 0; + drops[j].col = sourcedrop; + + } else { + + if (drops[j].colIndex==2) { // init bounce + drops[j].vel = -drops[j].vel/4;// reverse velocity with damping + drops[j].pos += drops[j].vel; + } + drops[j].col = sourcedrop*2; + drops[j].colIndex = 5; // bouncing + } } } } } - } + }; + + for (int stripNr=0; stripNr Date: Fri, 2 Sep 2022 17:55:08 +0200 Subject: [PATCH 2/7] fire_2012 to virtualStrip --- wled00/FX.cpp | 91 ++++++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 497eab819..1dba2016b 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -1966,59 +1966,60 @@ static const char _data_FX_MODE_PALETTE[] PROGMEM = "Palette@Cycle speed,;1,2,3; // in step 3 above) (Effect Intensity = Sparking). uint16_t mode_fire_2012() { - const uint16_t cols = strip.isMatrix ? SEGMENT.virtualWidth() : 1; - const uint16_t rows = strip.isMatrix ? SEGMENT.virtualHeight() : SEGMENT.virtualLength(); - - uint32_t it = strip.now >> 5; //div 32 - //uint16_t q = cols>>2; // a quarter of flames - - if (!SEGENV.allocateData(cols*rows)) return mode_static(); //allocation failed - + if (!SEGENV.allocateData(SEGMENT.nrOfVStrips()*SEGLEN)) return mode_static(); //allocation failed byte* heat = SEGENV.data; - if (it != SEGENV.step) { - SEGENV.step = it; - uint8_t ignition = max(3,rows/10); // ignition area: 10% of segment length or minimum 3 pixels + uint32_t it = strip.now >> 5; //div 32 - for (int f = 0; f < cols; f++) { - // Step 1. Cool down every cell a little - for (int i = 0; i < rows; i++) { - uint8_t cool = (((20 + SEGMENT.speed/3) * 16) / rows); - /* - // 2D enhancement: cool sides of the flame a bit more - if (cols>5) { - if (f < q) cool = qadd8(cool, 2*(uint16_t)((cool * (q-f))/cols)); // cool segment sides a bit more - if (f > 3*q) cool = qadd8(cool, 2*(uint16_t)((cool * (cols-f))/cols)); // cool segment sides a bit more + struct virtualStrip { + static void runStrip(uint16_t stripNr, byte* heat, uint32_t it) { + + if (it != SEGENV.step) + { + uint8_t ignition = max(3,SEGLEN/10); // ignition area: 10% of segment length or minimum 3 pixels + + // Step 1. Cool down every cell a little + for (int i = 0; i < SEGLEN; i++) { + uint8_t cool = (((20 + SEGMENT.speed/3) * 16) / SEGLEN); + /* + // 2D enhancement: cool sides of the flame a bit more + if (cols>5) { + if (f < q) cool = qadd8(cool, 2*(uint16_t)((cool * (q-f))/cols)); // cool segment sides a bit more + if (f > 3*q) cool = qadd8(cool, 2*(uint16_t)((cool * (cols-f))/cols)); // cool segment sides a bit more + } + */ + uint8_t temp = qsub8(heat[i], random8(0, cool + 2)); + heat[i] = (temp==0 && i 1; k--) { + heat[k] = (heat[k - 1] + (heat[k - 2]<<1) ) / 3; // heat[k-2] multiplied by 2 + } + + // Step 3. Randomly ignite new 'sparks' of heat near the bottom + if (random8() <= SEGMENT.intensity) { + uint8_t y = random8(ignition); + heat[y] = qadd8(heat[y], random8(160,255)); } - */ - uint8_t temp = qsub8(heat[i+rows*f], random8(0, cool + 2)); - heat[i+rows*f] = (temp==0 && i 1; k--) { - heat[k+rows*f] = (heat[k+rows*f - 1] + (heat[k+rows*f - 2]<<1) ) / 3; // heat[k-2] multiplied by 2 - } - - // Step 3. Randomly ignite new 'sparks' of heat near the bottom - if (random8() <= SEGMENT.intensity) { - uint8_t y = random8(ignition); - heat[y+rows*f] = qadd8(heat[y+rows*f], random8(160,255)); + // Step 4. Map from heat cells to LED colors + for (int j = 0; j < SEGLEN; j++) { + SEGMENT.setPixelColor(j | int((stripNr+1)<<16), ColorFromPalette(SEGPALETTE, /*MIN(*/heat[j]/*,240)*/, 255, LINEARBLEND)); } } - } + }; + + for (int stripNr=0; stripNr> 6); // 255>>6 = 3 float gravity = -0.0005 - (SEGMENT.speed/50000.0); - gravity *= (SEGLEN*1)-1; + gravity *= SEGLEN-1; int sourcedrop = 12; for (int j=0;j255) drops[j].col=255; SEGMENT.setPixelColor(stripNr, uint16_t(drops[j].pos), color_blend(BLACK,SEGCOLOR(0),drops[j].col)); From e29be737f7f5a966ddac5b00bc4544dadce60769 Mon Sep 17 00:00:00 2001 From: Ewowi Date: Fri, 2 Sep 2022 18:14:28 +0200 Subject: [PATCH 3/7] Drip to virtualstrip correction --- wled00/FX.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 1dba2016b..e0e9665a2 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -3401,10 +3401,10 @@ uint16_t mode_drip(void) drops[j].colIndex = 1; // drop state (0 init, 1 forming, 2 falling, 5 bouncing) } - SEGMENT.setPixelColor(stripNr, SEGLEN-1, color_blend(BLACK,SEGCOLOR(0), sourcedrop));// water source + SEGMENT.setPixelColor((SEGLEN-1) | int((stripNr+1)<<16), color_blend(BLACK,SEGCOLOR(0), sourcedrop));// water source if (drops[j].colIndex==1) { if (drops[j].col>255) drops[j].col=255; - SEGMENT.setPixelColor(stripNr, uint16_t(drops[j].pos), color_blend(BLACK,SEGCOLOR(0),drops[j].col)); + SEGMENT.setPixelColor(uint16_t(drops[j].pos) | int((stripNr+1)<<16), color_blend(BLACK,SEGCOLOR(0),drops[j].col)); drops[j].col += map(SEGMENT.speed, 0, 255, 1, 6); // swelling From 9e23d52193ba6cf1d22845e5dac52e8e818d485f Mon Sep 17 00:00:00 2001 From: Ewowi Date: Fri, 2 Sep 2022 18:30:23 +0200 Subject: [PATCH 4/7] Popcorn to virtualStrip --- wled00/FX.cpp | 85 +++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index e0e9665a2..63faaadc0 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -2943,68 +2943,67 @@ typedef struct Spark { uint8_t colIndex; } spark; +#define maxNumPopcorn 21 // max 21 on 16 segment ESP8266 /* * POPCORN * modified from https://github.com/kitesurfer1404/WS2812FX/blob/master/src/custom/Popcorn.h */ uint16_t mode_popcorn(void) { - const uint16_t cols = strip.isMatrix ? SEGMENT.virtualWidth() : 1; - const uint16_t rows = strip.isMatrix ? SEGMENT.virtualHeight() : SEGMENT.virtualLength(); - //allocate segment data - uint16_t maxNumPopcorn = 21; // max 21 on 16 segment ESP8266 uint16_t dataSize = sizeof(spark) * maxNumPopcorn; - if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed - - Spark* popcorn = reinterpret_cast(SEGENV.data); + if (!SEGENV.allocateData(dataSize * SEGMENT.nrOfVStrips())) return mode_static(); //allocation failed - float gravity = -0.0001 - (SEGMENT.speed/200000.0); // m/s/s - gravity *= rows; //SEGLEN + Spark* popcorn = reinterpret_cast(SEGENV.data); bool hasCol2 = SEGCOLOR(2); SEGMENT.fill(hasCol2 ? BLACK : SEGCOLOR(1)); - uint8_t numPopcorn = SEGMENT.intensity*maxNumPopcorn/255; - if (numPopcorn == 0) numPopcorn = 1; + struct virtualStrip { + static void runStrip(uint16_t stripNr, Spark* popcorn) { + float gravity = -0.0001 - (SEGMENT.speed/200000.0); // m/s/s + gravity *= SEGLEN; - for (int i = 0; i < numPopcorn; i++) { - if (popcorn[i].pos >= 0.0f) { // if kernel is active, update its position - popcorn[i].pos += popcorn[i].vel; - popcorn[i].vel += gravity; - } else { // if kernel is inactive, randomly pop it - if (random8() < 2) { // POP!!! - popcorn[i].pos = 0.01f; - popcorn[i].posX = random16(cols); - - uint16_t peakHeight = 128 + random8(128); //0-255 - peakHeight = (peakHeight * (rows -1)) >> 8; - popcorn[i].vel = sqrt(-2.0 * gravity * peakHeight); - popcorn[i].velX = 0; - - if (SEGMENT.palette) { - popcorn[i].colIndex = random8(); - } else { - byte col = random8(0, NUM_COLORS); - if (!hasCol2 || !SEGCOLOR(col)) col = 0; - popcorn[i].colIndex = col; + uint8_t numPopcorn = SEGMENT.intensity*maxNumPopcorn/255; + if (numPopcorn == 0) numPopcorn = 1; + + for(int i = 0; i < numPopcorn; i++) { + if (popcorn[i].pos >= 0.0f) { // if kernel is active, update its position + popcorn[i].pos += popcorn[i].vel; + popcorn[i].vel += gravity; + } else { // if kernel is inactive, randomly pop it + if (random8() < 2) { // POP!!! + popcorn[i].pos = 0.01f; + + uint16_t peakHeight = 128 + random8(128); //0-255 + peakHeight = (peakHeight * (SEGLEN -1)) >> 8; + popcorn[i].vel = sqrt(-2.0 * gravity * peakHeight); + + if (SEGMENT.palette) + { + popcorn[i].colIndex = random8(); + } else { + byte col = random8(0, NUM_COLORS); + if (!SEGCOLOR(2) || !SEGCOLOR(col)) col = 0; + popcorn[i].colIndex = col; + } + } + } + if (popcorn[i].pos >= 0.0f) { // draw now active popcorn (either active before or just popped) + uint32_t col = SEGMENT.color_wheel(popcorn[i].colIndex); + if (!SEGMENT.palette && popcorn[i].colIndex < NUM_COLORS) col = SEGCOLOR(popcorn[i].colIndex); + uint16_t ledIndex = popcorn[i].pos; + if (ledIndex < SEGLEN) SEGMENT.setPixelColor(ledIndex | int((stripNr+1)<<16), col); } } } - if (popcorn[i].pos >= 0.0f) { // draw now active popcorn (either active before or just popped) - uint32_t col = SEGMENT.color_wheel(popcorn[i].colIndex); - if (!SEGMENT.palette && popcorn[i].colIndex < NUM_COLORS) col = SEGCOLOR(popcorn[i].colIndex); - - uint16_t ledIndex = popcorn[i].pos; - if (ledIndex < rows) { - if (strip.isMatrix) SEGMENT.setPixelColorXY(uint16_t(popcorn[i].posX), rows - 1 - ledIndex, col); - else SEGMENT.setPixelColor(ledIndex, col); - } - } - } + }; + + for (int stripNr=0; stripNr Date: Fri, 2 Sep 2022 20:52:20 +0200 Subject: [PATCH 5/7] VirtualStrip: use indexToVStrip --- wled00/FX.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 63faaadc0..055af4ff4 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -30,6 +30,7 @@ #define IBN 5100 #define PALETTE_SOLID_WRAP (strip.paletteBlend == 1 || strip.paletteBlend == 3) +#define indexToVStrip(index, stripNr) (index) | int((stripNr+1)<<16) // effect utility functions uint8_t sin_gap(uint16_t in) { @@ -2006,7 +2007,7 @@ uint16_t mode_fire_2012() // Step 4. Map from heat cells to LED colors for (int j = 0; j < SEGLEN; j++) { - SEGMENT.setPixelColor(j | int((stripNr+1)<<16), ColorFromPalette(SEGPALETTE, /*MIN(*/heat[j]/*,240)*/, 255, LINEARBLEND)); + SEGMENT.setPixelColor(indexToVStrip(j, stripNr), ColorFromPalette(SEGPALETTE, /*MIN(*/heat[j]/*,240)*/, 255, LINEARBLEND)); } } }; @@ -2850,7 +2851,7 @@ uint16_t mode_bouncing_balls(void) { } int pos = roundf(balls[i].height * (SEGLEN - 1)); - if (SEGLEN<32) SEGMENT.setPixelColor(pos | int((stripNr+1)<<16), color); // encode virtual strip into index + if (SEGLEN<32) SEGMENT.setPixelColor(indexToVStrip(pos, stripNr), color); // encode virtual strip into index else SEGMENT.setPixelColor(balls[i].height + (stripNr+1)*10.0f, color); } } @@ -2992,7 +2993,7 @@ uint16_t mode_popcorn(void) { uint32_t col = SEGMENT.color_wheel(popcorn[i].colIndex); if (!SEGMENT.palette && popcorn[i].colIndex < NUM_COLORS) col = SEGCOLOR(popcorn[i].colIndex); uint16_t ledIndex = popcorn[i].pos; - if (ledIndex < SEGLEN) SEGMENT.setPixelColor(ledIndex | int((stripNr+1)<<16), col); + if (ledIndex < SEGLEN) SEGMENT.setPixelColor(indexToVStrip(ledIndex, stripNr), col); } } } @@ -3400,10 +3401,10 @@ uint16_t mode_drip(void) drops[j].colIndex = 1; // drop state (0 init, 1 forming, 2 falling, 5 bouncing) } - SEGMENT.setPixelColor((SEGLEN-1) | int((stripNr+1)<<16), color_blend(BLACK,SEGCOLOR(0), sourcedrop));// water source + SEGMENT.setPixelColor(indexToVStrip(SEGLEN-1, stripNr), color_blend(BLACK,SEGCOLOR(0), sourcedrop));// water source if (drops[j].colIndex==1) { if (drops[j].col>255) drops[j].col=255; - SEGMENT.setPixelColor(uint16_t(drops[j].pos) | int((stripNr+1)<<16), color_blend(BLACK,SEGCOLOR(0),drops[j].col)); + SEGMENT.setPixelColor(indexToVStrip(uint16_t(drops[j].pos), stripNr), color_blend(BLACK,SEGCOLOR(0),drops[j].col)); drops[j].col += map(SEGMENT.speed, 0, 255, 1, 6); // swelling @@ -3420,11 +3421,11 @@ uint16_t mode_drip(void) for (int i=1;i<7-drops[j].colIndex;i++) { // some minor math so we don't expand bouncing droplets uint16_t pos = constrain(uint16_t(drops[j].pos) +i, 0, SEGLEN-1); //this is BAD, returns a pos >= SEGLEN occasionally - SEGMENT.setPixelColor(pos | int((stripNr+1)<<16), color_blend(BLACK,SEGCOLOR(0),drops[j].col/i)); //spread pixel with fade while falling + SEGMENT.setPixelColor(indexToVStrip(pos, stripNr), color_blend(BLACK,SEGCOLOR(0),drops[j].col/i)); //spread pixel with fade while falling } if (drops[j].colIndex > 2) { // during bounce, some water is on the floor - SEGMENT.setPixelColor(0 | int((stripNr+1)<<16), color_blend(SEGCOLOR(0),BLACK,drops[j].col)); + SEGMENT.setPixelColor(indexToVStrip(0, stripNr), color_blend(SEGCOLOR(0),BLACK,drops[j].col)); } } else { // we hit bottom if (drops[j].colIndex > 2) { // already hit once, so back to forming @@ -3485,7 +3486,7 @@ uint16_t mode_tetrix(void) { if (SEGENV.call == 0) { drop->stack = 0; // reset brick stack size drop->step = 0; - //for (int i=0; istep == 0) { // init brick @@ -3513,7 +3514,7 @@ uint16_t mode_tetrix(void) { if (uint16_t(drop->pos) < drop->stack) drop->pos = drop->stack; for (int i=int(drop->pos); ipos)+drop->brick ? SEGMENT.color_from_palette(drop->col, false, false, 0) : SEGCOLOR(1); - SEGMENT.setPixelColor(i | int((stripNr+1)<<16), col); + SEGMENT.setPixelColor(indexToVStrip(i, stripNr), col); } } else { // we hit bottom drop->step = 0; // proceed with next brick, go back to init @@ -3526,7 +3527,7 @@ uint16_t mode_tetrix(void) { drop->brick = 0; // reset brick size (no more growing) if (drop->step > millis()) { // allow fading of virtual strip - for (int i=0; istack = 0; // reset brick stack size drop->step = 0; // proceed with next brick From c4a261f2d2a3c5aff92839812784f62ab7d1d3bf Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Fri, 2 Sep 2022 21:21:53 +0200 Subject: [PATCH 6/7] Minor tweaks. --- wled00/FX.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 055af4ff4..6558ff17f 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -30,7 +30,7 @@ #define IBN 5100 #define PALETTE_SOLID_WRAP (strip.paletteBlend == 1 || strip.paletteBlend == 3) -#define indexToVStrip(index, stripNr) (index) | int((stripNr+1)<<16) +#define indexToVStrip(index, stripNr) ((index) | (int((stripNr)+1)<<16)) // effect utility functions uint8_t sin_gap(uint16_t in) { @@ -1967,7 +1967,8 @@ static const char _data_FX_MODE_PALETTE[] PROGMEM = "Palette@Cycle speed,;1,2,3; // in step 3 above) (Effect Intensity = Sparking). uint16_t mode_fire_2012() { - if (!SEGENV.allocateData(SEGMENT.nrOfVStrips()*SEGLEN)) return mode_static(); //allocation failed + uint16_t strips = SEGMENT.nrOfVStrips(); + if (!SEGENV.allocateData(strips * SEGLEN)) return mode_static(); //allocation failed byte* heat = SEGENV.data; uint32_t it = strip.now >> 5; //div 32 @@ -1982,13 +1983,6 @@ uint16_t mode_fire_2012() // Step 1. Cool down every cell a little for (int i = 0; i < SEGLEN; i++) { uint8_t cool = (((20 + SEGMENT.speed/3) * 16) / SEGLEN); - /* - // 2D enhancement: cool sides of the flame a bit more - if (cols>5) { - if (f < q) cool = qadd8(cool, 2*(uint16_t)((cool * (q-f))/cols)); // cool segment sides a bit more - if (f > 3*q) cool = qadd8(cool, 2*(uint16_t)((cool * (cols-f))/cols)); // cool segment sides a bit more - } - */ uint8_t temp = qsub8(heat[i], random8(0, cool + 2)); heat[i] = (temp==0 && i(SEGENV.data); @@ -2999,7 +2994,7 @@ uint16_t mode_popcorn(void) { } }; - for (int stripNr=0; stripNr