So, I’m trying to find a way to modify some of my functions so that I can easily reuse them. I’m working on a project where I will be using multiple arrays of leds, outputting on multiple pins.
I’m having trouble understanding how to pass or reference my Array of RGB values into the function so that I can modify them. This way, I can tell the function which array I’m modifying, and not have to have separate functions for each array. I’ve googled around some tutorials but haven’t had much luck. I figured somebody here must have done it before, considering the nature of the library.
in case you are curious, the reason this isn’t contained within a for() loop is because I must be able to animate different sets of lights at the push of different buttons, so there is a “current pixel” variable for each strip to keep track of the state of the different animations.
//Define Pixel Arrays #define ARRAY1_SIZE 300 //LEDS output on First Data Pin #define ARRAY2_SIZE 64 //LEDS output on Second Data Pin
CRGB leds1[ARRAY1_SIZE];//Create array for RGB LED Control
CRGB leds2[ARRAY2_SIZE];
And here is what happens in the setup loop:
//Other Actions
FastLED.addLeds<NEOPIXEL, DATA1_PIN>(leds[1], ARRAY1_SIZE);
FastLED.addLeds<NEOPIXEL, DATA2_PIN>(leds[2], ARRAY2_SIZE);
I had the idea of using an Array of Arrays, but this would eat up memory really fast, especially I generally have 1 very large array, and then several smaller ones. I would keep them within a singular array, but physical location will be a barrier on this.