Blinka makes her debut on the big screen! With this library you can use CircuitPython displayio code on PC and Raspberry Pi to output to a PyGame window instead of a hardware display connected to I2C or SPI. This makes it easy to to use displayio elements on HDMI and other large format screens.
Warning: you must check display.check_quit() in the main loop and break if it's true in order to correctly handle the close button!
Auto refresh works differently for this library than for native CircuitPython implementations due to technical limitations of Pygame.
Pygame does not support updating the UI and refreshing the display from a
background thread but this is how CircuitPython implements it. To work around
this limitation, the library tells the main thread to refresh the display on
the next occasion. This happens whenever you call display.check_quit().
To keep your UI responsive, make sure to
- call
display.check_quit()on a regular basis- do lengthy processing (e.g. fetching data from the net) in a separate thread. This thread should only update data, but not any UI elements (e.g. labels).
If you disable auto-refresh, the display will still refresh on certain externally triggered events from the window-manager of your OS. This includes events like maximizing a window, moving it, uncovering it and so on. Failing to react to these events might make the window-manager angry and you will be asked what to do with the unresponsive window.
This driver depends on:
Please ensure all dependencies are available they can be installed with pip3
This driver can optionally make use of these displayio module libraries:
They can be installed with pip3.
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:
pip3 install blinka-displayio-pygamedisplayTo install system-wide (this may be required in some cases):
sudo pip3 install blinka-displayio-pygamedisplayTo install in a virtual environment in your current project:
mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install blinka-displayio-pygamedisplayimport displayio
from blinka_displayio_pygamedisplay import PyGameDisplay
display = PyGameDisplay(width=320, height=240)
splash = displayio.Group()
display.show(splash)
color_bitmap = displayio.Bitmap(display.width, display.height, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0x00FF00 # Bright Green
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
splash.append(bg_sprite)
while True:
if display.check_quit():
breakwidth(required) - The width of the window. A value of zero maximizes the windowheight(required) - The height of the window. A value of zero maximizes the windowicon(optional) - An icon for the PyGame windowcaption(optional) - A caption for the PyGame windownative_frames_per_second(optional) - High values result in high CPU loadhw_accel(optional) - Whether to use hardware acceleration. Default is Trueflags(optional) - Pygame display flags, e.g. pygame.FULLSCREEN or pygame.NOFRAME
If you encounter GL or EGL Pygame errors, try setting hw_accel to False to disable hardware acceleration. Performance may be reduced.
Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.
For information on building library documentation, please check out this guide.
