/ examples / il91874_simpletest.py
il91874_simpletest.py
 1  """
 2    Simple test script for 2.7" 264x176 Tri-Color display shield
 3    Supported products:
 4    * Adafruit 2.7" Tri-Color ePaper Display Shield
 5      https://www.adafruit.com/product/4229
 6  
 7    This program only requires the adafruit_il91874 library in /lib
 8    for CircuitPython 5.0 and above which has displayio support.
 9  """
10  
11  import time
12  import board
13  import displayio
14  import adafruit_il91874
15  
16  # Used to ensure the display is free in CircuitPython
17  displayio.release_displays()
18  
19  # Define the pins needed for display use on the Metro
20  spi = board.SPI()
21  epd_cs = board.D10
22  epd_dc = board.D9
23  
24  # Create the displayio connection to the display pins
25  display_bus = displayio.FourWire(
26      spi, command=epd_dc, chip_select=epd_cs, baudrate=1000000
27  )
28  time.sleep(1)  # Wait a bit
29  
30  # Create the display object - the third color is red (0xff0000)
31  display = adafruit_il91874.IL91874(
32      display_bus, width=264, height=176, highlight_color=0xFF0000, rotation=90
33  )
34  
35  # Create a display group for our screen objects
36  g = displayio.Group()
37  
38  # Display a ruler graphic from the root directory of the CIRCUITPY drive
39  f = open("/display-ruler.bmp", "rb")
40  
41  pic = displayio.OnDiskBitmap(f)
42  # Create a Tilegrid with the bitmap and put in the displayio group
43  t = displayio.TileGrid(pic, pixel_shader=displayio.ColorConverter())
44  g.append(t)
45  
46  # Place the display group on the screen (does not refresh)
47  display.show(g)
48  
49  # Show the image on the display
50  display.refresh()
51  
52  print("refreshed")
53  
54  # Do Not refresh the screen more often than every 180 seconds
55  #   for eInk displays! Rapid refreshes will damage the panel.
56  time.sleep(180)