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