Bodmer / TFT_eSPI

Arduino and PlatformIO IDE compatible TFT library optimised for the Raspberry Pi Pico (RP2040), STM32, ESP8266 and ESP32 that supports different driver chips
Other
3.8k stars 1.09k forks source link

A thought: A potentially easy way to support mono OLEDs #1355

Closed jpasqua closed 2 years ago

jpasqua commented 3 years ago

I have been popping back and forth between a project with a color display using TFT_eSPI, and another project using a small monochrome OLED like this one. Libraries for the latter typically have a 1bpp frame buffer. You draw into that and when you're ready, you call a display() function which copies the data to the hardware.

It occurred to me that it would be possible to support a bunch of these mono OLEDs using TFT_eSPI by writing to a 1bpp sprite of the same dimensions as the physical display and adding code to do the copy from the sprite buffer to the device. Since these devices typically use a y-major pixel ordering, the drawPixel function would need a minor change. I think the rest of the sprite functions use drawPixel for the 1bpp case.

I'm going to experiment with this by using TFT_eSPI to draw into a sprite and a native OLED library to do the device initialization and buffer copy.

If there is an easier way to use TFT_eSPI with these displays, I would definitely be interested. I'd like having a way to stick to one (rich) graphics API.

Bodmer commented 3 years ago

I did make some experimental changes to TFT_eSPI to support ePaper displays which have a similar frame data format.

The display image is drawn in a 1bpp sprite, then the sprite is sent to an ePaper class. See the Floyd_Steinberg example for clues as to how this was done. I am not able to help further as I have not looked at mono OLEDs, but the same principles seem to apply to the ePaper displays.