I have 4 dotstar strips. To access them in the right order i want to combine 4 arrays:
CRGB leds_left[50];
CRGB leds_right[50];
CRGB leds_top[100];
CRGB leds_bottom[100];
is it possible to combine these arrays in a way that i can address each LED with index 0..299?
0..49 are on the left strip
50..149 on the top
150..199 on the right
200..299 on the bottom
i already searched a lot. but i could not get it to work with malloc and memcpy.
What do you mean by "combine these arrays" ? Do you mean that you want to access the arrays in that order ? What populates the data in the arrays ?
CRGB leds_left[300];
CRGB* leds_right = leds_left + 50;
CRGB* leds_top = leds_left + 100;
CRGB* leds_bottom = leds_left + 200;
All in one array, but accessed with the same name/syntax.
Thank you Whandall! i found a workaround before your answer.
It's not a beautiful solution, but it's working:
void setLED(int number, CRGB color){
if (number < leds_left_size){
leds_left[number] = color;
}else if (number >= leds_left_size && number < leds_left_size + leds_top_size){
leds_top[number - leds_left_size] = color;
}else if (number >= leds_left_size + leds_top_size && number < leds_top_size + leds_left_size + leds_right_size){
leds_right[number - leds_left_size - leds_top_size] = color;
}else{
leds_bottom[number - leds_left_size - leds_top_size - leds_right_size] = color;
}
}
now i can only call setLED(247, CRGB(0,0,255)) and the 47th LED on the bottom strip will update