Go Down

Topic: SSD1306 - U8g2lib Framerate? (Read 1 time) previous topic - next topic

LucaRuggier

I am not disagreeing with the logic behind it, however, look at the following picture.

https://i.imgur.com/ObxuKdy.jpg

I am testing the refresh rate by setting a single pixel at a time, filling the display, top left to bottom right, with 4ms delay nested in the loop. This results in 40.005 seconds to draw 8192 frames, giving an average frame rate of 204.77 FPS.

Setting my slow-mo camera to 240 fps. I was able to capture individual pixel changes on most occasions. As you can see from the second and fourth frames. In the third frame 2 pixel were changed which is probably down to slight timings. I cannot set the slow motion frame rate any higher as the resolution drops and I can no longer discern the pixels.

Seeing single pixel changes means that the display is showing 204.77 pixels per second, keeping up with the ESP32's FPS output.

Is there an explanation on this?

david_prentice

Your camera is capturing a frame every 4.17 ms
Your sketch is averaging a new frame every 4.88ms

I suspect that what this actually means is that most frames appear at 4.16ms and occasional frames appear at more than 4.88ms.

Easy enough to see with a Logic Analyser.
Bear in mind that the ESP32 will probably be blitting the SSD1306 using DMA.
The ESP32 has lots of other tasks to get on with.   e.g. operating the Wireless whether you asked it or not.

Does it matter?    A human can't see 240FPS.   I don't know how quickly the OLED pixels can actually change.

Monochrome animations work quite nicely on the OLED.
Now run the same animation on a GLCD.   You just get a blurry mess.

Regardless of Wireless,  it seems unlikely that your 4.17ms period capture would ever catch a 2-pixel change.

If you do not have a Logic Analyser,  post your code.   Someone might try it for themselves.

David.

olikraus

There are two additions to u8g2:

I have added "setBusClock" to allow manual tuning of the I2C (and SPI) clock speed. This function is already available in the u8g2 version of the Arduino IDE.

Another speed improvement is the upcoming option to update only parts of the screen. This is discussed here. This issue also contains some working code for this.

Oliver

david_prentice

#18
Nov 21, 2018, 11:18 pm Last Edit: Nov 21, 2018, 11:35 pm by david_prentice
I was intrigued by the theoretical FPS (Frames Per Second) that can be achieved with a 128x64 SSD1306.

Normally you would display an XBM bitmap or an Adafruit bitmap.
An animation simply consists of displaying each frame in sequence.

I have attached a sketch that animates 15 frames on a SSD1306.
The time for 15 frames is printed on the Serial Terminal.   15 frames at 30 FPS would take 500 ms.

Since your "animation" is in Flash,   you might just as well pre-process it into the actual format used in the library screen buffer.  

The result is dramatic.   I can achieve 240 FPS on a Uno using SPI !!    (280 FPS with Adafruit_SSD1306)

Note that the sketch uses current versions of U8g2lib and Adafruit_SSD1306.
You can change bus speeds with u8g2.setBusClock()
Or with the new full-fat constructors from Adafruit_SSD1306

David.

p.s.   does anyone have any nice monochrome animations suitable for 128x64?
A Uno can store up to 20 full frames in Flash memory.
Monochrome Line animations can work with bigger TFT screens e.g. 240x240
I can resize a GIF, JPG, ... on a PC.   And convert to the RAW buffer format.

Go Up