hi everyone , does anyone know what is the fast way to copy array of byte data to array of CRGB data ? is there any fast inbuilt function such as memmove() or read readBytes() to copy byte array [3*NUMLED] to CRGB leds[NUMLED]
You didn’t say whether you’re using AVR or ARM or ESP or something else, and if using a 32 bit chip, whether you can arrange for the byte array to be aligned to a 32 bit address…
Actually I’m ESP user but I thought this is not related to any hardware architecture and maybe FastLED have in built function to copy array of color data to CRGB array structure, right now I’m using such following function
static uint8_t * BUFFER;
BUFFER= (uint8_t )malloc(NUM_LEDS3);
uint8_t p;
p=BUFFER;
for(int i = 0; i < NUM_LEDS3; i+=3) leds[i/3] = CRGB(&(p+i),&(p+i+1),&(p+i+2));
but I’m not sure how optimistic this would be
just do memcpy(leds, BUFFER, NUM_LEDS*3);
Daniel you mean memcpy don’t care the copy byte type to custom strut type (in size of 3)
memcpy doesn’t care at all - it just copies bytes around. (And the structure of CRGB was done/chosen intentionally so that you could easily do things like this)
I’ve check , you right , it is binary copy , thanks