U8g2: Graphics Library for Monochrome OLEDs and LCDs

Finally, I finished U8glib V2, now called U8g2.

What is u8g2?

  • Graphics library for many different monochrome OLEDs and LCDs
  • Supported display controller: SSD1305, SSD1306, SSD1309, SSD1322, SSD1325, SSD1327, SSD1606, SH1106, T6963, RA8835, LC7981, PCD8544, PCF8812, UC1604, UC1608, UC1610, UC1611, UC1701, ST7565, ST7567, NT7534, IST3020, ST7920, LD7032, KS0108
  • Powerful text and graphics commands
  • More than 700 fonts available

Installation

  • … via Arduino IDE library manager (search for “u8g2”).

What are the most important advantages compared to U8glib V1?

  • Full “RAM” memory buffer without picture loop (u8glib picture loop still supported).
  • Arduino SPI and TWI Libraries instead of custom code. This will make u8g2 much more portable.
  • Successfully tested with AVR, SAM and ESP8266 boards.
  • Support for Unicode and UTF-8: Unicode chars appear on the display as written in the Arduino IDE.
  • Faster compilation.
  • High speed text only API (U8x8).
  • Hardware 180 degree rotation for some displays available.
  • Compressed font format.
  • Button debounce event handler included.
  • 90% compatible with U8glib.

Limitations

  • Still support for some display controller is missing compared to U8glib V1 :frowning:

Links

Oliver

Edit: Updated list of supported controllers and font count.
Edit: Updated list of supported controllers (v2.9.1)
Edit: Updated list of supported controllers (v2.12.6)

uc1701_dogs102_uno_board_640.jpg

unicode_utf8_st7920.jpg

Oliver,
This sounds very interesting.
I wanted to take a look at it but the links are not working for me.

Your olikraus repository does not seem to be showing up on github.

Also, it would be nice to have a link to the actual repository to know where to find it for those needing to ad it manually vs using the lib manager.

BTW, while I see it shows up in the library manager, the library manager can’t find it either.

update:
apparently the library manager can install it, but it can’t find the repository if you click on the “More info” link which tries to go here: GitHub - olikraus/u8g2: U8glib library for monochrome displays, version 2
— bill

Hi Bill
The Arduino Repo is here: GitHub - olikraus/U8g2_Arduino: U8glib V2 library for Arduino

And yes, somehow parts of my repo got disabled. I am in contact with the githup support, so I hope it get fixed within the next 12h.

The link to the library should be this:
https://github.com/olikraus/U8g2_Arduino/archive/2.0.7.zip

Oliver

Dear Oliver

How can I add other languages to U8g2 lib? (for example "u8g_font_unifont_12_13")
I tried to add "u8g_font_unifont_12_13" to "U8g2_fonts.c" file but I was not successful

I like to display large characters on an EA DOGM240S-6 display and suppose this is possible using the U8g2 lib but where can I find fonts that can be used. I planed to use an Arduino UNO the drive the display and control my audio preamplifier.

Farzad321554:
Dear Oliver

How can I add other languages to U8g2 lib? (for example "u8g_font_unifont_12_13")
I tried to add "u8g_font_unifont_12_13" to "U8g2_fonts.c" file but I was not successful

This should be done in the next release (which should be online in the next few hours)

Oliver

Dalojan:
I like to display large characters on an EA DOGM240S-6 display and suppose this is possible using the U8g2 lib but where can I find fonts that can be used. I planed to use an Arduino UNO the drive the display and control my audio preamplifier.

Currently the DOGM240 is not yet ported to U8g2. However you can probably use U8glib for this display.

U8glib also contains some very large fonts: fontsize · olikraus/u8glib Wiki · GitHub

Oliver

Version 2.1.5 of U8g2 is now available.

The new release includes support for the T6963 display and also includes some more fonts.

Oliver

Hej

I have some trouble with this library and my 128x64 (ST7920) display.
With the previous version (U8Glib) everything works fine. I'm able to steer my display via parallel connection and the following constructor :

U8GLIB_ST7920_128X64_1X u8g(22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di/RS=17,rw=16

But now I try to use the new U8g2 and basically nothing work. No signs on the screen.
I'm 100% sure that something is wrong with my code and not with the library, but I need some help.

There are some example constructors in the code examples but there seems to be no constructor for parallel mode for the ST7920 with 128x64. So I thought it should be quite easy to make a new one based on the example for the 192x32 ST7920.

So I wrote this :

U8G2_ST7920_128X64_2_8080 u8g2(U8G2_R0, 22, 23, 24, 25, 26, 27, 28, 29, /*enable=*/30, /*cs=*/U8X8_PIN_NONE, /*dc=*/32, /*reset=*/ U8X8_PIN_NONE);

This is just one version of several different I've tried. But nothing works.
It's also quite confusing what "RS" actually really is.
On this site it tells me that CS is RS :

According to the ST7920 datasheet, the PSB pin selects between the 8-Bit and the serial (SPI) bus. For the serial bus, pin "RS" is "Chip-Select", pin "E" will be the clock input and pin "RW" acts as data line.

On this site it tells me that RS is dc :

dc Data/command selection line (register select) D/C, A0, RS, ...

So how do I have to wire the display correct and build the constructor for my display.
As I said, with the older U8Glib everything works fine.

Thanks Oli!!! I love your library, its so easy to use and works so well with every small monocrhome OLED/LCD i have used.

I love not having to "Clear" the screen too! Means no flicker!

Hm, strange...
Because Parallel connection with u8g2 doenst seems to work with my ST7920 128x64 display I thought I'll "just" switch to SPI.
Now I found out that SPI also doesnt work. I get strange artifacts in the display and can barely see the text that should be written on the display.
Then I tried software SPI and that works fine, but horrible slow.

Then, again, I switched back to U8Glib and everything work awesome.

I've tested this with my Mega, Nano and Uno. So I dont think that the controller is the guilty one.

Any ideas?
I would still prefer to use the parallel mode :wink:

The latest version is working on SIMBLEE hardware with software I2C on a SSD1306 128x64.
Thank you.

However the I2c speed seems to be slow. what is the proper way to adjust the software I2C speed?

liquid-light:
Hm, strange...
Because Parallel connection with u8g2 doenst seems to work with my ST7920 128x64 display I thought I'll "just" switch to SPI.
Now I found out that SPI also doesnt work. I get strange artifacts in the display and can barely see the text that should be written on the display.
Then I tried software SPI and that works fine, but horrible slow.

Then, again, I switched back to U8Glib and everything work awesome.

I've tested this with my Mega, Nano and Uno. So I dont think that the controller is the guilty one.

Any ideas?
I would still prefer to use the parallel mode :wink:

The latest version of U8g2 includes some modifications on HW SPI side, but i will also create an issue here and do some testing with the ST7920.

Oliver

liquid-light:
It's also quite confusing what "RS" actually really is.
On this site it tells me that CS is RS :
setup_tutorial · olikraus/u8g2 Wiki · GitHub
On this site it tells me that RS is dc :
u8g2setupcpp · olikraus/u8g2 Wiki · GitHub
So how do I have to wire the display correct and build the constructor for my display.
As I said, with the older U8Glib everything works fine.

ok... i will also look at this. Thanks for pointing out this difference.

Oliver

supermac:
The latest version is working on SIMBLEE hardware with software I2C on a SSD1306 128x64.
Thank you.

However the I2c speed seems to be slow. what is the proper way to adjust the software I2C speed?

U8g2 just uses the Arduino Wire Lib as it is. To my knowledge there are no options to turn on fast mode or something similar.
For speedup you could also use the full frame mode (F in the constructor) if there is enough RAM available.

Oliver

I just got an SSD1306 128x64 I2C Oled display today, going to spend tomorrow figuring it out. I see SPI mentioned a lot, does this library do I2C?

olikraus:
The latest version of U8g2 includes some modifications on HW SPI side, but i will also create an issue here and do some testing with the ST7920.

Oliver

liquid-light:
Hm, strange...
Because Parallel connection with u8g2 doenst seems to work with my ST7920 128x64 display I thought I'll "just" switch to SPI.
Now I found out that SPI also doesnt work. I get strange artifacts in the display and can barely see the text that should be written on the display.
Then I tried software SPI and that works fine, but horrible slow.

Then, again, I switched back to U8Glib and everything work awesome.

I've tested this with my Mega, Nano and Uno. So I dont think that the controller is the guilty one.

Any ideas?
I would still prefer to use the parallel mode :wink:

I have fixed an issue with ST7920 and U8g2.
The latest library zip is here:
https://github.com/olikraus/U8g2_Arduino/archive/master.zip
Use the library zip install menu for installation.

Oliver

INTP:
I just got an SSD1306 128x64 I2C Oled display today, going to spend tomorrow figuring it out. I see SPI mentioned a lot, does this library do I2C?

Yes, I2C is supported. In Arduino World this is usually called Wire-Lib or TWI.

Oliver

The parallel interface for the ST920 should be of type 6800 (RS, R/W, E) and not of 8080 type ? i've tested mi Digole 12864ZW screen with the ST920 controller and works ok with u8glib but not with u8g2 that uses a different constructor.

u8glib ->U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16, 19);

u8g2 -> U8G2_ST7920_128X64_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /enable=/ 18, /cs=/ 16, /dc=/ 17, /reset=/ 19);

Hello,

I was hopeing to use this library with my 128x64 display (sh1106) and my nodemcu esp8266 board, but haven't managed yet. I have tried the display with my Arduino UNO and the u8glib-library and it works great with this setting --> U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI

Since U8glib doesn't support esp8266-boards I was really happy to hear about the u8g2 library. So, I tried the GraphicsTest from the Full-buffer example without any success =(

I used the following constructor lines:
U8G2_SH1106_128X64_NONAME_2_SW_I2C u8g2(U8G2_R0, 12, 14, 8 );

And connected the display in the following way:
VCC -- > 3v3 (nodemcu)
GND --> GND
SDA --> D6 (nodemcu, GPIO12)
SCL --> D5 (nodemcu, GPIO14)

But, nothing on the display.. Any suggestions?

Regars Mattias

** PROBLEM SOLVED **
This constructor lines worked for me :
U8G2_SH1106_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, 14, 12, U8X8_PIN_NONE);