ST7796S driver lv_micropython

I would like to implement the ST7796S display driver, this display.
A Raspi Python Port already exists.
In this forum I have already learned that the ST7796S may be like the ili9488.
TFT_eSPI also supports the screen. I don’t own the module myself, I want to make sure that I can use it with lv_micropython first.
So I would like to know what I would have to rewrite in the source code to get the screen to work.
With best regards!

1 Like

Hi @Christian_Draxl!

That’s great!
I’ll be happy to help you with this, hoping that you could eventually contribute the driver back to LVGL.

You didn’t explicitly say which platform you are targeting.
A driver is usually implemented for a specific architecture. ESP32 driver would be different from Raspi driver, for example.
In the links you sent there are references to Raspi, ESP32, STM32… Which one are you going to use?

While Python and Micropython implement the same Python3 syntax, they are different languages.
This means that a Python driver cannot directly be used on Micropython, but you can probably port much of the code.

One of the main differences is library support. The Raspi Python Port for example imports numpy, spidev, RPi.GPIO libraries which are not available on Micropython.

Sometimes a driver is implemented in C and has a Python API. Writing Python API for a C library is very different between the “original” Python and Micropython, but if you have a C driver for your target architecture then there is a technique to automatically convert the C API into Micropython API.

There are of course other differences between Python and Micropython, a major one is memory management (Python manages reference counting while Micropython uses Garbage Collection), but the end-user experience in both cases is “writing Python3 code”.

This is good!
We already have a pure-Micropython driver for ILI9341 and ILI9488 for ESP32.
Are you targeting ESP32? If so, it should be pretty easy adding ST7796S over there.

If you are targeting Raspi then you can consider using the frame-buffer Micropython driver.
The Linux kernel supports many displays with the Frame Buffer API so this could be a good “generic” solution for many displays.

Yes, I would like to use the display primarily for the ESP32 (in my case WROVER with 8MB PSRAM).

I suppose we can basically expand the ( based on the comparison between the ili9488 and the ST7796?


On this family of displays the interface (SPI) and commands are very similar, and most of the differences are the initialization sequence and the color mode.
Here is the ILI9488 specific initialization.

So all you need to do is derive a new subclass from ili9XXX, set self.init_cmds, self.display_name and self.display_type and call the parent constructor.

If you use the 16-bit/pixel color mode (RGB=(565) 65K colors) then you can probably set display_type to DISPLAY_TYPE_ILI9341 since ILI9341 also uses the same 16 bit color mode. (ILI9488 currently uses 24-bit color mode (RGB=(888) 16.7M colors) )