Hello All, I have a Question regarding referencing more than 1 pixel at a time. I am currently messing around with the Blink example from FastLED. It was a simple enough example and I used what it taught me to write this code: http://pastebin.com/raw.php?i=1hnCfy54
I’m sure its pretty crude and could be improved upon 1000 fold. But my question is can it be made shorter? Rather than Referencing each pixel one by one is there a way to reference the 4 pixels in a group such as defining a variable for each section.
For the most part the code does what I want it to do but my concern is memory. I have a few more Animations to write and if this code is any indication in size then I fear I may not have enough memory.
Once again Thanks for your help!!!
Here is the LED Setup I am using… Maybe it will help you visualize what I’m doing. The LEDs are not wired yet so I can’t Light them up… My Apologies.
Don’t forget to check out all of the examples you can find online and play around with them. There’s a LOT of stuff you can do with very little code and the examples provided with FastLED are the best place to start.
This is possible:
leds[0] = leds[1] = leds[2] = leds[3] = CRGB::Red;
A better option:
fill_solid(leds, 4, CRGB(0,0,255); // Fill 4 pixels with blue, starting at leds[0]
or
fill_solid(leds+5, 10, CRGB::Blue); // Fill 10 pixels with blue, starting at leds[5]
Another option would be a loop:
for (int x=0; x<5; x=x+1) { leds[x]= CHSV(0,255,255); }
The new CRGBSet/CRGBArray stuff ends up being better - to set all the lads to a color you can just say leds = CRGB::Blue; or if you want to set a portion of the less to a color leds(5,8) = CRGB::Blue. Of course, where the new stuff starts becoming really useful will be for doing more complex manipulations of subsets of led data.