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  import adafruit_ili9341
 8  
 9  # Release any previously configured displays
10  displayio.release_displays()
11  
12  # Setup SPI bus
13  spi_bus = board.SPI()
14  
15  # Digital pins to use
16  tft_cs = board.D10
17  tft_dc = board.D9
18  
19  # Setup the display bus
20  display_bus = displayio.FourWire(spi_bus, command=tft_dc, chip_select=tft_cs)
21  
22  # Setup the Display
23  display = adafruit_ili9341.ILI9341(display_bus, width=320, height=240)
24  
25  #
26  # DONE - now you can use the display however you want
27  #
28  
29  bitmap = displayio.Bitmap(320, 240, 2)
30  
31  palette = displayio.Palette(2)
32  palette[0] = 0
33  palette[1] = 0xFFFFFF
34  
35  for x in range(10, 20):
36      for y in range(10, 20):
37          bitmap[x, y] = 1
38  
39  tile_grid = displayio.TileGrid(bitmap, pixel_shader=palette)
40  
41  group = displayio.Group()
42  group.append(tile_grid)
43  display.show(group)
44  
45  # Loop forever so you can enjoy your image
46  while True:
47      pass