Page buffering for 1.5" OLED display

Hi
Using ESP32 with a Waveshare 1.5inch RGB OLED Display Module, 65K RGB Colors, 128×128 Resolution, SPI Interface. Arduino IDE 2.3.0 and Adafruit_SSD1351.h library.
With the OLED Display the image is created actively on the screen, then the screen has to filled with black before creating the next image. This causes the screen to flash unpleasantly.
Other smaller monochrome screens allow you to generate a complex image in a buffer and then display it. Much nicer to look at. Is this possible with the RGB OLED display?

Can you post a link to where you read that

I'm not sure it is true. I'm not aware of any other type of screen which requires that.

Hi Paul, thanks for the reply. The example sketch "test" in the library demonstrates drawing various shapes. At the start of each one it has a "tft.fillScreen(BLACK);" line to clear the screen.
If it is not used then the previous image remains and the new image is superimposed over it.
If you respond soon and do not hear from me promptly please do not be offended, it is 1am here and I need to get some sleep. I've been up all evening trying to find a solution.

Yes, I'm certain it is possible.

However a smaller monochrome screen like 128x64 will require 128 * 64 / 8 = 1KB bytes of dynamic memory for the buffer. Most arduino like Uno and Nano have 2KB bytes of dynamic memory, which is enough for this buffer.

A 128x128 16-bit RGB screen will require 128 * 128 * 2 = 32KB of dynamic memory for the buffer. Clearly most Arduino do not have enough dynamic memory for such a large buffer.

Perhaps this is the reason why your screen flickers. All drawing is done directly to the screen, not to a buffer, by the library, so that the library is compatible with most Arduino, like Uno and Nano.

To avoid the flickering, you will need to find a new library. The Arduino will need more than 32KB of dynamic memory, which the new library can use as a buffer.

I do not know of a library for this type of OLED which uses a buffer.

Are you displaying actual images on the screen, or text? The common technique with text would be to save the previous text that was display, then before writing the new text to the screen write the old text using the background color. If you are displaying an image, see if the library has an option to draw the image as non-transparent.

Thanks Paul, that is quite a reasonable explanation as to why they have done it that way in the library. Unfortunately I have not been able to find an alternate library which I can get to work with the ESP32.

Hi David, the code is generating an image made of lines, circles (filled and unfilled) and numbers. It will change depending on the inputs from various sensors. It is dynamic with items moving and not all in set places.

I have an idea. I don't know if it will work, but I think it is worth trying.

The Adafruit_SSD1351.h uses another library called Adafruit_GFX.h. This library has a feature that might be what you need. You can create a "canvas" which you maybe could use as a buffer in memory, if it will allow a canvas to be created which is the same size as the screen. Your code would update the canvas in memory, clearing it to black and then re-drawing the image, then finally print the canvas to the screen.

You would need to use GFXcanvas16 class with your display.

Here's some example code. It's not for your screen, but it shows how to use a colour canvas.

Thanks for the lead Paul. It might take me a while to get my head around how to do this. I will update you on my progress then.

Should be pretty easy. Just create your canvas as a global variable, same height and width as the screen. Change all your code that currently clears or draws/writes to the screen to write to the canvas instead. At the end of that code, add the line (from the example code linked above) to copy the canvas to the screen.

If you run into problems, post your attempt (use code tags!).

I am reading about the GFX library. This looks promising. I will try the canvas tomorrow.

Using the canvas feature worked. It was exactly what I was looking for. I had read all I could about the RGB 128 x 128 OLED display and the SSD1351 library for it. I had not thought about exactly what the GFX library did and the link had that information.
Big thanks again to you PaulRB.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.