how to show image in lcd display

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
Posts: 1
Joined: Sat Aug 01, 2020 3:50 pm

how to show image in lcd display

Post by timm-zz » Sat Aug 01, 2020 3:58 pm

i want show image in my devices which driver is st7789v.
i use this lib,
so i can show text ,but i dont know how to show image in screen :(

User avatar
Posts: 492
Joined: Mon Jun 15, 2015 8:03 am

Re: how to show image in lcd display

Post by mcauser » Sat Aug 22, 2020 2:04 pm

Here's how you draw some random colours.

Code: Select all

>>> import random
>>> for i in range(400):
>>>     display.write(None, bytearray([random.getrandbits(8)]))
You use display.write(command=None, data=your-bytes) to send pixel data to the display.

To understand what it is doing, try writing the same 2 bytes, hundreds of times in a loop with a delay on each iteration.
2 bytes = 1 pixel. You will see how the display memory translates to the pixels on screen.

To get a recognisable image on the screen, you need to convert the image into the bytes in the format the driver expects, then write them in the correct order.

The display supports a bunch of different colour depths, 65k-16M.
If you run it at 65K, that's 16 bits per pixel, or RGB565
16M is 24 bits per pixel, or RGB888

You could use the framebuf in RGB565 mode. ... mebuf.html
Create a framebuf, draw some shapes, write to the display.

To show your image, you'll need to convert it to a RGB565 array of bytes. There's tools available online to help with that.
Then configure the driver to run in 65k mode.
Then write that array of bytes.
You'd need to use display.set_window() to position the "cursor" to the desired start pixel in the display memory.
If your display is 240x240 but you only want to draw a 32x32 image, set_window() lets you isolate a section of display memory to write to.

Post Reply