Author Topic: FastLED 3.1 works with Simblee, RFduino, IDE 1.6.7,1.6.8  (Read 1553 times)

tolson

  • Global Moderator
  • *****
  • Posts: 838
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
FastLED 3.1 works with Simblee, RFduino, IDE 1.6.7,1.6.8
« on: April 09, 2016, 11:38:20 AM »
If you don't mind including an all encompassing complicated pixel library in your memory map just to drive a neopixel string or ring, give FastLED 3.1 a go. For me it works pretty good on Simblee and RFduino with the latest Arduino IDEs...1.6.7, 1.6.8.

It even seems to work pretty good while the Simblee or RFduino Radio is turned on. That's nice!

Here is a sketch I modified to compile with the Radio turned on. You can compile for RFduino or Simblee.

Code: [Select]
// Fire2012Simblee using FastLED 3.1 and Fire2012
// Modified by Thomas Olson
// teo20151222.01 Testing if conflicts with Simblee Radio on
// Modified for compiling on Simblee and RFduino - IDE 1.6.7
// teo20160328.01 verified works with Arduino IDE 1.6.8


#if defined(RFDUINO)
 #include <RFduinoBLE.h>
 #define RFD RFduinoBLE
#elif defined(SIMBLEE)
 #include <SimbleeBLE.h>
 #define RFD SimbleeBLE
#endif

#include <FastLED.h>

#define LED_PIN     6
#define COLOR_ORDER GRB
#define CHIPSET     WS2811
#define NUM_LEDS    24

#define BRIGHTNESS  200
#define FRAMES_PER_SECOND 60

bool gReverseDirection = false;

CRGB leds[NUM_LEDS];

void setup() {
  delay(3000); // sanity delay
  FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  FastLED.setBrightness( BRIGHTNESS );

  RFD.begin();
}

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
  FastLED.delay(1000 / FRAMES_PER_SECOND);
}


// 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.
//
// Looks best on a high-density LED setup (60+ pixels/meter).
//
//
// 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 50, 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 - 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 < NUM_LEDS; j++) {
      CRGB color = HeatColor( heat[j]);
      int pixelnumber;
      if( gReverseDirection ) {
        pixelnumber = (NUM_LEDS-1) - j;
      } else {
        pixelnumber = j;
      }
      leds[pixelnumber] = color;
    }
}


jos.ph

  • RFduino Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: FastLED 3.1 works with Simblee, RFduino, IDE 1.6.7,1.6.8
« Reply #1 on: July 26, 2016, 01:03:41 AM »
I had to make the following changes to compile for Simblee in Arduino 1.6.5 (which I believe is the recommended Arduino version in the Simblee quickstart) -- apologies if I am reverting to an older version, but since this is the only thread with FastLED specifically in the title, maybe someone will find it useful. Note: made these changes to successfully *compile* - will report back with actual test results tomorrow.

FastLED `led_sysdefs.h`, line 6:
Code: [Select]
#if defined(NRF51) || defined(__RFduino__) || defined(__Simblee__)
Arduino Example
Code: [Select]
// Fire2012Simblee using FastLED 3.1 and Fire2012
// Modified by Thomas Olson
// teo20151222.01 Testing if conflicts with Simblee Radio on
// Modified for compiling on Simblee and RFduino - IDE 1.6.7
// teo20160328.01 verified works with Arduino IDE 1.6.8
// joe20160726.01 modified for Simblee & IDE 1.6.5


#include <SimbleeBLE.h>
#include <FastLED.h>

#define LED_PIN     6
#define COLOR_ORDER GRB
#define CHIPSET     WS2811
#define NUM_LEDS    24

#define BRIGHTNESS  200
#define FRAMES_PER_SECOND 60

bool gReverseDirection = false;

CRGB leds[NUM_LEDS];

void setup() {
  delay(3000); // sanity delay
  FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  FastLED.setBrightness( BRIGHTNESS );
 
  SimbleeBLE.begin();
}

void loop(){
/* same */
}

tolson

  • Global Moderator
  • *****
  • Posts: 838
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: FastLED 3.1 works with Simblee, RFduino, IDE 1.6.7,1.6.8
« Reply #2 on: July 26, 2016, 07:36:40 AM »
I had to make the following changes to compile for Simblee in Arduino 1.6.5 (which I believe is the recommended Arduino version in the Simblee quickstart) -- apologies if I am reverting to an older version, but since this is the only thread with FastLED specifically in the title, maybe someone will find it useful. Note: made these changes to successfully *compile* - will report back with actual test results tomorrow.


Hi Joe.ph
RF Digital is famous for not keeping the documentation up to date. But the 166 json file has been the preferred one for a while. And the recent release of the Android APP for SImblee for Mobile uses the same json updated to work with the required changes to work with Simblee for Mobile which requires the 1.1.0 library. The quickstart guide now shows using Arduino 1.6.9. So worth upgrading to Arduino 1.6.9 and Simblee 1.1.0 to take advantage of whatever improvements there are. Now if we can get a complete detailed API documentation.

jos.ph

  • RFduino Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: FastLED 3.1 works with Simblee, RFduino, IDE 1.6.7,1.6.8
« Reply #3 on: July 26, 2016, 07:40:12 AM »
Awesome thanks so much! Will absolutely try later today and report back.

 

anything