testing u8glib and GLCD 12864

Hi everybody, i'm testing a GLCD 128x64 with the u8glib but i have some little problems with a simple counter, i don't understand why if i try to do a simple for_loop it doesn't work properly and the lcd show me only the parity numbers i think the problems is with the library infact i also tried a 4x4 keyboard and i have to press any key 2 times to view the number for example if i want to see a sequence like 1-2-3 i have to press 1-anykey-2-anykey-3.. can somebody help me? :~ Thank you very much ;)

I need to see the code to give more specific suggestion, but here is some idea:

WRONG:

  int x = 0;
  for(;;) {
    u8g.firstPage();  
    do {
      u8g.setFont(u8g_font_unifont);
      u8g.setPrintPos(0, 20); 
      u8g.print(x);
      x++;                   // WRONG: x is changed within the picture loop
    } while( u8g.nextPage() );
  }

Correct:

  int x = 0;
  for(;;) {
    u8g.firstPage();  
    do {
      u8g.setFont(u8g_font_unifont);
      u8g.setPrintPos(0, 20); 
      u8g.print(x);    
    } while( u8g.nextPage() );
    x++;
  }

This is explained here http://code.google.com/p/u8glib/wiki/thelloworld and here http://code.google.com/p/u8glib/wiki/tpictureloop

Another example is the use of the ADC converter: WRONG:

  for(;;) {
    u8g.firstPage();  
    do {
      u8g.setFont(u8g_font_unifont);
      u8g.setPrintPos(0, 20); 
      u8g.print(analogRead(3));             // Wrong: Output is different with each iteration of the loop
    } while( u8g.nextPage() );
  }

Correct:

  int x = 0;
  for(;;) {
    x = analogRead(3);
    u8g.firstPage();  
    do {
      u8g.setFont(u8g_font_unifont);
      u8g.setPrintPos(0, 20); 
      u8g.print(x);
    } while( u8g.nextPage() );
  }

A similar mistake has happend here: http://bobdavis321.blogspot.de/2013/06/universal-8-bit-graphics-library-bug.html. I asked Bob to fix this article (you will find a small UPDATE note there), because the this is not a bug in U8glib.

Oliver

Thank you so much! Thanks to your suggestion i was able to do that counter! i read that reference page but i wasn't able to understand much :sweat_smile: Thank you again if i have some other trouble i'll ask you :)