U8glib: Graphics Lib for LCDs and OLEDs

Thank you Oliver ( for the Font tips ), and Happy new Year to you , and all who read this topic :slight_smile:
( I'm on the numeric font creation for my project , but the party for the new year's day was pretty hard :slight_smile: )

@Dj_Garfield: Good, but note that there is a size limitation for the glyphs. They can not be larger than about 48/49 pixel.

Oliver

Ok , I keep this in mind , but The Font I expect to create , is 17 pixels Width x 24 pixels Height . Actualy I just test your tips by extracting only chars from 42 to 59 => just displaying time, but I need the ":" char in the font table :). and it works fine :slight_smile:

I can do everything I need with the u8g lib , It is realy a wonderfull one , simple , as fast as the board could be .
I love it :slight_smile:

Edit :
The Font I expect to create is the one who displays the speed as digit numbers in the middle of the screen, the truncated Helv font is used to display time , and odometer informations.

I have a mysterious issue with time displaying : when I put the code to display time on a 40x2 LCD the display is like that : 01:03:30 for example , but here with the 128x64 with the Helv Font I obtain for the same time : 1:3:30 there is no leading 0 .. and I dont know why ...

Edit 2 :

All Right , the font is made :slight_smile: very simply , and is exactly what It was expected :slight_smile: , Now I start from a scratch bdf File , I open it with FONY , and when done : bdf2u8g and It works !:slight_smile:

Edit 3:

For those who wants the font :

// FONT DS-DIGITAL NUMERIC ONLY 
const u8g_fntpgm_uint8_t u8g_font_DSDGNUM[527] U8G_FONT_SECTION("u8g_font_DSDGNUM") = {
  0,16,30,0,251,24,0,0,0,0,48,57,0,25,0,24,
  0,14,24,48,16,1,1,127,248,191,244,223,236,224,28,224,
  28,224,28,224,28,224,28,224,28,192,12,128,4,0,0,128,
  4,192,12,224,28,224,28,224,28,224,28,224,28,224,28,224,
  28,223,236,191,244,127,248,3,24,24,16,12,1,32,96,224,
  224,224,224,224,224,224,224,96,32,0,32,96,224,224,224,224,
  224,224,224,96,32,14,24,48,16,1,1,255,248,127,244,63,
  236,0,28,0,28,0,28,0,28,0,28,0,28,31,236,63,
  244,127,248,191,240,192,0,224,0,224,0,224,0,224,0,224,
  0,224,0,224,0,223,224,191,240,127,248,13,24,48,16,2,
  1,255,240,127,232,63,216,0,56,0,56,0,56,0,56,0,
  56,0,56,63,216,127,232,255,240,127,232,0,24,0,56,0,
  56,0,56,0,56,0,56,0,56,0,56,63,216,127,232,255,
  240,14,22,44,16,1,2,128,4,192,12,224,28,224,28,224,
  28,224,28,224,28,224,28,223,236,191,244,127,248,31,244,0,
  12,0,28,0,28,0,28,0,28,0,28,0,28,0,28,0,
  12,0,4,14,24,48,16,1,1,127,248,191,240,223,224,224,
  0,224,0,224,0,224,0,224,0,224,0,223,224,191,240,127,
  248,63,244,0,12,0,28,0,28,0,28,0,28,0,28,0,
  28,0,28,31,236,63,244,127,248,14,24,48,16,1,1,127,
  248,191,240,223,224,224,0,224,0,224,0,224,0,224,0,224,
  0,223,224,191,240,127,248,191,244,192,12,224,28,224,28,224,
  28,224,28,224,28,224,28,224,28,223,236,191,244,127,248,13,
  23,46,16,2,2,255,240,127,232,63,216,0,56,0,56,0,
  56,0,56,0,56,0,24,0,8,0,0,0,8,0,24,0,
  56,0,56,0,56,0,56,0,56,0,56,0,56,0,56,0,
  24,0,8,14,24,48,16,1,1,127,248,191,244,223,236,224,
  28,224,28,224,28,224,28,224,28,224,28,223,236,191,244,127,
  248,191,244,192,12,224,28,224,28,224,28,224,28,224,28,224,
  28,224,28,223,236,191,244,127,248,14,24,48,16,1,1,127,
  248,191,244,223,236,224,28,224,28,224,28,224,28,224,28,224,
  28,223,236,191,244,127,248,63,244,0,12,0,28,0,28,0,
  28,0,28,0,28,0,28,0,28,31,236,63,244,127,248};

Below all the Files needed for the operation , if someone need some , It's free :slight_smile:

DS-Digital-V1.bdf (2.14 KB)

u8g_font_DS-Digital-V1.c (2.21 KB)

DS-Digital.fon (1.27 KB)

I have a problem getting a SSD1306 128x64 OLED to work. It does not show anything.
The OLED works flawless using the Adafruit lib.
Using the u8glib and any example sketch, I cannot get it to work and I admit it might a case of identifying the correct pins.

The OLED I am trying to work with is this one:
http://www.ebay.com/itm/SPI-IIC-0-96-128X64-White-GreenLand-OLED-Display-Module-SSD1306-for-Arduino-AVR-/310740698356?pt=LH_DefaultDomain_0&hash=item485996c4f4

In the sketch I have uncommented "U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9);"

In the attached picture I have tried to identify the different pins and functions of the board vs Adafruit lib and U8GLIB.
The connections I am most unsure of is MOSI and A0.

Reading the U8G device documentation an comparing it to Adafruit and OLED documentation it seems as MOSI should be connected from the D1 pin on the OLED to PIN 11 on the arduino boardm and a0 should be connected from the DC PIN on the OLED to PIN 9 on the Arduino board.
However it is not working, and I have tried to identify the pins on the OLED according to the U8GLIB terminology, but nothing works. Even when I sporadically move around the connectors on the OLED :wink:

Anyway, I hope someone can shed some light on this.

  • Lars

With the SW SPI constructor
U8GLIB_SSD1306_128X64(sck, mosi, cs, a0 [, reset])
you can use any Arduino pin. For example
U8GLIB_SSD1306_128X64(1,2,3,4)
tells U8glib, that the sck line of the display is connected to pin 1 of the Arduino board, MOSI (data) line is connected to pin 2 of the Arduino and so on. In fact you can mimic the Adafruit setup with U8glib (pin values from your table):
U8GLIB_SSD1306_128X64(10, 9, 12, 11, 13)

Also ensure, that your display is put into serial mode.

Oliver

Just to confirm when using U8glib on Arduino, it's a Software SPI and can therefore use any pins?

U8glib supports SW SPI (with any pins), but also HW SPI.

Oliver

So it uses HW SPI if you define the HW SPI pins in the setup function?

richardtheboffin:
So it uses HW SPI if you define the HW SPI pins in the setup function?

The opposite is true, see page Google Code Archive - Long-term storage for Google Code Project Hosting..

Text copy from there:

SW SPI 	u8g_dev_st7565_64128n_sw_spi 	U8GLIB_64128N(sck, mosi, cs, a0 [, reset]) 	
HW SPI 	u8g_dev_st7565_64128n_hw_spi 	U8GLIB_64128N(cs, a0 [, reset])

Oliver

Have anyone tried to use this lib with Nokia 7110 display? It doesn't work for me and I've tried few configurations for different so-called compatible displays, but didn't work. I need help because I have 3 lcd displays collected from some 7110 phones. Thanks!

Which constructors did you use? The display should be compatible with the ST7565 controller.

Oliver

olikraus:
In fact you can mimic the Adafruit setup with U8glib (pin values from your table):
U8GLIB_SSD1306_128X64(10, 9, 12, 11, 13)
Also ensure, that your display is put into serial mode.
Oliver

Thank you!

Actually, I DID try to mimic the Adafruit example without luck - Thanks to your suggestion, I noticed that I had lacked the RESET PIN - which I did not read about in the documentation.
Thank you very much for a fabulous library and your devoted help to people using your library.

  • Lars

@Lars
Glad to read that your display works.

Oliver

U8glib (Google Code Archive - Long-term storage for Google Code Project Hosting.) version v1.15 is available for download.

Google finally had stopped any new downloads. I had to remove the tab on the google code project page. Please download U8glib from here: Service End for Bintray, JCenter, GoCenter, and ChartCenter | JFrog

The new release includes (together with some bug fixes) the following new features:

  • ProFont family of fonts
  • drawTriangle
  • Support for the UC1608 controller (240x64 pixel)

ProFont comes with several sizes and is very readable

"drawTriangle" draws a filled triangle:

The UC1608 is a modern controller for large COG displays:

Oliver

Hi I am trying to show 2 plots in the same loop on a LCD by using the U8glib library but it fails.

The reason that the plots has to be presented sequentially in the same loop is I am showing an averaged value and FFT result from an analog pin, and whenever the loop update it would pick a new measurement.

I was trying to write the program as the way below, however, it is apparently one of the programming restriction in the library and I would like to ask how can I do the same thing without updating to the new loop?

show plot A
delay 5s
show plot B

Information of LCD and library can be found below:
Used LCD: LM6059, 128x64, Adafruit
Controller: ST7565
GLib: U8glib

Many thanks!

You should break down your task into three independent steps:

loop() {
  do measure and derive other values (FFT)
  display data
  calculate which page should be visible
}

"display data" will look like this:

if ( page_to_display == 1 )
  display_page_1();
else if ( page_to_display == 2 )
  display_page_2();

The "calculate which page should be visible" steps solves the task to calculate a suitable value for "page_to_display". This calculation will be done based on the current system time, which is returned by millis(). So every 5 seconds you could switch the value for "page_to_display" from 1 to 2 and 2 to 1.

Oliver

olikraus:
You should break down your task into three independent steps:

loop() {

do measure and derive other values (FFT)
 display data
 calculate which page should be visible
}




"display data" will look like this:


if ( page_to_display == 1 )
 display_page_1();
else if ( page_to_display == 2 )
 display_page_2();




The "calculate which page should be visible" steps solves the task to calculate a suitable value for "page_to_display". This calculation will be done based on the current system time, which is returned by millis(). So every 5 seconds you could switch the value for "page_to_display" from 1 to 2 and 2 to 1.

Oliver

Thanks for the reply!

I just wonder if I should do the "display data" inside the draw function picture loop or..? as if I do it in the main loop I would need delay(5000) after obtaining the millis() value so as to switch between the display page for every 5 seconds.

could you please explain a bit more detail about how to perform the function as I am confused?

The below is the program structure I am trying to perform and it needs to be finished in one cycle since the system picks new measurement during every cycle.

loop(){
     do measure and derive FFT value
     picture loop {
        draw();
     }
}

draw(){
    for (i=0; i<3; i++){
        display value
        wait 5s
        display FFT result
    }
}

You should not do the delay inside the picture loop.

You could do it like this:

loop(){
     do measure and derive FFT value
     picture loop {
        display value
     }
     wait 5s
     picture loop {
        display FFT result
     }
     wait 5s
}

Oliver

Hi Oliver.
I've been trying the new 4X 8 bit parallel mode for ST7920 and it's an obvious improvement. Thanks.
Since (for what I've seen) the ST7920 has become more "popular", I was wondering if you would reconsider writing the driver for the READ/WRITE/SHIFT low level capabilities of the parallel connection to it.
Keep up the good work!

DukeR:
Hi Oliver.
I've been trying the new 4X 8 bit parallel mode for ST7920 and it's an obvious improvement. Thanks.
Since (for what I've seen) the ST7920 has become more "popular", I was wondering if you would reconsider writing the driver for the READ/WRITE/SHIFT low level capabilities of the parallel connection to it.
Keep up the good work!

Thanks, but your request is not so clear to me It is not so clear me. The parallel connection is there:

    U8GLIB_ST7920_128X64_4X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
        uint8_t en, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE)

But i do not know what you mean by READ/WRITE/SHIFT.

Oliver