Hi, Looking for a bit of advice when working with an array of arrays,

Hi,

Looking for a bit of advice when working with an array of arrays, im using ws2812b leds and ive got 5 individual strips. Id like to ‘reuse’ 3 of them in one big array but only for one switch case. ive had a look into the documentation and it seems as though you have to use entirely separate pins for the different arrays so ive used two different pins for the different arrays but wired them to the same strip. Ive even tried using two transistors per strip to switch between data inputs. But no matter what i do as soon as i switch my cases the leds freeze up and im assuming its because its being sent both sets of data.
So i hoping somebody here has some insight into either a coding fix or a mechanical fix to this problem. Also it could just be totally my fault but all the code works before ive tried to set up this multiple array. Ill only include up the my setup in this post for the length of it but i can provide it all if necessary.

Thanks in advance.

#include "FastLED.h"

FASTLED_USING_NAMESPACE

#define FEATURE_NUM_LEDS 22
#define CASE_NUM_LEDS 28
#define UNDERGLOW_NUM_LEDS 15
#define UP_VERTICAL_NUM_LEDS 15
#define DOWN_VERTICAL_NUM_LEDS 15
#define ALL_NUM_LEDS (FEATURE_NUM_LEDS + CASE_NUM_LEDS + UNDERGLOW_NUM_LEDS)
#define FEATURE_STRIP 11
#define FEATURE_STRIP_ALT 10
#define UP_VERTICAL_STRIP 9
#define DOWN_VERTICAL_STRIP 8
#define CASE_STRIP 3
#define CASE_STRIP_ALT 4
#define UNDERGLOW_STRIP 7
#define UNDERGLOW_STRIP_ALT 6
#define BRIGHTNESS  200
#define FRAMES_PER_SECOND 100
#define COOLING  55
#define SPARKING 120
#define THERMAL_PIN A1
#define CURRENT_PIN 12
#define CYCLE_BUTTON_PIN 2
#define TRANS_PIN 13
#define ALT_TRANS_PIN 5
#define SOUND_PIN A0
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))

int currentSensorValue = 0;
int ledMode=0;
int tempSensorValue = 0;
int dimTime=0;
int l=0;
int m=0;
int n=0;

uint8_t gHue=0;
uint8_t gCurrentPatternNumber = 0; 

unsigned long previousMillis = 0;
unsigned long currentMillis = 0;

bool gReverseDirection = false;
bool oldState = HIGH;

CRGB featureLeds[FEATURE_NUM_LEDS];
CRGB caseLeds [CASE_NUM_LEDS];
CRGB underglowLeds [UNDERGLOW_NUM_LEDS];
CRGB upVerticalLeds [UP_VERTICAL_NUM_LEDS];
CRGB downVerticalLeds [DOWN_VERTICAL_NUM_LEDS];
CRGB allLeds [ALL_NUM_LEDS];


void setup() { 
      
      delay (3000);


       //singleArrays
  	  FastLED.addLeds<NEOPIXEL, FEATURE_STRIP>(featureLeds, FEATURE_NUM_LEDS);
      FastLED.addLeds<NEOPIXEL, CASE_STRIP>(caseLeds, CASE_NUM_LEDS);
      FastLED.addLeds<NEOPIXEL, UP_VERTICAL_STRIP>(upVerticalLeds, UP_VERTICAL_NUM_LEDS);
      FastLED.addLeds<NEOPIXEL, DOWN_VERTICAL_STRIP>(downVerticalLeds, DOWN_VERTICAL_NUM_LEDS);
      FastLED.addLeds<NEOPIXEL, UNDERGLOW_STRIP>(underglowLeds, UNDERGLOW_NUM_LEDS);

       // arrayOfArrays
      FastLED.addLeds<NEOPIXEL, FEATURE_STRIP_ALT>(allLeds ,UNDERGLOW_NUM_LEDS ,FEATURE_NUM_LEDS);
      FastLED.addLeds<NEOPIXEL, CASE_STRIP_ALT>(allLeds ,0 , CASE_NUM_LEDS);
      FastLED.addLeds<NEOPIXEL, UNDERGLOW_STRIP_ALT>(allLeds ,CASE_NUM_LEDS ,UNDERGLOW_NUM_LEDS);
      
      
      FastLED.setBrightness( BRIGHTNESS );
      pinMode(CURRENT_PIN, INPUT);
      pinMode(CYCLE_BUTTON_PIN, INPUT_PULLUP);
      pinMode(TRANS_PIN, OUTPUT);
      pinMode(ALT_TRANS_PIN, OUTPUT);
      Serial.begin (9600);
       
      }

I would try to do this in code for the case where you want the three strips to act as one and not mess with different physical wiring.

For the case where it’s to act as one array, set all the color data in another temp CRGB array that is the size of the sum of the number of pixels in the three strips. And then appropriately copy the data from the temp array to the three separate strips before displaying.

@marmil yeah i think i see what you mean, so rather than combining the 3 existing strips in an array, create one that wont get ‘shown’ and then use memmove to copy the appropriate blocks of leds to each original strip individually?
neat idea, ill give it a go tonight or tomorrow!

@Chris_D Correct!

@marmil Thanks! not used memmove before (also pretty new to coding) but im assuming that this is the correct usage??

case 2:

           memmove8( &underglowLeds, &allLeds[0,UNDERGLOW_NUM_LEDS-1], (ALL_NUM_LEDS));
           memmove8( &featureLeds, &allLeds[UNDERGLOW_NUM_LEDS-1, FEATURE_NUM_LEDS-1], (ALL_NUM_LEDS));
           memmove8( &caseLeds, &allLeds[FEATURE_NUM_LEDS-1, CASE_NUM_LEDS-1], (ALL_NUM_LEDS));
      
           gPatterns[gCurrentPatternNumber]();
           FastLED.show();
          
        break;

Sorry if the formatting is terrible on here. The part im not to sure about is the selection of the group size to copy, the allLeds[ ] parts…

The snytax for memmove8 is:
memmove8( &destination[start position], &source[start position], size of pixel data )

So for example, if your source, allLeds, was a total of 24 pixels and it was being split in 3rds, you could move the data for the first 8, middle 8, and last 8 pixels to the three destination strips like this:

//move allLeds pixel data 0-7 to underglow 0-7
memmove8( &underglowLeds[0], &allLeds[0], 8*sizeof(CRGB) );

//move allLeds pixel data 8-15 to featureLeds 0-7
memmove8( &featureLeds[0], &allLeds[8], 8*sizeof(CRGB) );

//move allLeds pixel data 16-23 to caseLeds 0-7
memmove8( &caseLeds[0], &allLeds[16], 8*sizeof(CRGB) );

If memmove8 might be too confusing for others using your code a few simple “for loops” can be much easier to understand and is often still plenty fast.

Also, here’s an example using memmove8:

@marmil thanks i searched high and low for a good example, that made it alot clearer! strangely it sort of worked with what i had.

Thanks again, actually pretty simple once you have a good pattern to follow.