Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#AnimateMarquee
- //Causes a contiuous trail of 5 pixels, spaced by 3 apart, to animate
- //Assumes Start at 0
- //There is probably a more elegant way to code this
- //This is easy to read
- int AnimateMarquee(int Array[], int EndPixel, int CurrentPixel, int Hue, int Sat){
- //Depending on CurrentPixel Value, Pick the animation case
- const int Bright1 = 255;
- const int Bright2 = 190;
- switch (CurrentPixel){
- case 0:
- Array[0] = CHSV(Hue, Sat, Bright1);
- Array[1] = CHSV(Hue, Sat, Bright1);
- Array[2] = CHSV(Hue, Sat, Bright1);
- Array[3] = CHSV(Hue, Sat, Bright1);
- Array[4] = CHSV(Hue, Sat, Bright1);
- Array[5] = CHSV(Hue, Sat, Bright2);
- Array[6] = CHSV(Hue, Sat, Bright2);
- Array[7] = CHSV(Hue, Sat, Bright2);
- break;
- case 1:
- Array[0] = CHSV(Hue, Sat, Bright2);
- Array[1] = CHSV(Hue, Sat, Bright1);
- Array[2] = CHSV(Hue, Sat, Bright1);
- Array[3] = CHSV(Hue, Sat, Bright1);
- Array[4] = CHSV(Hue, Sat, Bright1);
- Array[5] = CHSV(Hue, Sat, Bright1);
- Array[6] = CHSV(Hue, Sat, Bright2);
- Array[7] = CHSV(Hue, Sat, Bright2);
- break;
- case 2:
- Array[0] = CHSV(Hue, Sat, Bright2);
- Array[1] = CHSV(Hue, Sat, Bright2);
- Array[2] = CHSV(Hue, Sat, Bright1);
- Array[3] = CHSV(Hue, Sat, Bright1);
- Array[4] = CHSV(Hue, Sat, Bright1);
- Array[5] = CHSV(Hue, Sat, Bright1);
- Array[6] = CHSV(Hue, Sat, Bright1);
- Array[7] = CHSV(Hue, Sat, Bright2);
- break;
- case 3:
- Array[0] = CHSV(Hue, Sat, Bright2);
- Array[1] = CHSV(Hue, Sat, Bright2);
- Array[2] = CHSV(Hue, Sat, Bright2);
- Array[3] = CHSV(Hue, Sat, Bright1);
- Array[4] = CHSV(Hue, Sat, Bright1);
- Array[5] = CHSV(Hue, Sat, Bright1);
- Array[6] = CHSV(Hue, Sat, Bright1);
- Array[7] = CHSV(Hue, Sat, Bright1);
- break;
- case 4:
- Array[0] = CHSV(Hue, Sat, Bright1);
- Array[1] = CHSV(Hue, Sat, Bright2);
- Array[2] = CHSV(Hue, Sat, Bright2);
- Array[3] = CHSV(Hue, Sat, Bright2);
- Array[4] = CHSV(Hue, Sat, Bright1);
- Array[5] = CHSV(Hue, Sat, Bright1);
- Array[6] = CHSV(Hue, Sat, Bright1);
- Array[7] = CHSV(Hue, Sat, Bright1);
- break;
- case 5:
- Array[0] = CHSV(Hue, Sat, Bright1);
- Array[1] = CHSV(Hue, Sat, Bright1);
- Array[2] = CHSV(Hue, Sat, Bright2);
- Array[3] = CHSV(Hue, Sat, Bright2);
- Array[4] = CHSV(Hue, Sat, Bright2);
- Array[5] = CHSV(Hue, Sat, Bright1);
- Array[6] = CHSV(Hue, Sat, Bright1);
- Array[7] = CHSV(Hue, Sat, Bright1);
- break;
- case 6:
- Array[0] = CHSV(Hue, Sat, Bright1);
- Array[1] = CHSV(Hue, Sat, Bright1);
- Array[2] = CHSV(Hue, Sat, Bright1);
- Array[3] = CHSV(Hue, Sat, Bright2);
- Array[4] = CHSV(Hue, Sat, Bright2);
- Array[5] = CHSV(Hue, Sat, Bright2);
- Array[6] = CHSV(Hue, Sat, Bright1);
- Array[7] = CHSV(Hue, Sat, Bright1);
- break;
- case 7:
- Array[0] = CHSV(Hue, Sat, Bright1);
- Array[1] = CHSV(Hue, Sat, Bright1);
- Array[2] = CHSV(Hue, Sat, Bright1);
- Array[3] = CHSV(Hue, Sat, Bright1);
- Array[4] = CHSV(Hue, Sat, Bright2);
- Array[5] = CHSV(Hue, Sat, Bright2);
- Array[6] = CHSV(Hue, Sat, Bright2);
- Array[7] = CHSV(Hue, Sat, Bright1);
- break;
- }
- //after picking case, apply to the rest of the range
- for(int i = 7; i < EndPixel; i = i + 8){
- memmove8( &Array[i], &Array[0], 8 * sizeof( CRGB ) );
- }
- FastLED.show();
- //Reset at 8, since the function will draw all of the rest for you
- if(CurrentPixel <= 7){
- CurrentPixel = CurrentPixel+1;
- }
- if(CurrentPixel == 8){
- CurrentPixel = 0;
- }
- return CurrentPixel;
- }
Advertisement
Add Comment
Please, Sign In to add comment