gizmo_simpletest.py
1 import time 2 from random import randrange 3 import displayio 4 from adafruit_gizmo import tft_gizmo 5 6 # Create the TFT Gizmo display 7 display = tft_gizmo.TFT_Gizmo() 8 9 # You can now use the display to do whatever you want 10 # Here we show how to draw random pixels 11 12 # Create a bitmap with two colors 13 bitmap = displayio.Bitmap(display.width, display.height, 2) 14 15 # Create a two color palette 16 palette = displayio.Palette(2) 17 palette[0] = 0x000000 18 palette[1] = 0xFFFFFF 19 20 # Create a TileGrid using the Bitmap and Palette 21 tile_grid = displayio.TileGrid(bitmap, pixel_shader=palette) 22 23 # Create a Group 24 group = displayio.Group() 25 26 # Add the TileGrid to the Group 27 group.append(tile_grid) 28 29 # Add the Group to the Display 30 display.show(group) 31 32 # Draw pixels 33 while True: 34 for _ in range(200): 35 x = randrange(0, display.width) 36 y = randrange(0, display.height) 37 bitmap[x, y] = 1 38 time.sleep(0.1) 39 for i in range(display.width * display.height): 40 bitmap[i] = 0