0

my arduino nano drives an LED Matrix. evrything works fine. but my "outline path" ist too big for the SRAM, so i try to put it into PROGMEM. Now reading values from this progmem array leads to totally wrong integers. what am i doing wrong?

thx for helping!!

bye andre

void progStarsWarp() {

const static PROGMEM int outlinePath[] = {30, 31, 29, 28, 27, 26, 36, 42, 43, 44, 45, 46, 25, 9, 8, 0, 1, 2, 4, 3, 16, 17, 56, 57, 91, 92, 101, 102, 111, 112, 121, 122, 162, 192, 193, 229, 230, 262, 263, 274, 275, 276, 277, 270, 269, 254, 239, 240, 241, 242, 243, 244, 253, 252, 251, 250, 249, 211, 210, 176, 177, 178, 179, 175, 161, 152, 151, 142, 141, 132, 131, 77, 72, 73, 74, 75, 76, 37, 31};
int *pointerOutlinePath;

FastLED.clear();

for (unsigned int i = 0; i < 79; i++) {
    pointerOutlinePath = &outlinePath[i];
    int test = pgm_read_word(pointerOutlinePath);
    leds.m_LED[outlinePath[test]] = CRGB(getRandomColorValue(), getRandomColorValue(), getRandomColorValue());
}

FastLED.show();
delay(60000);

}

just4phil
  • 25
  • 1
  • 5
  • 1
    `outlinePath[test]`as an index to m_LED looks wrong to me. test will have the values 30, 31, 29, 28 , ... and might eventually be directly the desired index to `leds.m_LED` (who knows?) But as you fill random values there, why set the leds in that strange order? – datafiddler Feb 23 '20 at 17:54
  • 1
    try `int test = pgm_read_word(outlinePath + i);` – Juraj Feb 23 '20 at 17:59
  • great ... thankx for seeing this stupi bug :) .... leds.m_LED[test] = ... fixed it :) – just4phil Feb 23 '20 at 18:00
  • why set the leds in that strange order? -> its not strange .... it is a path around my LED-Matrix, that has the outline of my electric guitar :) – just4phil Feb 23 '20 at 18:03

0 Answers0