Hi, Help needed :) Warning - coding question ahead...

Hi,

Help needed :slight_smile:

Warning - coding question ahead…

Just getting started in this whole LED / teensy / arduino / FastLED / OctoWS2811 / micro coding world. So far have successfully put together a Teensy 3.1, using FastLED 3.1 library which talks to the OctoWS2811 library (for performance), with 8 strings of 288 WS2812B LEDs (16 lots of 1m x 144 LED). Can get all sorts of basic effects going, all very cool – & many many thanks to the people who put so many hours into putting this stack together!!!

This will ultimately be for an installation which consists of 8 strings end-to-end (ie a single long string of 2304 LEDs, split up into 8 equidistant segments) running around the perimeter of a room. No problem running this as a single long string, but for various architectural and aesthetic reasons, I want to be able to split this into a ‘main’ (large) and a ‘back’ (small) area, which I can then do different things with (eg dynamic display on main area, slow hue cycle on back area).

To make things easy, thought I could use something like this:

union {
CRGB leds[2304];
struct {
CRGB main_pelment[1920];
CRGB back_pelmet[384];
} ;
} splitleds;

Then I could operate independently on either of the splitleds.main_pelmet[ ] or splitleds.back_pelmet[ ] arrays whilst simply feeding fastled with splitleds.leds[ ] (eg FastLED.show(splitleds.leds)).

Does that make sense? Is this a reasonable way to proceed, or is there a better / alternative / simpler approach?

If it does make sense, then how would I actually do it, as the compiler throws all sorts of errors when I try to use the CRGB object in this manner. Interestingly enough, if I change the data types to, eg ints, then it compiles without an issue (but of course, doesn’t run) - so I’m guessing the concept is sort of ok but there’s some reason I can’t use CRGB like this???

Anyways, any/all help/suggestions much appreciated!!

You can’t make unions of objects that have constructors, which crgb does. Better would be to have:

CRGB leds[2304];

CRGB *front = leds;
CRGB *back = leds + 1920;

Also be aware that 2304 ws2812 LEDs in serial will have a write time of 70ms. Which is going to slaughter your frame rate.

Ahhhh… lightbulb (LED?!) moment… pardon my ignorance… thanks!!!

Re framerate - by getting FastLED to use OctoWS2811, and splitting the 2304 LEDs across 8 strings, I’m getting about 100fps which is just fine for my application (verified by seeing how fast I can get a dot of light to move down the strings - 144 LEDS take roughly about 1.3 seconds).

Thanks again for the superb job with FastLED!!!