code.py
1 # SPDX-FileCopyrightText: 2019 Carter Nelson for Adafruit Industries 2 # 3 # SPDX-License-Identifier: MIT 4 5 import board 6 import displayio 7 8 display = board.DISPLAY 9 10 # Create a bitmap with two colors 11 bitmap = displayio.Bitmap(display.width, display.height, 2) 12 13 # Create a two color palette 14 palette = displayio.Palette(2) 15 palette[0] = 0x000000 16 palette[1] = 0xffffff 17 18 # Create a TileGrid using the Bitmap and Palette 19 tile_grid = displayio.TileGrid(bitmap, pixel_shader=palette) 20 21 # Create a Group 22 group = displayio.Group() 23 24 # Add the TileGrid to the Group 25 group.append(tile_grid) 26 27 # Add the Group to the Display 28 display.show(group) 29 30 # Draw a pixel 31 bitmap[80, 50] = 1 32 33 # Draw even more pixels 34 for x in range(150, 170): 35 for y in range(100, 110): 36 bitmap[x, y] = 1 37 38 # Loop forever so you can enjoy your image 39 while True: 40 pass