Reading from PROGMEM

I'm writing data to an LCD's RAM, and I'm using the following command:

  for(int j = 0x00; j < 0x12C0; j++){
    spi_transfer(pgm_read_byte(&(SampleImage[j])));

My question is whether I'm correctly using the pgm_read_byte command. I'm reading values from an array of hex values, and the "spi_transfer" should send these specific hex values to my display. For some reason, the values being sent to the display are only correct if they are 0x00 or 0xFF.

Can you show us how you declared the SampleImage[] array? That could make a big difference.

--
Check out our new shield: http://www.ruggedcircuits.com/html/gadget_shield.html

Sure, here's a sample:

static prog_uint8_t SampleImage[0x12C0] PROGMEM = {
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
  0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 . . .

The array was generated with the tool provided in KS0108 GLCD library (although my code does not use that library). Then I modified the information to declare the array slightly.

My concern comes from the fact that I get what appears to be a smudge or smear on my ChLCD array instead of the actual image. I'm guessing that I'm not reading hex values and passing hex values to the display's RAM.

Well, the PROGMEM is redundant as it's already incorporated into the prog_uint8_t type, but I don't think that's really the problem (doesn't hurt to try without it though).

Try reading the array out and printing it to the screen with Serial.println first. It's possible the problem is with the interface to the LCD, not the PROGMEM part. That part actually looks right.

--
Check out our new shield: http://www.ruggedcircuits.com/html/gadget_shield.html

When I print it with Serial.print, it comes out correctly if I specify it as a HEX value. Otherwise it comes out as gibberish.

Sooo....problem solved? You specify it as a HEX value and it's correct?

--
Check out our new shield: http://www.ruggedcircuits.com/html/gadget_shield.html

Yes, I just solved the problem. It looks like I'm reading correctly from the PROGMEM, but you need to load the memory with the correct data. In my case, I found out that the KS0108 library tool writes hex values vertically, and I needed them horizontally for the Kent Display (ChLCD) that I was using.

I found this BMP (bitmap) to HEX software that made it work: Bitmap converter for mono and color LCD displays This is a wonderful piece of software!

The actual way you are getting the data is a problem.

What you need to do is get pointers to your data in PROGMEM and pass them.

I spent a few good hours researching this the other week for my own project and found this the most useful: http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=38003