U8glib: Graphics Lib for LCDs and OLEDs

I checked v1.03 with my DOGXL160 display. HW SPI and SW SPI are fine. I do not see any issues here.

Oliver

Hi

I have been using the u8g Library to complete a university project. I have been playing around with it and must say that it is fantastic. The one problem I am having is that I want to display a line of ASCII print for a certain period of time, clear the entree screen and then write another set of ASCII text. I am using an ST7920 screen as it was the only one locally available as all shops have sold out of the KS0108. The screen i attached to a DFRobot mega clone...

Please if anyone can help me I have tried so many ways to get this to work but with no success

thanks in advance

Chris

Hi Chris

I am not sure what you mean by "ASCII print". A chart of ASCII glyphs can be produced in this way:

void u8g_ascii_1() {
  char s[2] = " ";
  uint8_t x, y;
  u8g.drawStr( 0, 0, "ASCII page 1");
  for( y = 0; y < 6; y++ ) {
    for( x = 0; x < 16; x++ ) {
      s[0] = y*16 + x + 32;
      u8g.drawStr(x*7, y*10+10, s);
    }
  }
}

As shown in the second tutorial (Google Code Archive - Long-term storage for Google Code Project Hosting.) there is no clear screen command. Instead, as soon as you enter the picture loop, the screen gets cleared.
See also the background article here: Google Code Archive - Long-term storage for Google Code Project Hosting.

In order to display a screen, wait some time and than display another screen, you may use the code and ideas from "GraphicsText.pde" (attached to this post, but also part of the Arduino examples).

Oliver

GraphicsTest.pde (6.38 KB)

hi is it possible to display hindi (indian language) using this library. what i need to do

Hi cnavnath

This is possible. You need a font which contains hindi glyphs. U8glib can use the glyphs from unifont (http://unifoundry.com/unifont.html). The font u8g_font_unifont_18_19 (Google Code Archive - Long-term storage for Google Code Project Hosting.) already contains some Sanskrit glyphs from unicode page 09xx.

You just provide this hindi font to u8glib with the setFont command:

u8g.setFont(u8g_font_unifont_18_19);

After this, you can use u8g.DrawStr(x,y, "abc") to draw the Sanskrit glyphs.

If you need glyphs from another uncode page, you may use bdf2u8g (Google Code Archive - Long-term storage for Google Code Project Hosting.) to construct your own selecton of glyps.
You can also tell me which glyphs you need from unifont and I can construct one or more fonts for you.

Oliver

Edit: Fontname

hii i used this library it very nice.
i am from india and it also supporting my regional language hindi.
but there is one issue that in that language i need to OVERSTRIKE two characters some time.
means if i send "K" and "a"
then result on lcd should be as shown in image
please help me for this

Ka.png

Hi
Overstrike of two chars is no problam. Simply draw the char at the same location

u8g.drawChar(10,10, "K");
u8g.drawChar(10,10, "a");

Of course you need to use a font with latin "a" and "K" glyphs.

Oliver

Oliver,
Is there drawChar() api function :wink:

That aside,

I also played around with overstrike on a modified glcd lib and the resulting characters are not
very legible for a 5x7 font.
The other tricky thing is that the font either needs to be a fixed width
or the variable width characters need to be rendered centered
within a fixed width.

--- bill

Hi Bill

Is there drawChar() api function smiley-wink

Good point. It does not exist on the Arduino C++ interface, but it is there on the C-level interface. It should be added.

The other tricky thing is that the font either needs to be a fixed width
or the variable width characters need to be rendered centered
within a fixed width.

Additionally the are two different "a" out there.

Reference to Wikipedia (A - Wikipedia):

I am not sure, why there is a need to overstrike two glyphs. I would expect, that all common glyphs are inside unifont.

Oliver

I'm wondering if this really is a request/need for digraph support vs overstrike.
The two are very different.
I had to deal with using digraph support in the early 80's when writing
C code on IBM machines and printers.
EBCDIC does not have curly braces in its font.
(Makes C programming really tough)

So the digraph (< is { and >) is }

When the device can render a curly brace it all happens
under the hood and is hidden,
however it can make writing code on devices/terminals or
reading printouts when the digraph is displayed
rather than the actual curly brace characters a bit challenging/confusing sometimes.

--- bill

Also a good question. For sure, u8glib does not support any digraphs.
Oliver

Hi,

u8glib is working great with a st7920 lcd over SPI on my Arduino Nano, but it does not compile for the atmega 32u4 (arduino leonardo) on Arduino 1.0. Using a earlier version of u8glib on arduino 1.0-RC2 works fine.

Hi
What is the u8glib version? What are the exact compiler errors?

Thanks, Oliver

I'm using 1.04. When I said I made it work in 1.0-rc2, I was using 1.23.
You can replicate this error by just selecting the arduino leonardo board in the 1.0 IDE (uncomment its lines from /arduino-1.0/hardware/arduino/boards.txt if you haven't done it already) and try to compile any u8glib sketch (I haven't tried compiling it with other constructors than st7920 over SPI)

/arduino-1.0/libraries/U8glib/utility/u8g_com_arduino_port_d_wr.c: In function ‘u8g_com_arduino_port_d_wr_fn’:
/arduino-1.0/libraries/U8glib/utility/u8g_com_arduino_port_d_wr.c:80:7: error: ‘UCSR0B’ undeclared (first use in this function)
/arduino-1.0/libraries/U8glib/utility/u8g_com_arduino_port_d_wr.c:80:7: note: each undeclared identifier is reported only once for each function it appears in

Ok, thanks. I will fix this in the next release.
As a workaround, you can remove or comment out line 80:

 // UCSR0B = 0;

Oliver

Hi

U8glib v1.05 is now available.

It includes some new icon fonts:

There is a new hardware state backup and restore procedure to solve conflicts
where pins are shared with other devices.
http://code.google.com/p/u8glib/wiki/userreference#setHardwareBackup

U8glib has also been tested with Arduino 1.0.1 IDE.

Additionally I have some experimental code for SSD1306 (Adafruit 128x64 OLED)
and SSD1322 based OLEDs inside the release. This code has not yet been confirmed
because i do not have access to these displays. Any confirmation or bug-reports on
these display types would be great.

Oliver

I had to release v1.06 because of the broken u8g.h file. This will fix the problem with U8G_PROGMEM.

Additional there is now support for SSD1306 (thanks to Yann) and SBN1661 (thanks to Alex).

Project page: Google Code Archive - Long-term storage for Google Code Project Hosting.

Oliver

I'm using the library for the DFRobot ST7920 128 X 64 LCD and it works without a problem, both in serial as in parallel mode. But the weird thing is, is that the parallel mode is a bit slower. In SW serial I got a refresh rate of 6 to 7 frames per sec and in 8bit it goes down to 4 to 5.

Is this normal behavior or am I doing something wrong?

Thanks for the hint. I will investigate this.

Oliver

I'm trying to get NHD-C12864A1Z-FSB-FBW-HTT working with the u8glib, but I'm getting nothing the screen. It works fine with the Adafruit library. I've checked the pin mapping several times and I have connected to the Arduino correctly. I've unsuccessfully tried loading it as the following ST7565 devices: U8GLIB_DOGM128, U8GLIB_LM6059, U8GLIB_LM6063, and U8GLIB_DOGM132. Is there something I'm missing?

New Haven Display
NHD-C12864A1Z-FSB-FBW-HTT

Digikey link

Manual