Morning folks :-) Loving the FastLED library, this is an incredible piece of work,

gplus
(Ross Cooper-Smith) #1

Morning folks :slight_smile:

Loving the FastLED library, this is an incredible piece of work, but I’m coming at this as a beginner programmer who hasn’t touched C in more than 20 years.

I’ve gotten all my proof of concept code working, but I’m struggling with trying to make it more flexible. I’m writing a user interface where I want the ability for people to add a friendly name to the LED strip, and specify how many LEDs they’re using.

I have a fixed set of CRGB arrays, named leds_A, leds_B… leds_F, and I’m trying to create a way to add friendly names and settings to these.

I think I probably need to be saving a pointer to the CRGB array rather than the string name of the CRGB array, but I’m struggling to find answers online. Can anybody advise either what I’m doing wrong, or whether there’s a better way to do this?

//Structure to define LED strips
typedef struct ledArray_struct
{
String ledStripName;
String ledArray;
int numberOfLeds;
};

//Create an array to track all led strips
ledArray_struct ledStrips[numberLedStrips];

//TODO: Populate this with saved data for actual LED strip details
ledStrips[0].ledStripName = “Top”;
ledStrips[0].ledArray = “leds_A”;
ledStrips[0].numberOfLeds = 7;

//Add LEDs and ensure LEDs are off at start
FastLED.addLeds<LED_TYPE,DATA_PIN_A,CLK_PIN_A,COLOUR_ORDER>(ledStrips[0].ledArray,ledStrips[0].numberOfLeds);
fill_solid(ledStrips[0].ledArray,ledStrips[0].numberOfLeds,CRGB::Black);

(Ken White) #2

@Ross_Cooper-Smith - I would recommend that you look at middle of the following webpage:

That will give you information on how to name strips on different pins. As to CRGB arrays and how to define and name them, you should look at the following examples of using CRGBSet:

and

http://gist.github.com - CRGBSet_Example_3_with_array_fill__and_colorwipe.ino

Here is some FastLED documentation for CRBGSet:

and