Created
April 9, 2018 19:37
-
-
Save marmilicious/fe0bbb5a381930a77188dfa5e0b244a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For Bill from this post: | |
https://plus.google.com/u/0/109149766109138486006/posts/J9Xnqthpgsh | |
//--------------------------------------------------------------- | |
Somewhere at the top of the program: | |
#define NUM_LEDS 32 //length of one strip | |
#define DBL_LEDS NUM_LEDS*2 //double the length of one strip | |
CRGB ledsA[NUM_LEDS]; //strip A (gets displayed) | |
CRGB ledsB[NUM_LEDS]; //strip B (gets displayed) | |
CRGB temp[DBL_LEDS]; //temporary working array (not displayed) | |
//--------------------------------------------------------------- | |
In the setup section, something like this for the two strips ledsA and ledsB: | |
FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, RGB>(ledsA, NUM_LEDS); | |
FastLED.addLeds<APA102, DATA_PIN2, CLOCK_PIN2, RGB>(ledsB, NUM_LEDS); | |
//--------------------------------------------------------------- | |
In the main loop when assigning color, opperate on the "temp" | |
array and use DBL_LEDS as the number of pixels. For example: | |
fill_rainbow( temp, DBL_LEDS, millis()/5); | |
Call the shuffle function right before running show: | |
ShufflePixels(); | |
FastLED.show(); | |
//--------------------------------------------------------------- | |
And a shuffle function: | |
void ShufflePixels() | |
// Function to shuffle pixels before displaying. | |
// | |
// Have "temp" array data like this: | |
// 0,1,2,3,4,5 ... DBL_LEDS | |
// | |
// Want it shuffled and distributed to two strips like this: | |
// 0,2,4,6... | |
// 1,3,5,7... | |
{ | |
uint16_t c = 1; | |
for (uint8_t i=0; i<DBL_LEDS; i++) { | |
if ((i & 0x01) == 0) { //number is even | |
ledsA[c/2] = temp[i]; | |
} else { //number is odd | |
ledsB[(c/2)-1] = temp[i]; | |
} | |
c++; | |
} | |
}//end ShufflePixels | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment