Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const bool random_order = true;
- const uint8_t palette_delay = 20; //in seconds
- // active palettes
- const bool pal_0_act = true;
- const bool pal_1_act = false;
- const bool pal_2_act = true;
- const bool pal_3_act = false;
- const bool pal_4_act = true;
- const bool pal_5_act = true;
- void ChangePalettePeriodically()
- {
- uint8_t secondHand = (millis() / 1000) % (palette_delay + 1); // eltelt ms bekapcsolás óta.
- static uint8_t lastSecond = 99;
- if( lastSecond != secondHand) { // ez csak másodperceként 1x engedi lefutni, de miért?
- lastSecond = secondHand;
- static uint8_t pal_count = 0;
- pal_count %= 6;
- // Serial.println(pal_count);
- if (random_order == true) { pal_count = random(6); }
- if( pal_count == 0 && pal_0_act == true) { new_palette = aria_pl;} else if ( pal_0_act == false ) { pal_count += 1;}
- if( pal_count == 1 && pal_1_act == true) { new_palette = Blue_Green_gp;} else if ( pal_1_act == false ) { pal_count += 1;}
- if( pal_count == 2 && pal_2_act == true) { new_palette = Deep_Sea_gp;} else if ( pal_2_act == false ) { pal_count += 1;}
- if( pal_count == 3 && pal_3_act == true) { new_palette = Incandescent_gp;} else if ( pal_3_act == false ) { pal_count += 1;}
- if( pal_count == 4 && pal_4_act == true) { new_palette = Purples_gp;} else if ( pal_4_act == false ) { pal_count += 1;}
- if( pal_count == 5 && pal_5_act == true) { new_palette = blackpl;} else if ( pal_5_act == false ) { pal_count += 1;}
- if( secondHand == palette_delay) { targetPalette = new_palette; pal_count += 1;}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment