Skip to content

uPesy now ships to the entire European Union

Contents Menu Expand Light mode Dark mode Auto light/dark mode

MicroPython FrameBuffer

Understanding the module framebuf

Screen drivers generally do not send data directly when a pixel is modified. It would take too much time each time. All pixels of the screen are sent at once. To do this, a buffer contains the state of all the pixels on the screen: it is an array of bits of type bytearray()

fonctionnement interne framebuffer micropython

Our Python program will modify the state of the pixels in the buffer. Then this buffer will be sent periodically to the screen to update the “physical” pixels, possibly in the background by the driver. The Python library’s driver communicates with the screen via an I2C bus, SPI.

The module FrameBuffer is only an abstraction layer that proposes a generic buffer. The data format will be configured according to the type of pixels on the screen (monochrome, RGB).

We can also have several small FrameBuffer for the same screen, with a size smaller than the screen dimensions. This will be very useful for moving small images on the screen.

Warning

In this article, we use the SS1306 monochrome screen for more simplicity

Primitive functions

In the examples, display.xx is the variable that represents the driver of your screen.

This article is available to premium members only. You still have 84% to discover.

Subscribe for only 5$/month

Already subscribed? Sign in

We use cookies to make your visit to the site as pleasant as possible. Privacy Policy