Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //please declare variables
- static uint8_t startIndex = 0;
- void loop()
- {
- //ChangePalettePeriodically();
- //static uint8_t startIndex = 0;
- //startIndex = startIndex + 1; /* motion speed */
- //FillLEDsFromPaletteColors( startIndex);
- FillLEDsFromPaletteColors2( startIndex);
- //FastLED.show();
- //FastLED.delay(1000 / UPDATES_PER_SECOND);
- }
- // Original
- void FillLEDsFromPaletteColors( uint8_t colorIndex)
- {
- uint8_t brightness = 255;
- for( int i = 0; i < NUM_LEDS; ++i) {
- leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
- colorIndex += 3;
- }
- }
- // For-loop switched for millis()
- void FillLEDsFromPaletteColors2(){
- currentPalette = RainbowStripeColors_p;
- static uint8_t temp_index = startIndex; //initialize once for colorfrompalette
- if(isLoaded == false){ //leds arent loaded. do nothing but load data
- if(x < NUM_LEDS){ //original for-loop condition for(int i =0; x<NUM_LEDS;i++)
- leds[x] = ColorFromPalette( currentPalette, temp_index, 40, currentBlending );
- temp_index += 3;
- x++; //original for-loop incrementor
- }else if(x == NUM_LEDS){ //leds are full,
- x = 0;
- isLoaded = true; //leds are finally loaded, reset x and wait for timer
- }
- }
- if(millis() - previousMillis >= (20) && isLoaded == true){ //our fastled delay(20)
- previousMillis = millis();
- isLoaded = false; //leds will no longer be loaded at FastLED show is called
- startIndex += 1;
- temp_index = startIndex; //reset temp_index to start index to move led to next
- FastLED.show(); //no longer loaded
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement