FastLED - Fire2012 Compiling Issue

Hi.

I trying to learn the FastLED library and I’ve copied the Fire2012 code example to play with.
I’ve installed the FastLED library and not touched the code, but it won’t compile for me at all. I’ve seen other posts that people aren’t installing the libraries correctly, but I’ve tried replacing them following the libraries guide but no luck.

Here’s the code: (or look here: Fire2012: an Arduino/LED fire simulation for FastLED - Pastebin.com)

#include <bitswap.h>
#include <chipsets.h>
#include <color.h>
#include <colorpalettes.h>
#include <colorutils.h>
#include <controller.h>
#include <cpp_compat.h>
#include <dmx.h>
#include <FastLED.h>
#include <fastled_config.h>
#include <fastled_delay.h>
#include <fastled_progmem.h>
#include <fastpin.h>
#include <fastspi.h>
#include <fastspi_bitbang.h>
#include <fastspi_dma.h>
#include <fastspi_nop.h>
#include <fastspi_ref.h>
#include <fastspi_types.h>
#include <hsv2rgb.h>
#include <led_sysdefs.h>
#include <lib8tion.h>
#include <noise.h>
#include <pixelset.h>
#include <pixeltypes.h>
#include <platforms.h>
#include <power_mgt.h>




// Fire2012: a basic fire simulation for a one-dimensional string of LEDs
// Mark Kriegsman, July 2012.
//
// Compiled size for Arduino/AVR is about 3,968 bytes.
 
#include <FastLED.h>
 
#define LED_PIN     5
#define COLOR_ORDER GRB
#define CHIPSET     WS2811
#define NUM_LEDS    50
 
#define BRIGHTNESS  200
#define FRAMES_PER_SECOND 60
 
CRGB leds[NUM_LEDS];



void setup() {
  delay(3000); // sanity delay
FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.setBrightness( BRIGHTNESS );
}
 
void loop()
{
  // Add entropy to random number generator; we use a lot of it.
  random16_add_entropy( random());
 
  Fire2012(); // run simulation frame
  FastLED.show(); // display this frame
 
#if defined(FASTLED_VERSION) && (FASTLED_VERSION >= 2001000)
  FastLED.delay(1000 / FRAMES_PER_SECOND);
#else  
  delay(1000 / FRAMES_PER_SECOND);
#endif  
}
 
 
// Fire2012 by Mark Kriegsman, July 2012
// as part of "Five Elements" shown here: http://youtu.be/knWiGsmgycY
//
// This basic one-dimensional 'fire' simulation works roughly as follows:
// There's a underlying array of 'heat' cells, that model the temperature
// at each point along the line.  Every cycle through the simulation,
// four steps are performed:
//  1) All cells cool down a little bit, losing heat to the air
//  2) The heat from each cell drifts 'up' and diffuses a little
//  3) Sometimes randomly new 'sparks' of heat are added at the bottom
//  4) The heat from each cell is rendered as a color into the leds array
//     The heat-to-color mapping uses a black-body radiation approximation.
//
// Temperature is in arbitrary units from 0 (cold black) to 255 (white hot).
//
// This simulation scales it self a bit depending on NUM_LEDS; it should look
// "OK" on anywhere from 20 to 100 LEDs without too much tweaking.
//
// I recommend running this simulation at anywhere from 30-100 frames per second,
// meaning an interframe delay of about 10-35 milliseconds.
//
//
// There are two main parameters you can play with to control the look and
// feel of your fire: COOLING (used in step 1 above), and SPARKING (used
// in step 3 above).
//
// COOLING: How much does the air cool as it rises?
// Less cooling = taller flames.  More cooling = shorter flames.
// Default 55, suggested range 20-100
#define COOLING  55
 
// SPARKING: What chance (out of 255) is there that a new spark will be lit?
// Higher chance = more roaring fire.  Lower chance = more flickery fire.
// Default 120, suggested range 50-200.
#define SPARKING 120
 
 
void Fire2012()
{
// Array of temperature readings at each simulation cell
  static byte heat[NUM_LEDS];
 
  // Step 1.  Cool down every cell a little
    for( int i = 0; i < NUM_LEDS; i++) {
      heat[i] = qsub8( heat[i],  random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
    }
 
    // Step 2.  Heat from each cell drifts 'up' and diffuses a little
    for( int k= NUM_LEDS - 3; k > 0; 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 < NUM_LEDS; j++) {
        leds[j] = HeatColor( heat[j]);
    }
}
 
 
 
// CRGB HeatColor( uint8_t temperature)
// [to be included in the forthcoming FastLED v2.1]
//
// Approximates a 'black body radiation' spectrum for
// a given 'heat' level.  This is useful for animations of 'fire'.
// Heat is specified as an arbitrary scale from 0 (cool) to 255 (hot).
// This is NOT a chromatically correct 'black body radiation'
// spectrum, but it's surprisingly close, and it's extremely fast and small.
//
// On AVR/Arduino, this typically takes around 70 bytes of program memory,
// versus 768 bytes for a full 256-entry RGB lookup table.
 
CRGB HeatColor( uint8_t temperature)
{
  CRGB heatcolor;
 
  // Scale 'heat' down from 0-255 to 0-191,
  // which can then be easily divided into three
  // equal 'thirds' of 64 units each.
  uint8_t t192 = scale8_video( temperature, 192);
 
  // calculate a value that ramps up from
  // zero to 255 in each 'third' of the scale.
  uint8_t heatramp = t192 & 0x3F; // 0..63
  heatramp <<= 2; // scale up to 0..252
 
  // now figure out which third of the spectrum we're in:
  if( t192 & 0x80) {
    // we're in the hottest third
    heatcolor.r = 255; // full red
    heatcolor.g = 255; // full green
    heatcolor.b = heatramp; // ramp up blue
   
  } else if( t192 & 0x40 ) {
    // we're in the middle third
    heatcolor.r = 255; // full red
    heatcolor.g = heatramp; // ramp up green
    heatcolor.b = 0; // no blue
   
  } else {
    // we're in the coolest third
    heatcolor.r = heatramp; // ramp up red
    heatcolor.g = 0; // no green
    heatcolor.b = 0; // no blue
  }
 
  return heatcolor;
}

I get these errors upon compiling:

D:\Documents\Arduino\Stolen_Fire_Emu\Stolen_Fire_Emu.ino:69:9: warning: extra tokens at end of #endif directive

#endif 

^

In file included from D:\Documents\Arduino\libraries\FastLED-master/bitswap.h:4:0,

from D:\Documents\Arduino\Stolen_Fire_Emu\Stolen_Fire_Emu.ino:1:

D:\Documents\Arduino\libraries\FastLED-master/FastLED.h:17:21: note: #pragma message: FastLED version 3.001.008

pragma message “FastLED version 3.001.008”

^

D:\Documents\Arduino\Stolen_Fire_Emu\Stolen_Fire_Emu.ino: In function ‘Fire2012()’:

D:\Documents\Arduino\Stolen_Fire_Emu\Stolen_Fire_Emu.ino:122:42: warning: iteration 46 invokes undefined behavior [-Waggressive-loop-optimizations]

heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;

^

D:\Documents\Arduino\Stolen_Fire_Emu\Stolen_Fire_Emu.ino:121:5: note: containing loop

for( int k= NUM_LEDS - 3; k > 0; k–) {

^

libraries\FastLED-master\colorutils.cpp.o (symbol from plugin): In function `nblend(CRGB&, CRGB const&, unsigned char)’:

(.text+0x0): multiple definition of `HeatColor(unsigned char)’

sketch\Stolen_Fire_Emu.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp: In function ‘main’:

D:\Documents\Arduino\Stolen_Fire_Emu\Stolen_Fire_Emu.ino:122:42: warning: iteration 46 invokes undefined behavior [-Waggressive-loop-optimizations]

heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;

^

D:\Documents\Arduino\Stolen_Fire_Emu\Stolen_Fire_Emu.ino:121:5: note: containing loop

for( int k= NUM_LEDS - 3; k > 0; k–) {

^

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno.

Any help would be awesome!

Hi,
Don't copy the example.
Got to

Files/Examples/FastLED
and select the Fire2012 from there, it has none of all those extra libraries.

The IDE example compiles, WIN 7, IDE 1.8.5

What model Arduino are you compiling for?

Thanks.. Tom.. :slight_smile: