ajout de fire

This commit is contained in:
Julien Cabillot 2017-03-10 11:22:03 +01:00 committed by Cabillot Julien
parent 4e0c1ff950
commit 606a442777
2 changed files with 45 additions and 1 deletions

View File

@ -340,8 +340,47 @@ void colorTemp()
FastLED.show();
FastLED.delay(8);
}
////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////Fire202
void fire()
{
// Array of temperature readings at each simulation cell
static byte heat[LED_NUM];
// Step 1. Cool down every cell a little
for( int i = 0; i < LED_NUM; i++) {
heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / LED_NUM) + 2));
}
// Step 2. Heat from each cell drifts 'up' and diffuses a little
for( int k= LED_NUM - 1; k >= 2; k--) {
heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
}
// Step 3. Randomly ignite new 'sparks' of heat near the bottom
if( random8() < SPARKING ) {
int y = random8(7);
heat[y] = qadd8( heat[y], random8(160,255) );
}
// Step 4. Map from heat cells to LED colors
for( int j = 0; j < LED_NUM; j++) {
CRGB color = HeatColor( heat[j]);
int pixelnumber;
if( gReverseDirection ) {
pixelnumber = (LED_NUM - 1) - j;
} else {
pixelnumber = j;
}
leds[pixelnumber] = color;
}
FastLED.delay(1000 / speed);
}
/////////////////////////////////////////////
void loop() {
// MQTT
testConnectMQTT();
@ -359,6 +398,8 @@ void loop() {
ledColorPattern();
} else if (ledEffect == LED_EFFECT_COLORTEMP) {
colorTemp();
} else if (ledEffect == LED_EFFECT_FIRE) {
fire();
} else {
ledError();
}

View File

@ -11,6 +11,9 @@ input_select:
options:
- "cylon"
- "full"
- "colorp"
- "colort"
- "fire"
- "error"
input_slider: