ajout de fire
This commit is contained in:
parent
4e0c1ff950
commit
606a442777
@ -340,8 +340,47 @@ void colorTemp()
|
|||||||
FastLED.show();
|
FastLED.show();
|
||||||
FastLED.delay(8);
|
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() {
|
void loop() {
|
||||||
// MQTT
|
// MQTT
|
||||||
testConnectMQTT();
|
testConnectMQTT();
|
||||||
@ -359,6 +398,8 @@ void loop() {
|
|||||||
ledColorPattern();
|
ledColorPattern();
|
||||||
} else if (ledEffect == LED_EFFECT_COLORTEMP) {
|
} else if (ledEffect == LED_EFFECT_COLORTEMP) {
|
||||||
colorTemp();
|
colorTemp();
|
||||||
|
} else if (ledEffect == LED_EFFECT_FIRE) {
|
||||||
|
fire();
|
||||||
} else {
|
} else {
|
||||||
ledError();
|
ledError();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,9 @@ input_select:
|
|||||||
options:
|
options:
|
||||||
- "cylon"
|
- "cylon"
|
||||||
- "full"
|
- "full"
|
||||||
|
- "colorp"
|
||||||
|
- "colort"
|
||||||
|
- "fire"
|
||||||
- "error"
|
- "error"
|
||||||
|
|
||||||
input_slider:
|
input_slider:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user