I’m just getting started with FastLED, and wondering if there is a way to tell FastLED that a string is reversed? I’ll have two strings that will appear as one, but the strings will start in the middle. For ease of programming, I’d like to have one “logical” array, and pass pointers to the first element, and Nth element as two separate strings and have FastLED treat 0-N as if they were N-0. If there’s no direct way to do that, I’ll deal with it, but it would be handy if FastLED could do it for me.
There’s no direct way that I know of. Code as normal filling up both strips. Then call a function that reverses the first half. And then call FastLED.show().
Just always run your extra reversing function before any show() call.
Or you can create a second CRGB array, so you’d have something like:
CRGB leds_working; or CRGB tmp_leds, etc.
Populate your pixel data into one, then copy to the other to display, appropriately reversing one half as you go. (This uses more memory since you create a second CRGB array, but it’s sometimes a bit easier to work this way depending on how you’re processing your pixel data.)
If you always want the strips to mirror each other, you could simply connect them to the same data pin and declare the number of LEDs as N.
The other way is to use the CRGBArray declaration and functions. Write the pattern to one of the strips and simply copy it to the other in reverse order. Search this forum for the details.
You should be able to do this https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples#one-array-many-strips
and also create a “Map” to reorder the LEDs properly.
Here is an example based on the example code in the wiki but with mapping also included. https://gist.github.com/Blink515/08adcce86bf30f5ba8c31042865bf6f2
I haven’t tested it but it should work. You’ll obviously want to adjust for the num of leds you are using.
@Brian_Lewis I came up with the same idea, but implemented it as a macro: #define vINDEX(n) ((n>=NUM_LEDS_GABLE) ? n : (n-(NUM_LEDS_GABLE-1))
So I reference leds[vINDEX(i)]. The map is probably a few instructions faster, but I’m not planning any high refresh rates on this project.
See the CRGBArray stuff. Quite a nice set of abstractions, including “reversed”.