Understanding the language, error messages, etc.
Post a reply

Arrays again confusing ...

Sun Aug 10, 2014 6:28 pm

I have this:

Code:
const int PROGMEM soundfx[2][9] = {
  {1, 0, 1, -1, 1, -1, 0, 0, 7},
  {0, 0, 0, 0, 0, 0, 0, 0, 0},
};



and in the game-loop:

Code:
  for (int test=0; test<9; test++) {
    gb.display.cursorX=0;
    gb.display.cursorY=test*6;
    gb.display.print(soundfx[0][test]);
  }


... but instead of showing me 1, 0, 1, -1, 1, -1, 0, 0, 7 on the screen, it gives me strange values like 0, 1, 7, -280, 260, 1, 15872, 7 ...

Where my mistake here?

Re: Arrays again confusing ...

Sun Aug 10, 2014 6:33 pm

You can't access PROGMEM arrays directly, you have to use the pgm_read_word or pgm_read_byte macros (cf Arduino - PROGMEM)
Post a reply