Hi all
this is my first post.
I have somme troubles to make my code smaller.
i have a matrix 32*8 controlled by fastled library.
the codes works but i want it to be smaller because i repeat a lot of times the same code exept the name
as example
void LEDMATRIX() {
// Frame 1
FastLED.clear();
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = pgm_read_dword(&(Xmas001[i]));
}
FastLED.show();
delay(400);
// Frame 2
FastLED.clear();
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = pgm_read_dword(&(Xmas002[i]));
}
i want to make the Xmas.... dynamic
i got in mind to do this with a array
char* Xitems [77] = {
"Xmas001" , "Xmas002" , "Xmas003" , "Xmas004" , "Xmas005" , "Xmas006" , "Xmas007" , "Xmas008" , "Xmas009" , "Xmas010" , "Xmas011" , "Xmas012" , "Xmas013" , "Xmas014" , "Xmas015" , "Xmas016" , "Xmas017" , "Xmas018" , "Xmas019" , "Xmas020" , "Xmas021" , "Xmas022" , "Xmas023" , "Xmas024" , "Xmas025" , "Xmas026" , "Xmas027" , "Xmas028" , "Xmas029" , "Xmas030" , "Xmas031" , "Xmas032" , "Xmas033" , "Xmas034" , "Xmas035" , "Xmas036" , "Xmas037" , "Xmas038" , "Xmas039" , "Xmas040" , "Xmas041" , "Xmas042" , "Xmas043" , "Xmas044" , "Xmas045" , "Xmas046" , "Xmas047" , "Xmas048" , "Xmas049" , "Xmas050" , "Xmas051" , "Xmas052" , "Xmas053" , "Xmas054" , "Xmas055" , "Xmas056" , "Xmas057" , "Xmas058" , "Xmas059" , "Xmas060" , "Xmas061" , "Xmas062" , "Xmas063" , "Xmas064" , "Xmas065" , "Xmas066" , "Xmas067" , "Xmas068" , "Xmas069" , "Xmas070" , "Xmas071" , "Xmas072" , "Xmas073" , "Xmas074" , "Xmas075" , "Xmas076" , "Xmas077"
};
so i was trying to do the follow, but that isnt work
void RUNMATRIX() {
// Frame 1-77
FastLED.clear();
/////////////////////
/*
for (byte idx = 0; idx < sizeof(Xitems) / sizeof(Xitems[0]); idx++)
{
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = pgm_read_dword(&(Xitems[idx][i]));
}
}
*/
//////////////// OR
for (int i = 0; i < NUM_LEDS; i++) {
for (byte idx = 0; idx < sizeof(Xitems) / sizeof(Xitems[0]); idx++)
{
leds[i] = pgm_read_dword(&(Xitems[idx][i]));
}
}
any one that can help me?Processing: xmas301_T1.rar...
xmas301_T1.zip (7.1 KB)