Skip to content

Commit

Permalink
Release 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
bportaluri committed Mar 23, 2015
1 parent 3d06c5c commit 739bb8a
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 767 deletions.
14 changes: 5 additions & 9 deletions Ala.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@
#define ALA_PIXELBOUNCE 203
#define ALA_PIXELSMOOTHSHIFTRIGHT 211
#define ALA_PIXELSMOOTHSHIFTLEFT 212
#define ALA_PIXELSMOOTHBOUNCE 213
#define ALA_COMET 221
#define ALA_COMETCOL 222
#define ALA_BARSHIFTRIGHT 231
#define ALA_BARSHIFTLEFT 232
#define ALA_MOVINGBARS 241
#define ALA_MOVINGGRADIENT 242
#define ALA_LARSONSCANNER 251
#define ALA_LARSONSCANNER2 252

#define ALA_FADEIN 301
#define ALA_FADEOUT 302
Expand Down Expand Up @@ -123,6 +126,7 @@ typedef struct AlaColor
int b0 = min(b*k, 255);
return AlaColor(r0, g0, b0);
}


typedef enum {
Aqua=0x00FFFF,
Expand Down Expand Up @@ -197,17 +201,9 @@ typedef struct AlaSeq


////////////////////////////////////////////////////////////////////////////////
// Colors and palette definitions
// Palette definitions
////////////////////////////////////////////////////////////////////////////////

/* Replaced by enum
static AlaColor alaColorWhite = 0xFFFFFF;
static AlaColor alaColorGray = 0x888888;
static AlaColor alaColorBlack = 0x000000;
static AlaColor alaColorRed = 0xFF0000;
static AlaColor alaColorGreen = 0x00FF00;
static AlaColor alaColorBlue = 0x0000FF;
*/

static AlaColor alaPalRgb_[] = { 0xFF0000, 0x00FF00, 0x0000FF };
static AlaPalette alaPalRgb = { 3, alaPalRgb_ };
Expand Down
76 changes: 57 additions & 19 deletions AlaLed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include "ExtTlc5940.h"




AlaLed::AlaLed()
{
maxOut=255;
Expand Down Expand Up @@ -50,10 +48,6 @@ void AlaLed::initTLC5940(int numLeds, byte *pins)
memset(leds, 0, numLeds);
}

//pins = (byte *)malloc(numLeds);
//for(int i=0; i<numLeds; i++)
// pins[i]=i;

Tlc.init(0);
}

Expand Down Expand Up @@ -156,16 +150,20 @@ void AlaLed::setAnimationFunc(int animation)
case ALA_BLINK: animFunc = &AlaLed::blink; break;
case ALA_BLINKALT: animFunc = &AlaLed::blinkAlt; break;
case ALA_SPARKLE: animFunc = &AlaLed::sparkle; break;
case ALA_SPARKLE2: animFunc = &AlaLed::sparkle2; break;
case ALA_STROBO: animFunc = &AlaLed::strobo; break;

case ALA_PIXELSHIFTRIGHT: animFunc = &AlaLed::pixelShiftRight; break;
case ALA_PIXELSHIFTLEFT: animFunc = &AlaLed::pixelShiftLeft; break;
case ALA_PIXELBOUNCE: animFunc = &AlaLed::pixelBounce; break;
case ALA_PIXELSMOOTHSHIFTRIGHT: animFunc = &AlaLed::pixelSmoothShiftRight; break;
case ALA_PIXELSMOOTHSHIFTLEFT: animFunc = &AlaLed::pixelSmoothShiftLeft; break;
case ALA_PIXELSMOOTHBOUNCE: animFunc = &AlaLed::pixelSmoothBounce; break;
case ALA_COMET: animFunc = &AlaLed::comet; break;
case ALA_BARSHIFTRIGHT: animFunc = &AlaLed::barShiftRight; break;
case ALA_BARSHIFTLEFT: animFunc = &AlaLed::barShiftLeft; break;
case ALA_LARSONSCANNER: animFunc = &AlaLed::larsonScanner; break;
case ALA_LARSONSCANNER2: animFunc = &AlaLed::larsonScanner2; break;

case ALA_FADEIN: animFunc = &AlaLed::fadeIn; break;
case ALA_FADEOUT: animFunc = &AlaLed::fadeOut; break;
Expand Down Expand Up @@ -221,23 +219,27 @@ void AlaLed::blinkAlt()

void AlaLed::sparkle()
{
static long tStart;

if (millis()<tStart+50)
return;
int p = speed/100;
for(int x=0; x<numLeds; x++)
{
leds[x] = (random(p)==0)*maxOut;
}
}

for(int x=0; x<numLeds; x++)
void AlaLed::sparkle2()
{
int p = speed/10;
for(int x=0; x<numLeds; x++)
{
if(random(16)==0)
if(random(p)==0)
leds[x] = maxOut;
else
leds[x] = 0;
leds[x] = leds[x] * 0.88;
}

tStart=millis();
}



void AlaLed::strobo()
{
int t = getStep(animStartTime, speed, ALA_STROBODC);
Expand Down Expand Up @@ -286,6 +288,7 @@ void AlaLed::pixelBounce()
}



void AlaLed::pixelSmoothShiftRight()
{
float t = getStepFloat(animStartTime, speed, numLeds+1);
Expand Down Expand Up @@ -351,6 +354,41 @@ void AlaLed::barShiftLeft()
}
}

void AlaLed::pixelSmoothBounce()
{
// see larsonScanner
float t = getStepFloat(animStartTime, speed, 2*numLeds-2);

for(int x=0; x<numLeds; x++)
{
leds[x] = constrain((int)((-abs(abs(t-numLeds+1)-x)+1)*maxOut), 0, maxOut);
}
}


void AlaLed::larsonScanner()
{
float l = numLeds/4;
float t = getStepFloat(animStartTime, speed, 2*numLeds-2);

for(int x=0; x<numLeds; x++)
{
leds[x] = constrain((int)((-abs(abs(t-numLeds+1)-x)+l)*maxOut), 0, maxOut);
}
}

void AlaLed::larsonScanner2()
{
float l = numLeds/4; // 2>7, 3-11, 4-14
float t = getStepFloat(animStartTime, speed, 2*numLeds+(l*4-1));

for(int x=0; x<numLeds; x++)
{

leds[x] = constrain((int)((-abs(abs(t-numLeds-2*l)-x-l)+l)*maxOut), 0, maxOut);
}
}

////////////////////////////////////////////////////////////////////////////////////////////
// Fading effects
////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -360,7 +398,7 @@ void AlaLed::fadeIn()
int s = getStep(animStartTime, speed, maxOut);
for(int x=0; x<numLeds; x++)
{
leds[numLeds-x-1] = s;
leds[x] = s;
}
}

Expand All @@ -370,7 +408,7 @@ void AlaLed::fadeOut()
int s = getStep(animStartTime, speed, maxOut);
for(int x=0; x<numLeds; x++)
{
leds[numLeds-x-1] = abs(maxOut-s);
leds[x] = abs(maxOut-s);
}
}

Expand All @@ -381,7 +419,7 @@ void AlaLed::fadeInOut()

for(int x=0; x<numLeds; x++)
{
leds[numLeds-x-1] = abs(maxOut-abs(s));
leds[x] = abs(maxOut-abs(s));
}
}

Expand All @@ -392,6 +430,6 @@ void AlaLed::glow()

for(int x=0; x<numLeds; x++)
{
leds[numLeds-x-1] = (-cos(s)+1)*maxOut/2;
leds[x] = (-cos(s)+1)*maxOut/2;
}
}
4 changes: 4 additions & 0 deletions AlaLed.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,20 @@ class AlaLed
void blink();
void blinkAlt();
void sparkle();
void sparkle2();
void strobo();

void pixelShiftRight();
void pixelShiftLeft();
void pixelBounce();
void pixelSmoothShiftRight();
void pixelSmoothShiftLeft();
void pixelSmoothBounce();
void comet();
void barShiftRight();
void barShiftLeft();
void larsonScanner();
void larsonScanner2();

void fadeIn();
void fadeOut();
Expand Down
Loading

0 comments on commit 739bb8a

Please sign in to comment.