Go Down

Topic: st7920 lcd12864 glcd (Read 719 times) previous topic - next topic

Ginocasa

Good evening,
this is my first topic.... a greetings to all.
I bought a display 128x64 in the object i try it with the library of DF Robot on arduino uno r3 and i try the example included and it's working well. Now i would like to  draw something, i try the command and some sketch but i have many fault in the compiler.I try also the u8glib but same problem. Someone could help me, i need just a sketch that draw a line on the screen. I use the lcd in parallel mode.
Thanks in advance.
Gino :smiley-eek:

olikraus

Maybe you could post your code and the exact error you get with U8glib.

Oliver

Ginocasa

Thank Oliver for your answer and happy new year.
Yesterday i understand the correct string for set the ugc8 and my display, but my code doesn't display the lines:

#include "U8glib.h"

U8GLIB_ST7920_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, U8G_PIN_NONE, U8G_PIN_NONE, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16



void setup(void) {
  // flip screen, if required
  //u8g.setRot180();
}
void loop(void) {
 
u8g.drawHLine(20, 50, 47);
  u8g.drawVLine(58, 50, 12);
 
  }

Thanks
Gino

olikraus

Happy New Year!

U8glib is a little bit special. Graphics commands, need to be part of the "picture loop":

Code: [Select]
void loop(void) {
  u8g.firstPage(); 
  do {
    u8g.drawHLine(20, 50, 47);
    u8g.drawVLine(58, 50, 12);
  } while( u8g.nextPage() );
}


See also http://code.google.com/p/u8glib/wiki/thelloworld

Oliver

Ginocasa

Hi Oliver,
thanks for you answer. Now is working and i see the line. But i don't understan why i need to do this, i try also to read the reference of library. This command is a problem for me because after a command u8g.firstPage(); it clean the screen.In my  sketch after some seconds i want check an input and i need to draw another line without clean the screen.
Gino

olikraus

Quote
But i don't understan why i need to do this

This is a FAQ.I tried to explain this here: http://code.google.com/p/u8glib/wiki/tpictureloop

Quote
In my  sketch after some seconds i want check an input and i need to draw another line without clean the screen.

As explained in the link above, this can not be done with U8glib. You need to redraw the first line also.
Usually this is solved by an additional variable:

Code: [Select]
int is_second_line = 0;
void draw(void)
{
  // draw first line
...
if ( is_second_line != 0 )
{
    // draw second line
}
}

As soon as you set the variable "is_second_line" to an nonezero value, both lines will be drawn.

Oliver

Ginocasa

Hi Oliver, thanks! I solved my problem as you propose. Before i read the value of analog port and after i draw all the lines. I found also on internet a procedure for increase the sample rate of adc : http://highfellow.org/arduino:sample_rate.
Thanks a lot.
Gino

Go Up