PROGMEM for arrays not working :(

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I have a huge array and I'm trying to put it in the program memory.

OK, I have the ATXmega128A1, which only has 8k ram. I'm trying to put a picture on my LCD. Now I tested the PCD, I can write regular strings and stuff, so I know hardware is good.

In order to not have a big post (size wise), I cut most of the array elements, but here's my array.

[/code]

uint8_t logo[] =
{
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
0xFF,0xFF,
};

gsetpixel(x,y, (GCOLOR) pallete[logo[i]); 

When I tried it like this was 1/4 of the picture it worked, but if I had the whole picture it becomes to big for ram and I tried to add PROGMEM to the array

uint8_t logo[] PROGMEM = ....

I can see the memory usage on the Data went down but the picture isn't coming out good. I tried adding pgm_read_byte

gsetpixel(x,y, (GCOLOR) pallete[pgm_read_byte
(logo[i]));

And that didn't work either.

Any help will be greatly appreiated

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

pgm_read_byte(logo[i])
->
pgm_read_byte(&logo[i])

Stefan Ernst

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

omg, thanks dude, always good to have a second pair of eyes.

It works now!