FastLED 3.9.15
Loading...
Searching...
No Matches
FxFire2012.ino
Go to the documentation of this file.
1
3// Fire2012 by Mark Kriegsman, July 2012
4// as part of "Five Elements" shown here: http://youtu.be/knWiGsmgycY
6// This basic one-dimensional 'fire' simulation works roughly as follows:
7// There's a underlying array of 'heat' cells, that model the temperature
8// at each point along the line. Every cycle through the simulation,
9// four steps are performed:
10// 1) All cells cool down a little bit, losing heat to the air
11// 2) The heat from each cell drifts 'up' and diffuses a little
12// 3) Sometimes randomly new 'sparks' of heat are added at the bottom
13// 4) The heat from each cell is rendered as a color into the leds array
14// The heat-to-color mapping uses a black-body radiation approximation.
15//
16// Temperature is in arbitrary units from 0 (cold black) to 255 (white hot).
17//
18// This simulation scales it self a bit depending on NUM_LEDS; it should look
19// "OK" on anywhere from 20 to 100 LEDs without too much tweaking.
20//
21// I recommend running this simulation at anywhere from 30-100 frames per second,
22// meaning an interframe delay of about 10-35 milliseconds.
23//
24// Looks best on a high-density LED setup (60+ pixels/meter).
25//
26//
27// There are two main parameters you can play with to control the look and
28// feel of your fire: COOLING (used in step 1 above), and SPARKING (used
29// in step 3 above).
30//
31// COOLING: How much does the air cool as it rises?
32// Less cooling = taller flames. More cooling = shorter flames.
33// Default 50, suggested range 20-100
34
35// SPARKING: What chance (out of 255) is there that a new spark will be lit?
36// Higher chance = more roaring fire. Lower chance = more flickery fire.
37// Default 120, suggested range 50-200.
38
39#include <FastLED.h>
40#include "fx/1d/fire2012.h"
41#include "fl/screenmap.h"
42
43using namespace fl;
44
45#define LED_PIN 5
46#define COLOR_ORDER GRB
47#define CHIPSET WS2811
48#define NUM_LEDS 92
49
50#define BRIGHTNESS 128
51#define FRAMES_PER_SECOND 30
52#define COOLING 55
53#define SPARKING 120
54#define REVERSE_DIRECTION false
55
57Fire2012Ptr fire = Fire2012Ptr::New(NUM_LEDS, COOLING, SPARKING, REVERSE_DIRECTION);
58
59void setup() {
62 .setCorrection(TypicalLEDStrip)
63 .setScreenMap(screenMap)
64 .setRgbw();
65 FastLED.setBrightness(BRIGHTNESS);
66}
67
68void loop()
69{
70 fire->draw(Fx::DrawContext(millis(), leds)); // run simulation frame
71
72 FastLED.show(millis()); // display this frame
73 FastLED.delay(1000 / FRAMES_PER_SECOND);
74}
75
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
#define NUM_LEDS
Definition Apa102.ino:6
#define BRIGHTNESS
Definition Blur.ino:8
#define COLOR_ORDER
#define LED_PIN
#define CHIPSET
#define FRAMES_PER_SECOND
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:58
central include file for FastLED, defines the CFastLED class/object
fl::ScreenMap screenMap
#define COOLING
Definition Fire2012.ino:68
#define SPARKING
Definition Fire2012.ino:73
Fire2012Ptr fire
void setup()
#define REVERSE_DIRECTION
void loop()
_DrawContext DrawContext
Definition fx.h:21
static ScreenMap DefaultStrip(int numLeds, float cm_between_leds=1.5f, float cm_led_diameter=0.2f, float completion=.9f)
Definition screenmap.h:33
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
Definition color.h:19
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:55