Hii, FastLED library is working just fine .I am stuck with some programming which i need help for.
My problem is with the function named " void FillLEDsFromPaletteColors( unsigned char colorIndex) " which is used in the example that is included in the FastLED library called " colorpalettes ".
the function mentioned above assigns colorIndex +=3 on the last line of the function, It controls the direction of color flow(THIS IS WHAT I UNDERSTAND) i.e when colorIndex +=3 is assigned color direction is from 50 (NUM_LED) towards 1(First LED) & when colorIndex -=3 is assigned color direction is from 1st LED towards 50 (NUM_LED).
NOW, what i need to do is to change the direction successively.
Thank you for your time and help.
Below is the Function where colorIndex is assigned
Yes, instead of filling the whole strip, just fill half (NUM_LEDS/2) and then use a for loop to copy those pixels to the other half before calling show(). Changing dir would then cause the flow to be inward or outward.
We all start somewhere and these are the best sort of exercises to keep learning. Also look at as many examples as you can to find to see how others manipulate things. And copy those examples and mess with a few variables or lines of code at a time to see how it changes the output.
@marmil Hii,
I have a question,how to do the copy thing using for loop that you mentioned earlier is there any example related to it.I tried but could not get the desired output
This would make the second pixel equal to the first.
leds[1] = leds[0];
This would make the last pixel equal to the first.
leds[NUM_LEDS-1] = leds[0];
Using a for loop, you can copy a bunch of pixel data to other pixels.
This copies the pixels from the first half of the strip to the pixels in the second half of the strip, and also reversed the order (copying to last pixel and then back toward the middle) at the same time.
for (uint8_t i = 0; i < NUM_LEDS/2; i++) {
leds[NUM_LEDS-1-i] = leds[i];
}
Here’s another variation of using a loop to copy pixel data from one pixel to another. In this case it’s being used to move (shift) all the data down the strip by one position. It starts at the end and works back toward the beginning of the strip.
for (uint8_t i = NUM_LEDS-1; i > 0; i–) {
leds[i] = leds[i-1]; // shift data down the line by one pixel
}
Step through the above examples on paper if needed to make sure you see how it works. Once you understand it you will think of fun ways to use something like this in your patterns.