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