Guest User

Untitled

a guest
Oct 15th, 2014
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.57 KB | None | 0 0
  1. //#AnimateMarquee
  2. //Causes a contiuous trail of 5 pixels, spaced by 3 apart, to animate
  3. //Assumes Start at 0
  4. //There is probably a more elegant way to code this
  5. //This is easy to read
  6. int AnimateMarquee(int Array[], int EndPixel, int CurrentPixel, int Hue, int Sat){
  7.   //Depending on CurrentPixel Value, Pick the animation case
  8.     const int Bright1 = 255;
  9.     const int Bright2 = 190;
  10.   switch (CurrentPixel){
  11.   case 0:
  12.     Array[0] = CHSV(Hue, Sat, Bright1);
  13.     Array[1] = CHSV(Hue, Sat, Bright1);
  14.     Array[2] = CHSV(Hue, Sat, Bright1);
  15.     Array[3] = CHSV(Hue, Sat, Bright1);
  16.     Array[4] = CHSV(Hue, Sat, Bright1);
  17.     Array[5] = CHSV(Hue, Sat, Bright2);
  18.     Array[6] = CHSV(Hue, Sat, Bright2);
  19.     Array[7] = CHSV(Hue, Sat, Bright2);
  20.     break;
  21.  
  22.   case 1:
  23.     Array[0] = CHSV(Hue, Sat, Bright2);
  24.     Array[1] = CHSV(Hue, Sat, Bright1);
  25.     Array[2] = CHSV(Hue, Sat, Bright1);
  26.     Array[3] = CHSV(Hue, Sat, Bright1);
  27.     Array[4] = CHSV(Hue, Sat, Bright1);
  28.     Array[5] = CHSV(Hue, Sat, Bright1);
  29.     Array[6] = CHSV(Hue, Sat, Bright2);
  30.     Array[7] = CHSV(Hue, Sat, Bright2);
  31.     break;
  32.  
  33.   case 2:
  34.     Array[0] = CHSV(Hue, Sat, Bright2);
  35.     Array[1] = CHSV(Hue, Sat, Bright2);
  36.     Array[2] = CHSV(Hue, Sat, Bright1);
  37.     Array[3] = CHSV(Hue, Sat, Bright1);
  38.     Array[4] = CHSV(Hue, Sat, Bright1);
  39.     Array[5] = CHSV(Hue, Sat, Bright1);
  40.     Array[6] = CHSV(Hue, Sat, Bright1);
  41.     Array[7] = CHSV(Hue, Sat, Bright2);
  42.     break;
  43.  
  44.   case 3:
  45.     Array[0] = CHSV(Hue, Sat, Bright2);
  46.     Array[1] = CHSV(Hue, Sat, Bright2);
  47.     Array[2] = CHSV(Hue, Sat, Bright2);
  48.     Array[3] = CHSV(Hue, Sat, Bright1);
  49.     Array[4] = CHSV(Hue, Sat, Bright1);
  50.     Array[5] = CHSV(Hue, Sat, Bright1);
  51.     Array[6] = CHSV(Hue, Sat, Bright1);
  52.     Array[7] = CHSV(Hue, Sat, Bright1);
  53.     break;
  54.  
  55.   case 4:
  56.     Array[0] = CHSV(Hue, Sat, Bright1);
  57.     Array[1] = CHSV(Hue, Sat, Bright2);
  58.     Array[2] = CHSV(Hue, Sat, Bright2);
  59.     Array[3] = CHSV(Hue, Sat, Bright2);
  60.     Array[4] = CHSV(Hue, Sat, Bright1);
  61.     Array[5] = CHSV(Hue, Sat, Bright1);
  62.     Array[6] = CHSV(Hue, Sat, Bright1);
  63.     Array[7] = CHSV(Hue, Sat, Bright1);
  64.     break;
  65.  
  66.   case 5:
  67.     Array[0] = CHSV(Hue, Sat, Bright1);
  68.     Array[1] = CHSV(Hue, Sat, Bright1);
  69.     Array[2] = CHSV(Hue, Sat, Bright2);
  70.     Array[3] = CHSV(Hue, Sat, Bright2);
  71.     Array[4] = CHSV(Hue, Sat, Bright2);
  72.     Array[5] = CHSV(Hue, Sat, Bright1);
  73.     Array[6] = CHSV(Hue, Sat, Bright1);
  74.     Array[7] = CHSV(Hue, Sat, Bright1);
  75.     break;
  76.  
  77.   case 6:
  78.     Array[0] = CHSV(Hue, Sat, Bright1);
  79.     Array[1] = CHSV(Hue, Sat, Bright1);
  80.     Array[2] = CHSV(Hue, Sat, Bright1);
  81.     Array[3] = CHSV(Hue, Sat, Bright2);
  82.     Array[4] = CHSV(Hue, Sat, Bright2);
  83.     Array[5] = CHSV(Hue, Sat, Bright2);
  84.     Array[6] = CHSV(Hue, Sat, Bright1);
  85.     Array[7] = CHSV(Hue, Sat, Bright1);
  86.     break;
  87.  
  88.   case 7:
  89.     Array[0] = CHSV(Hue, Sat, Bright1);
  90.     Array[1] = CHSV(Hue, Sat, Bright1);
  91.     Array[2] = CHSV(Hue, Sat, Bright1);
  92.     Array[3] = CHSV(Hue, Sat, Bright1);
  93.     Array[4] = CHSV(Hue, Sat, Bright2);
  94.     Array[5] = CHSV(Hue, Sat, Bright2);
  95.     Array[6] = CHSV(Hue, Sat, Bright2);
  96.     Array[7] = CHSV(Hue, Sat, Bright1);
  97.     break;
  98.  
  99.   }
  100.  
  101.  
  102. //after picking case, apply to the rest of the range
  103.    for(int i = 7; i < EndPixel; i = i + 8){
  104.    memmove8( &Array[i], &Array[0], 8 * sizeof( CRGB ) );
  105.    }
  106.  
  107.   FastLED.show();
  108.   //Reset at 8, since the function will draw all of the rest for you
  109.   if(CurrentPixel <= 7){
  110.     CurrentPixel = CurrentPixel+1;
  111.   }
  112.   if(CurrentPixel == 8){
  113.     CurrentPixel = 0;
  114.   }
  115.   return CurrentPixel;
  116. }
Advertisement
Add Comment
Please, Sign In to add comment