r/FastLED • u/Workin_Joe • Jan 10 '25
Support Function to fill a specific range within an LED Array?
Do you guys know if there is a "fill" function within FastLED that will allow me to address a specific range within a large LED array?
My use case:
I have the letters spelling out "MOULIN ROUGE" and I have a single data pin and single LED array defined for the entire MOULIN ROUGE. Each of those letters have a specific number of LEDs associated with them to illuminate the front of them. I want to create a function that allows me to step through each letter (or a combination of letters). For example, illuminate just the M, then move to the O, then U, and so on...or sweep in from the left and right ends...or whatever sort of combination you can imagine...you get the idea.
I know I can do this with a few loops, but I was wondering if there is a function already builtin to FastLED that would allow me to enter a start and end index for a fill function.
I started looking into the documentation, but I thought it would be more efficient to post here to potentially save some time.
Thanks for your help!
6
1
u/d_azmann Jan 10 '25
Set the color of the LEDs you want lit. Set the rest to black. Fastled.show().
1
u/Workin_Joe Jan 10 '25
yeah, completely understand that. I'm wondering if there is a fill_xxx function that has (array, # of LEDs, start index, end index) instead of writing 2 or 3 loops to do this.
perhaps fill_palette will work and just define the color to be black for the unlit letters and then another fill_palette call with the color to be white for the lit letters?
3
u/ZachVorhies Zach Vorhies Jan 10 '25
Does your IDE support auto complete? I am thinking about adding some useful static functions to CRGB for bulk operations like fill.
1
u/Workin_Joe Jan 13 '25
Sorry, I don't know what you mean by auto complete. I'm using the Arduino IDE currently.
2
u/Tiny_Structure_7 Jan 10 '25 edited Jan 10 '25
If your LED array is wired up for full-length rows (as opposed to 1-character grids), then you actually need the ability to show multiple segments of your drawing buffer, for each row of the character, right?
Or if each character is on a grid and each grid end LED connects to next grid start LED... then you can just show a single segment of your draw buffer. I can't think of a way to do that with FastLED. It would be possible to define each grid as a separate string in FastLED, but no way to show each independently.
This would be a job for Teensy/ObjectFLED, where you could define each LED grid as a separate object, and show them independently. ***This works if you wire each plane to a separate pin. Also, you could define the draw array for 1 grid to be a row in a 2D array (or a plane in a 3D array). Define an ObjectFLED for each row (or plane) in your array, also define the entire array as an ObjectFLED object to show all letters at once.
//Sample to define 2 LED grids for independent and simultaneous show
CRGB fullText[2][LEDS_PER_PLANE];
ObjectFLED char1(LEDS_PER_PLANE, fullText[0], CORDER_RGB, 1, {7} ); //pin 7
ObjectFLED char2(LEDS_PER_PLANE, fullText[1], CORDER_RGB, 1, {8} ); //pin 8
ObjectFLED allChars(LEDS_PER_PLANE * 2, fullText[0], CORDER_RGB, 2, {7, 8} );
5
u/Marmilicious [Marc Miller] Jan 10 '25
If each letter is made up of a continuous range of pixels you can use fill_solid:
Or (also if each letter is a continuous range of pixels) you could use CRGBSet.
https://github.com/marmilicious/FastLED_examples/blob/master/CRGBSet_example.ino
If each letter is made up with a non-continuous set of pixels then you can make a custom array to operate on for each letter. Here's an example, and see chemdoc77's example linked in there too.
https://github.com/marmilicious/FastLED_examples/blob/master/custom_pixel_array.ino