shdowmyst

Untitled

Aug 8th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.62 KB | None | 0 0
  1. const bool random_order = true;
  2. const uint8_t palette_delay = 20; //in seconds
  3.  
  4. // active palettes
  5. const bool pal_0_act = true;
  6. const bool pal_1_act = false;
  7. const bool pal_2_act = true;
  8. const bool pal_3_act = false;
  9. const bool pal_4_act = true;
  10. const bool pal_5_act = true;
  11.  
  12. void ChangePalettePeriodically()
  13. {
  14.   uint8_t secondHand = (millis() / 1000) % (palette_delay + 1); //  eltelt ms bekapcsolás óta.
  15.   static uint8_t lastSecond = 99;
  16.     if( lastSecond != secondHand) {       // ez csak másodperceként 1x engedi lefutni, de miért?
  17.     lastSecond = secondHand;
  18.    
  19.      static uint8_t pal_count = 0;
  20.                    pal_count %= 6;
  21.            //        Serial.println(pal_count);
  22.     if (random_order == true) { pal_count = random(6); }
  23.  
  24.     if( pal_count == 0 && pal_0_act == true)  { new_palette = aria_pl;}         else if (  pal_0_act == false ) { pal_count += 1;}
  25.     if( pal_count == 1 && pal_1_act == true)  { new_palette = Blue_Green_gp;}   else if (  pal_1_act == false ) { pal_count += 1;}
  26.     if( pal_count == 2 && pal_2_act == true)  { new_palette = Deep_Sea_gp;}     else if (  pal_2_act == false ) { pal_count += 1;}
  27.     if( pal_count == 3 && pal_3_act == true)  { new_palette = Incandescent_gp;} else if (  pal_3_act == false ) { pal_count += 1;}
  28.     if( pal_count == 4 && pal_4_act == true)  { new_palette = Purples_gp;}      else if (  pal_4_act == false ) { pal_count += 1;}
  29.     if( pal_count == 5 && pal_5_act == true)  { new_palette = blackpl;}         else if (  pal_5_act == false ) { pal_count += 1;}
  30.    
  31.  
  32.     if( secondHand == palette_delay)  { targetPalette = new_palette; pal_count += 1;}
  33.   }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment