/ examples / il0398_simpletest.py
il0398_simpletest.py
 1  """Simple test script for 4.2" 400x300 black and white displays.
 2  
 3  Supported products:
 4    * WaveShare 4.2" Black and White
 5      * https://www.waveshare.com/product/modules/oleds-lcds/e-paper/4.2inch-e-paper.htm
 6      * https://www.waveshare.com/product/modules/oleds-lcds/e-paper/4.2inch-e-paper-module.htm
 7    """
 8  
 9  import time
10  import board
11  import displayio
12  import adafruit_il0398
13  
14  displayio.release_displays()
15  
16  # This pinout works on a Feather M4 and may need to be altered for other boards.
17  spi = board.SPI()  # Uses SCK and MOSI
18  epd_cs = board.D9
19  epd_dc = board.D10
20  epd_reset = board.D5
21  epd_busy = board.D6
22  
23  display_bus = displayio.FourWire(
24      spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
25  )
26  time.sleep(1)
27  
28  display = adafruit_il0398.IL0398(
29      display_bus, width=400, height=300, seconds_per_frame=20, busy_pin=epd_busy
30  )
31  
32  g = displayio.Group()
33  
34  f = open("/display-ruler.bmp", "rb")
35  
36  pic = displayio.OnDiskBitmap(f)
37  t = displayio.TileGrid(pic, pixel_shader=displayio.ColorConverter())
38  g.append(t)
39  
40  display.show(g)
41  
42  display.refresh()
43  
44  time.sleep(120)