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