Skip to content

Commit 8e7b1c9

Browse files
committed
Merge branch 'fx-upd'
2 parents c9c55fe + 07cc26a commit 8e7b1c9

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

wled00/FX.cpp

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,41 +1964,41 @@ static const char _data_FX_MODE_PALETTE[] PROGMEM = "Palette@Cycle speed;;!;;c3=
19641964
// feel of your fire: COOLING (used in step 1 above) (Speed = COOLING), and SPARKING (used
19651965
// in step 3 above) (Effect Intensity = Sparking).
19661966
uint16_t mode_fire_2012() {
1967-
uint16_t strips = SEGMENT.nrOfVStrips();
1967+
const uint16_t strips = SEGMENT.nrOfVStrips();
19681968
if (!SEGENV.allocateData(strips * SEGLEN)) return mode_static(); //allocation failed
19691969
byte* heat = SEGENV.data;
19701970

1971-
uint32_t it = strip.now >> 5; //div 32
1971+
const uint32_t it = strip.now >> 6; //div 64
19721972

19731973
struct virtualStrip {
19741974
static void runStrip(uint16_t stripNr, byte* heat, uint32_t it) {
19751975

1976-
if (it != SEGENV.step)
1977-
{
1978-
uint8_t ignition = max(3,SEGLEN/10); // ignition area: 10% of segment length or minimum 3 pixels
1979-
1980-
// Step 1. Cool down every cell a little
1981-
for (int i = 0; i < SEGLEN; i++) {
1982-
uint8_t cool = random8((((20 + SEGMENT.speed/3) * 16) / SEGLEN)+2);
1983-
uint8_t minTemp = 0;
1984-
if (i<ignition) {
1985-
//cool /= (ignition-i)/3 + 1; // ignition area cools slower
1986-
minTemp = (ignition-i)/4 + 16; // and should not become black
1987-
}
1988-
uint8_t temp = qsub8(heat[i], cool);
1989-
heat[i] = temp<minTemp ? minTemp : temp;
1976+
const uint8_t ignition = max(3,SEGLEN/10); // ignition area: 10% of segment length or minimum 3 pixels
1977+
1978+
// Step 1. Cool down every cell a little
1979+
for (int i = 0; i < SEGLEN; i++) {
1980+
uint8_t cool = (it != SEGENV.step) ? random8((((20 + SEGMENT.speed/3) * 16) / SEGLEN)+2) : random(8);
1981+
uint8_t minTemp = 0;
1982+
if (i<ignition) {
1983+
minTemp = (ignition-i)/4 + 16; // and should not become black
19901984
}
1985+
uint8_t temp = qsub8(heat[i], cool);
1986+
heat[i] = temp<minTemp ? minTemp : temp;
1987+
}
19911988

1989+
if (it != SEGENV.step)
1990+
{
19921991
// Step 2. Heat from each cell drifts 'up' and diffuses a little
19931992
for (int k = SEGLEN -1; k > 1; k--) {
19941993
heat[k] = (heat[k - 1] + (heat[k - 2]<<1) ) / 3; // heat[k-2] multiplied by 2
19951994
}
1995+
}
19961996

1997-
// Step 3. Randomly ignite new 'sparks' of heat near the bottom
1998-
if (random8() <= SEGMENT.intensity) {
1999-
uint8_t y = random8(ignition);
2000-
heat[y] = qadd8(heat[y], random8(160,255));
2001-
}
1997+
// Step 3. Randomly ignite new 'sparks' of heat near the bottom
1998+
if (random8() <= SEGMENT.intensity) {
1999+
uint8_t y = random8(ignition);
2000+
uint8_t boost = (32+SEGMENT.custom3*2) * (2*ignition-y) / (2*ignition);
2001+
heat[y] = qadd8(heat[y], random8(64+boost,128+boost));
20022002
}
20032003

20042004
// Step 4. Map from heat cells to LED colors
@@ -2011,12 +2011,14 @@ uint16_t mode_fire_2012() {
20112011
for (int stripNr=0; stripNr<strips; stripNr++)
20122012
virtualStrip::runStrip(stripNr, &heat[stripNr * SEGLEN], it);
20132013

2014+
if (SEGMENT.is2D()) SEGMENT.blur(32);
2015+
20142016
if (it != SEGENV.step)
20152017
SEGENV.step = it;
20162018

20172019
return FRAMETIME;
20182020
}
2019-
static const char _data_FX_MODE_FIRE_2012[] PROGMEM = "Fire 2012@Cooling,Spark rate;;!;1;sx=120,ix=64,m12=1"; // bars
2021+
static const char _data_FX_MODE_FIRE_2012[] PROGMEM = "Fire 2012@Cooling,Spark rate,,,Boost;;!;1;sx=120,ix=64,m12=1"; // bars
20202022

20212023

20222024
// ColorWavesWithPalettes by Mark Kriegsman: https://gist.github.com/kriegsman/8281905786e8b2632aeb

0 commit comments

Comments
 (0)