Skip to content

Commit

Permalink
New flame effect
Browse files Browse the repository at this point in the history
Flame effect added
Minor initialization issue fixed
  • Loading branch information
bportaluri committed Oct 11, 2015
1 parent 6c6be05 commit b2d397e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/Ala.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#define ALA_FADECOLORS 351
#define ALA_FADECOLORSLOOP 352
#define ALA_PIXELSFADECOLORS 353
#define ALA_FLAME 354

#define ALA_FIRE 501
#define ALA_BOUNCINGBALLS 502
Expand Down
14 changes: 13 additions & 1 deletion src/AlaLed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "ExtTlc5940.h"



AlaLed::AlaLed()
{
maxOut=255;
Expand All @@ -16,7 +17,7 @@ AlaLed::AlaLed()

void AlaLed::initPWM(byte pin)
{
byte *pins_ = (byte *)malloc(numLeds);
byte *pins_ = (byte *)malloc(1);
pins_[0] = pin;

initPWM(1, pins_);
Expand Down Expand Up @@ -178,6 +179,8 @@ void AlaLed::setAnimationFunc(int animation)
case ALA_FADEOUT: animFunc = &AlaLed::fadeOut; break;
case ALA_FADEINOUT: animFunc = &AlaLed::fadeInOut; break;
case ALA_GLOW: animFunc = &AlaLed::glow; break;
case ALA_FLAME: animFunc = &AlaLed::flame; break;

default: animFunc = &AlaLed::off;
}
}
Expand Down Expand Up @@ -442,3 +445,12 @@ void AlaLed::glow()
leds[x] = (-cos(s)+1)*maxOut/2;
}
}

void AlaLed::flame()
{
for(int x=0; x<numLeds; x++)
{
if (random(4) == 0)
leds[x] = map(random(30)+70, 0, 100, 0, maxOut);
}
}
1 change: 1 addition & 0 deletions src/AlaLed.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class AlaLed
void fadeOut();
void fadeInOut();
void glow();
void flame();


byte driver;
Expand Down
4 changes: 1 addition & 3 deletions src/AlaLedRgb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ AlaLedRgb::AlaLedRgb()

void AlaLedRgb::initPWM(byte pinRed, byte pinGreen, byte pinBlue)
{
byte *pins_ = (byte *)malloc(3*numLeds);
byte *pins_ = (byte *)malloc(3);
pins_[0] = pinRed;
pins_[1] = pinGreen;
pins_[2] = pinBlue;
Expand Down Expand Up @@ -567,7 +567,6 @@ void AlaLedRgb::pixelsFadeColors()
AlaColor c = palette.getPalColor(t+7*x);
leds[x] = c;
}

}

void AlaLedRgb::fadeColorsLoop()
Expand Down Expand Up @@ -613,7 +612,6 @@ void AlaLedRgb::movingGradient()
}



void AlaLedRgb::fire()
{
// COOLING: How much does the air cool as it rises?
Expand Down

0 comments on commit b2d397e

Please sign in to comment.