U8g2: Graphics Library for Monochrome OLEDs and LCDs

Hi Oliver

Thanks for making your u8g2 library available. Do you have plans to implement the capability to update only part of the screen in order to improve performance? Since sendBuffer and firstPage/nextPage update the entire screen in one go, it is quite slow to render an animated bitmap.

Thanks, Alan

@Jama & PaulRB
The ST7920 has been improved a lot for speed. Maybe I did too much for this.
What is your Arduino Board?

You can locate file u8x8_d_st7920.c. Uncomment the delay in lines 136 and 139. Will this help?

Oliver

Starburst:
Hi Oliver

Thanks for making your u8g2 library available. Do you have plans to implement the capability to update only part of the screen in order to improve performance? Since sendBuffer and firstPage/nextPage update the entire screen in one go, it is quite slow to render an animated bitmap.

Thanks, Alan

You could use the direct buffer interface:

Another option is to use the u8x8 API. In fact you could use u8g2 and u8x8 interface together on the same display.

Oliver

Hi,

does anyone have a working example for the function:

u8g2.userInterfaceInputValue("Select Voltage", "DAC= ", &v, 0, 5, 1, " V");

The documentation is very well but it looks like I don´t understand how to use it.

Uwe

EDIT: Done! I did a mistake with dim the var locally, but must be global. Now it works :slight_smile:

Hi Oliver.
My Oled display does not appear exactly some Vietnamese characters or string when I use unifont_t_latin. Ex: 'Ộ;ệ;ă;ơ...'
I was wondering if you would mind including Vietnamese font to this library.

Thank you very much.

nphumy:
Hi Oliver.
My Oled display does not appear exactly some Vietnamese characters or string when I use unifont_t_latin. Ex: 'Ộ;ệ;ă;ơ...'
I was wondering if you would mind including Vietnamese font to this library.

Thank you very much.

Best would be to create an issue here: Issues · olikraus/u8g2 · GitHub

I also need to know the unicodes which should be added.

Oliver

Beginner here,

First i want to say thank you Oliver for this amazing library. i am trying to implement the "scrolling text" example from the library work on a teensy 3.1.

The issue i have is that my text is kind of "long" so it can not be displayed so i looked at the docs and at this wiki page:

And it says:

U8g2 is configured for 8 Bit mode by default. For any device with a pixel width of 256 or higher, you must uncomment (remove the //) from the following line in u8g2.h:

//#define U8G2_16BIT

Problem is that, i am using the U8g2 arduino library that you can install from the arduino IDE itself and first i do not have any u8g2.h file, all i have is a U8g2lib.h which is located in: ARDUINO\libraries\U8g2\src
And i have searched in U8g2lib.h for a //#define U8G2_16BIT comment but i could not find any.

  1. Could you please help me ?
  2. My other question is, is there any way to make the text scroll faster or have a way to control the speed of the scroll ?

I have put my code below just in case even if i suppose the problem is not in the code.

Cheers.

/*

ScrollingText.ino

This will scroll text on the display.
Enable U8g2 16 bit mode (see FAQ) for larger text!



#include <Arduino.h>
#include <U8g2lib.h>

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif


/*
U8glib Example Overview:
Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption
Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards.
U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only.

This is a page buffer example.

*/

U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);   // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED


// This example shows a scrolling text.
// If U8G2_16BIT is not set (default), then the pixel width of the text must be lesser than 128
// If U8G2_16BIT is set, then the pixel width an be up to 32000 


u8g2_uint_t offset; // current offset for the scrolling text
u8g2_uint_t width; // pixel width of the scrolling text (must be lesser than 128 unless U8G2_16BIT is defined
const char *text = "Sunday 12/05/2017  Troom: 22.5° Text: 21° "; // scroll this text from right to left


void setup(void) {

/* U8g2 Project: SSD1306 Test Board */
//pinMode(10, OUTPUT);
//pinMode(9, OUTPUT);
//digitalWrite(10, 0);
//digitalWrite(9, 0); 

/* U8g2 Project: T6963 Test Board */
//pinMode(18, OUTPUT);
//digitalWrite(18, 1); 

/* U8g2 Project: KS0108 Test Board */
//pinMode(16, OUTPUT);
//digitalWrite(16, 0); 

u8g2.begin();
u8g2.setContrast(1); // lowest possible

u8g2.setFont(u8g2_font_inb30_mr); // set the target font to calculate the pixel width
width = u8g2.getUTF8Width(text); // calculate the pixel width of the text

u8g2.setFontMode(0); // enable transparent mode, which is faster
}


void loop(void) {
u8g2_uint_t x;

u8g2.firstPage();
do {

// draw the scrolling text at current offset
x = offset;
u8g2.setFont(u8g2_font_inb30_mr); // set the target font
do { // repeated drawing of the scrolling text...
u8g2.drawUTF8(x, 30, text); // draw the scolling text
x += width; // add the pixel width of the scrolling text
} while (x < u8g2.getDisplayWidth()); // draw again until the complete display is filled

u8g2.setFont(u8g2_font_inb16_mr); // draw the current pixel width
u8g2.setCursor(0, 58);
u8g2.print(width); // this value must be lesser than 128 unless U8G2_16BIT is set

} while (u8g2.nextPage());

offset -= 1; // scroll by one pixel
if ((u8g2_uint_t)offset < (u8g2_uint_t)-width)
offset = 0; // start over again

delay(10); // do some small delay
}

Hi

There should be a folder ARDUINO\libraries\U8g2\src\clib. Inside there you will find u8g2.h

The speed depends on the uC. But you can also increase the offset, like

offset -= 2; // scroll by two pixel

Oliver

Thank you very much for your answer Oliver, everything is working correctly now.

Have you tried compiling U8g2 examples in ArduinoDroid? I have had no success.

I have been able to upload basic examples (blink, etc) and also the test example in Adafruit library for the PCD8544. I'm using and Arduino Pro Mini connected with a CP2012 converter and the PCD8544 display.

I have installed the U8g2 library through the library manager of the IDE but have also tried using the zip from github but I still have errors during compiling, namely "undefined reference to" errors.

I have contacted the author of the app but no response yet. If you could install the app and try to compile an example sketch i´d be very grateful.

Note: ArduinoDroid doesnt let the user modify and immediately compile example sketches as it happens with the Arduino IDE. That is, in ArduinoDroid, after uncommenting the constructor, the user needs to save as a new sketch, then compile and upload.

I once installed this App, but I already failed with basic examples. If I remember correctly the App is incompatible with Android 7.x. Not sure whether this is fixed meanwhile.

Oliver

Very well. The changelog of the app makes it look like those problems have been dealt with, however i'm using Android 5.1 in a 10.1" Archos tablet.

Still, I would ask the readers of this post to give it a try. I have subscribed to the thread and hopefully some solution will come up, as the app is useful to me to make small adjustment in the code while at the field.

thank you,

Francisco

Looks like ArduinoDroid works better now, but indeed I also get the undef'ed error for u8g2. For me it looks like ArduinoDroid does not recognice the C code, which is part of U8g2 Lib.

Oliver

Thank you very much for your time. Hopefully the developer will solve the issue.

Hi Oliver!

what a outstanding work!

I'm trying to use e-paper display from WaveShare with Arduino Nano.
Will your library work?
Maybe i will move towards ESP8266 as it has more RAM.

Question: is you library suitable to controll the following e-paper modules (SPI communication) :

http://www.waveshare.com/wiki/2.9inch_e-Paper_Module

http://www.waveshare.com/wiki/1.54inch_e-Paper_Module

http://www.waveshare.com/wiki/2.13inch_e-Paper_HAT

and this one (UART communication):

One more thing: i tried to load ZIP file from GitHub:

to my Arduino IDE 1.6.8

but i got error like: ZIP file doesn't contain proper library.

???

You can install u8g2 from the Arduino Library Manager. Additionally the zip file is available here:

https://github.com/olikraus/U8g2_Arduino/archive/master.zip

U8g2 support SSD1606 and SSD1607 based e-paper devices.

Oliver

Thank you Oliver,

i looked at the arduino library but it seems there are only two e-paper modules supported: SSD1606 (172x72 pixels) and SSD1607 (200x200 pixels). Is there any quick way to change screen resolution or it is controller chip specific feature?

bogus105:
i looked at the arduino library but it seems there are only two e-paper modules supported: SSD1606 (172x72 pixels) and SSD1607 (200x200 pixels). Is there any quick way to change screen resolution or it is controller chip specific feature?

Depends on what you mean by quick. It also depends on the complexity of the controller.
For example adding support for the SSD1606 took a week or so. But I had the device in my lab. Without access to the device, it usually takes longer.

First step would be to create an issue in the github u8g2 tracker. Then we need to collect all required information about the controller and the display. After that I will create a draft version of the new device.

Oliver