How to get Font from EEPROM

Hello every boby.

for (byte c=0; c<8; ++c) {          
     for (byte y=0; y<8; ++y) {
            byte data = (byte) pgm_read_byte (&myfont[disp[line][c]][y]);   // fetch data from program memory
              for (byte x=0; x<8; ++x) {
                if (data & (1<<x)) {
                   // on is off
                   int color = 2;
                   if (line > 1)
                     color = 1;
                     
                   set_pixel((7-x) + (line * 8),y + (c*8),color);
                } else {
                    //set_pixel(x,y,1);
                }
            }
        }
}

}

This is available code ,which i downloaded ,but i don't know how to use detail this syntax :
data = (byte) pgm_read_byte (&myfont[disp[line]

][y])[/color]
This code is so complex ,can you give me some codes simpler ,because i search on Google serveral days ,but difficult to found  =( =(

Thanks

EEPROM != PROGMEM

It's difficult to help with just a code snipped. Please post all the info you have, especially what you're trying to achieve.

Yes,this is a full source.pde
http://www.mediafire.com/?1o5eptd3avscb61

Nice!

Have you noticed this line in font.h ?

const prog_uint8_t PROGMEM BitMap[8] = {                                   // Store in program memory to save RAM

PROGMEM is where the program(!) is stored. RAM and EEPROM are other two types of memory you find in Arduino (well, inside the Atmega328P, actually).

pgm_read_byte is a special function that reads a byte from PROGMEM and brings it into RAM, so it can be used by the program.

I won't repeat here with my own (poor) words what has already been written elsewhere in great detail. Search for PROGMEM.

:slight_smile:

I only want how to use this syntax
data = (byte) pgm_read_byte (&myfont[disp[line]

][y])[/color]

not const prog_uint8_t PROGMEM BitMap[8] = {

Thanks

Please read my previous reply.

Also, I don't find it clear what you're trying to do...

Yes, i hope you don't reply with not useful :0

Thanks

That's the wrong smiley to use when asking for FREE help.

Good luck with your project.

(edit: maybe you misunderstood my previous answer: what I meant is that I don't understand what you're trying to achieve; it wasn't a judgement about your project (which I don't know))

taipscode:
I only want how to use this syntax
data = (byte) pgm_read_byte (&myfont[disp[line]

][y])[/color]

not const prog_uint8_t PROGMEM BitMap[8] = {

[/quote]

pgm_read_byte() is a function in the Arduino library.

I think it is general avr-libc, rather that Arduino specific.

http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html

data = (byte) pgm_read_byte (&myfont[disp[line]

][y])

data = (get 8 pixels ) from (a font-character[pointed to by disp[currentline][current_character][current_character_pixel_line]. 

Which is a complicated way of Saying

if disp[line] = "A simple test"
then disp[line][0] = "A"
       disp[line][1] = " "
       disp[line][2] = "s"
       ... etc

then &myfont[] returns the address of a character inside a font array which holds the (8 x 8 pixels) character.
So &myfont[disp[line][0]] would return the address to the letter "A" in the font array. 

&myfont[disp[line][0]][y] would return 8 pixels of row [y] of the letter "A"
This technique is used to convert a letter to pixels. e.g. (8x8 pixel font)

[font=Courier]
.  .  .  .  .  .  .  .
.  .  .  X  .  .  .  .
.  .  X  .  X  .  .  .
.  X  .  .  .  X  .  .       =>  A
.  X  X  X  X  X  .  .
X  .  .  .  .  .  X  .
X  .  .  .  .  .  X  .
.  .  .  .  .  .  .  .
[/font]

It's reading 8 pixels as a byte. 
Your code then loops through this code with [color=red]for (byte x=0; x<8; ++x)[/color]
And draws a pixel on the screen if it found a pixel in the font.

Thats about it.