Go Down

Topic: Fadeout Fire2012 with fastled (Read 348 times) previous topic - next topic

Kenai

Hello guys,
you all may know the Fire2012 by Mark Kriegsmann.
I need to sketch such fire but the length of the flames should be variable, i.e. heat up the fire or cool down, not with the colours but withe the count of uses pixels.

This is what i have for now: The fire runs over 35 LEDs. If Timer 1 is over the count of pixels is divided by two (later on this will be a fade from 35 to 18). I thought, if i change the NUM_LEDS constant in the Fire2012 void it should work, but after Time1 the Fire stops with the LEDs on in their last status.

Does anyone has an idea?
Thanks Thomas

Code: [Select]

#include <FastLED.h>
#include <neotimer.h>
#define COOLING  55
#define SPARKING 120
#define LED_PIN     2
#define COLOR_ORDER GRB
#define CHIPSET     WS2812B
#define BRIGHTNESS  160
#define NUM_LEDS  35
int Brennweite = 35;

Neotimer Time1 = Neotimer(4000);
Neotimer Time2 = Neotimer(7000);

#define FRAMES_PER_SECOND 60
bool gReverseDirection = true;
CRGBPalette16 gPal;
CRGBPalette16 gPal2;
CRGB leds[NUM_LEDS];

void setup() {
  //Serial.begin(9600);
  //delay(3000); // sanity delay
  FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  FastLED.setBrightness(BRIGHTNESS );
gPal = CRGBPalette16( CRGB::Black, CRGB::Blue, CRGB::Aqua,  CRGB::White);
  Time1.start();
  Time2.start();
}

void loop()
{
  random16_add_entropy( random());

  Fire2012(); // run simulation frame
 
  FastLED.show(); // display this frame
  FastLED.delay(1000/ FRAMES_PER_SECOND);
  if(Time1.done()) {Fadeout (Brennweite, 1);
                    Time1.stop();}}

  void Fire2012(){
   static byte heat[NUM_LEDS];

    for( int i = 0; i < Brennweite; i++) {
      heat[i] = qsub8( heat[i],  random8(0, ((COOLING * 10) / Brennweite) + 2));
    }
    for( int k= Brennweite - 1; k >= 2; k--) {
      heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
    }
    if( random8() < SPARKING ) {
      int y = random8(7);
      heat[y] = qadd8( heat[y], random8(160,255) );
    }
    for( int j = 0; j < Brennweite; j++) {
     byte colorindex = scale8( heat[j], 240);
      CRGB color = ColorFromPalette( gPal, colorindex);
      int pixelnumber;
      if( gReverseDirection ) {
        pixelnumber = (Brennweite-1) - j;
      } else {
        pixelnumber = j;
      }
      leds[pixelnumber] = color;
    }}

   
  void Fadeout(int Brennweite, int fadespeed) {
         for (int a = Brennweite; a =1; Brennweite--){ Brennweite = Brennweite - fadespeed;}     
                }     


sterretje

#1
Jun 18, 2019, 08:28 am Last Edit: Jun 18, 2019, 08:29 am by sterretje
I'm not sure if you have a problem or need an approach. But the below is not correct

void Fadeout(int Brennweite, int fadespeed) {
  for (int a = Brennweite; a = 1; Brennweite--) {
    Brennweite = Brennweite - fadespeed;
  }
}

If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

Go Up