Adafruit_Learning_System_Gu.../CircuitPython_displayio/displayio_pixels/code.py
2021-08-23 14:14:41 -04:00

36 lines
725 B
Python

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
# Loop forever so you can enjoy your image
while True:
pass