Ok I lied. I'm stuck again.
Thought I could figure it out but it's just not doing what I want. Like how this looks but can't see how to make Case 3 and 4 go the opposite way.
Case 1 and 2- Move from strip 1-12
Case 3 and 4- Move from strip 12-1 (reverse direction)
Here is the code. I tried all kinds of ways to change case 3 and 4 to work in the reverse direction with no luck. I'm probably way off on my thoughts anyways. Def harder than I expected this to be. Hopefully I'll understand any help given
Thank you
#include "FastLED.h"
#define NUM_LEDS_PER_STRIP 37
#define NUM_STRIPS 12
const uint8_t pinStrip1 = 1;
const uint8_t pinStrip2 = 2;
const uint8_t pinStrip3 = 3;
const uint8_t pinStrip4 = 4;
const uint8_t pinStrip5 = 5;
const uint8_t pinStrip6 = 6;
const uint8_t pinStrip7 = 7;
const uint8_t pinStrip8 = 8;
const uint8_t pinStrip9 = 9;
const uint8_t pinStrip10 = 10;
const uint8_t pinStrip11 = 11;
const uint8_t pinStrip12 = 12;
//const uint8_t pinDebug = A0;
CRGB
grLeds[NUM_STRIPS][NUM_LEDS_PER_STRIP];
CLEDController
*stripControl[NUM_STRIPS];
uint8_t gBrightness = 255;
void setup() {
delay(100);
stripControl[0] = &FastLED.addLeds<WS2812, pinStrip1, GRB>(grLeds[0], NUM_LEDS_PER_STRIP);
stripControl[1] = &FastLED.addLeds<WS2812, pinStrip2, GRB>(grLeds[1], NUM_LEDS_PER_STRIP);
stripControl[2] = &FastLED.addLeds<WS2812, pinStrip3, GRB>(grLeds[2], NUM_LEDS_PER_STRIP);
stripControl[3] = &FastLED.addLeds<WS2812, pinStrip4, GRB>(grLeds[3], NUM_LEDS_PER_STRIP);
stripControl[4] = &FastLED.addLeds<WS2812, pinStrip5, GRB>(grLeds[4], NUM_LEDS_PER_STRIP);
stripControl[5] = &FastLED.addLeds<WS2812, pinStrip6, GRB>(grLeds[5], NUM_LEDS_PER_STRIP);
stripControl[6] = &FastLED.addLeds<WS2812, pinStrip7, GRB>(grLeds[6], NUM_LEDS_PER_STRIP);
stripControl[7] = &FastLED.addLeds<WS2812, pinStrip8, GRB>(grLeds[7], NUM_LEDS_PER_STRIP);
stripControl[8] = &FastLED.addLeds<WS2812, pinStrip9, GRB>(grLeds[8], NUM_LEDS_PER_STRIP);
stripControl[9] = &FastLED.addLeds<WS2812, pinStrip10, GRB>(grLeds[9], NUM_LEDS_PER_STRIP);
stripControl[10] = &FastLED.addLeds<WS2812, pinStrip11, GRB>(grLeds[10], NUM_LEDS_PER_STRIP);
stripControl[11] = &FastLED.addLeds<WS2812, pinStrip12, GRB>(grLeds[11], NUM_LEDS_PER_STRIP);
//pinMode( pinDebug, OUTPUT );
}//setup
void loop()
{
doEffects();
}//loop
void doEffects( void )
{
static uint8_t
stripIdx = 0,
stateEffects = 0;
switch ( stateEffects )
{
case 0:
//stay in state 0 doing the meteor effect...
meteorRain( stripIdx, CRGB(0x00, 0x00, 0x00), CRGB(0xff, 0xff, 0xff), 10, 175, true, 25 );
stripIdx++;
//until all strips are done...
if ( stripIdx == NUM_STRIPS )
stateEffects++; //then bump to the next state
break;
case 1:
//add another effect here and when done...
for ( stripIdx = 0; stripIdx < NUM_STRIPS; stripIdx += 3 )
{
fill_solid( grLeds[stripIdx], NUM_LEDS_PER_STRIP, CRGB(0xff, 0x00, 0x00) );
stripControl[stripIdx]->showLeds(gBrightness);
delay(25);
fill_solid( grLeds[stripIdx + 1], NUM_LEDS_PER_STRIP, CRGB(0xff, 0x00, 0x00) );
stripControl[stripIdx + 1]->showLeds(gBrightness);
delay(25);
fill_solid( grLeds[stripIdx + 2], NUM_LEDS_PER_STRIP, CRGB(0xff, 0x00, 0x00) );
stripControl[stripIdx + 2]->showLeds(gBrightness);
delay(25);
}//for
//move to the next effect
stateEffects++;
break;
case 2:
//add another effect here and when done...
for ( stripIdx = 0; stripIdx < NUM_STRIPS; stripIdx += 3 )
{
fill_solid( grLeds[stripIdx], NUM_LEDS_PER_STRIP, CRGB(0x00, 0x00, 0x00) );
stripControl[stripIdx]->showLeds(gBrightness);
delay(25);
fill_solid( grLeds[stripIdx + 1], NUM_LEDS_PER_STRIP, CRGB(0x00, 0x00, 0x00) );
stripControl[stripIdx + 1]->showLeds(gBrightness);
delay(25);
fill_solid( grLeds[stripIdx + 2], NUM_LEDS_PER_STRIP, CRGB(0x00, 0x00, 0x00) );
stripControl[stripIdx + 2]->showLeds(gBrightness);
delay(25);
}//for
//move to the next effect
stateEffects++;
break;
case 3:
//add another effect here and when done...
for ( stripIdx = 0; stripIdx < NUM_STRIPS; stripIdx += 3 )
{
fill_solid( grLeds[stripIdx], NUM_LEDS_PER_STRIP, CRGB(0xff, 0x00, 0x00) );
stripControl[stripIdx]->showLeds(gBrightness);
delay(25);
fill_solid( grLeds[stripIdx + 1], NUM_LEDS_PER_STRIP, CRGB(0xff, 0x00, 0x00) );
stripControl[stripIdx + 1]->showLeds(gBrightness);
delay(25);
fill_solid( grLeds[stripIdx + 2], NUM_LEDS_PER_STRIP, CRGB(0xff, 0x00, 0x00) );
stripControl[stripIdx + 2]->showLeds(gBrightness);
delay(25);
}//for
//move to the next effect
stateEffects++;
break;
case 4:
//add another effect here and when done...
for ( stripIdx = 0; stripIdx < NUM_STRIPS; stripIdx += 3 )
{
fill_solid( grLeds[stripIdx], NUM_LEDS_PER_STRIP, CRGB(0x00, 0x00, 0x00) );
stripControl[stripIdx]->showLeds(gBrightness);
delay(25);
fill_solid( grLeds[stripIdx + 1], NUM_LEDS_PER_STRIP, CRGB(0x00, 0x00, 0x00) );
stripControl[stripIdx + 1]->showLeds(gBrightness);
delay(25);
fill_solid( grLeds[stripIdx + 2], NUM_LEDS_PER_STRIP, CRGB(0x00, 0x00, 0x00) );
stripControl[stripIdx + 2]->showLeds(gBrightness);
delay(25);
}//for
//move to the next effect
stateEffects++;
break;
case 5:
//add another effect and so on...
//when done effects, just use an empty case like this
for ( stripIdx = 0; stripIdx < NUM_STRIPS; stripIdx += 3 )
{
fill_solid( grLeds[stripIdx], NUM_LEDS_PER_STRIP, CRGB(0xff, 0xff, 0xff) );
stripControl[stripIdx]->showLeds(gBrightness);
fill_solid( grLeds[stripIdx + 1], NUM_LEDS_PER_STRIP, CRGB(0xff, 0xff, 0xff) );
stripControl[stripIdx + 1]->showLeds(gBrightness);
fill_solid( grLeds[stripIdx + 2], NUM_LEDS_PER_STRIP, CRGB(0xff, 0xff, 0xff) );
stripControl[stripIdx + 2]->showLeds(gBrightness);
}//for
//move to the next effect
stateEffects++;
break;
}//switch
}//doEffects
void meteorRain( uint8_t stripNo,
CRGB ColorBackground,
CRGB ColorMeteor,
byte meteorSize,
byte meteorTrailDecay,
boolean meteorRandomDecay,
uint32_t SpeedDelay )
{
// set background color
fill_solid( grLeds[stripNo], NUM_LEDS_PER_STRIP, ColorBackground );
for (uint8_t i = 0; i < NUM_LEDS_PER_STRIP * 2; i++ )
{
// fade color to background color for all LEDs
for (uint8_t led = 0; led < NUM_LEDS_PER_STRIP; led++ )
{
if ( (!meteorRandomDecay) || (random(10) > 5) )
{
grLeds[stripNo][led] = fadeTowardColor( grLeds[stripNo][led], ColorBackground, meteorTrailDecay );
}//if
}//for
// draw meteor
for ( uint8_t j = 0; j < meteorSize; j++ )
{
if ( ( (i - j) < NUM_LEDS_PER_STRIP) && ((i - j) >= 0) )
{
grLeds[stripNo][i - j] = ColorMeteor;
}//if
}//for
stripControl[stripNo]->showLeds(gBrightness);
delayMicroseconds( SpeedDelay );
}//for
}//meteorRain
CRGB fadeTowardColor( CRGB &cur, const CRGB &target, uint8_t amount )
{
nblendU8TowardU8( cur.red, target.red, amount);
nblendU8TowardU8( cur.green, target.green, amount);
nblendU8TowardU8( cur.blue, target.blue, amount);
return cur;
}//fadeTowardColor
void nblendU8TowardU8( uint8_t &cur, const uint8_t target, uint8_t amount )
{
if ( cur == target)
return;
if ( cur < target )
{
uint8_t delta = target - cur;
delta = scale8_video( delta, amount);
cur += delta;
}//if
else
{
uint8_t delta = cur - target;
delta = scale8_video( delta, amount);
cur -= delta;
}//else
}//nblendU8TowardU8