Make sure you have the latest CircuitPython firmware loaded for your board to use displayio. You can download it from the link below.

Do you want to just set a specific pixel to a specific color? Here's how. Most of the code is the setup of necessary parts - the TileGrid, Palette, and Group. But once everything is setup, you can access pixels with the simple syntax:

Download: file
bitmap[x, y] = color_value

Remember that color_value is not an actual color, but a reference to the associated Palette.

Here's a full example:

Download: file
import board
import displayio

display = board.DISPLAY

# Create a bitmap with two colors
bitmap = displayio.Bitmap(display.width, display.height, 2)

# Create a two color palette
palette = displayio.Palette(2)
palette[0] = 0x000000
palette[1] = 0xffffff

# Create a TileGrid using the Bitmap and Palette
tile_grid = displayio.TileGrid(bitmap, pixel_shader=palette)

# Create a Group
group = displayio.Group()

# Add the TileGrid to the Group
group.append(tile_grid)

# Add the Group to the Display
display.show(group)

# Draw a pixel
bitmap[80, 50] = 1

# Draw even more pixels
for x in range(150, 170):
    for y in range(100, 110):
        bitmap[x, y] = 1
This guide was first published on Apr 30, 2019. It was last updated on Apr 30, 2019.
This page (Draw Pixels) was last updated on Oct 24, 2020.