Simple test

Ensure your device works with this simple test.

examples/il0398_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""Simple test script for 4.2" 400x300 black and white displays.
 5
 6Supported products:
 7  * WaveShare 4.2" Black and White
 8    * https://www.waveshare.com/product/modules/oleds-lcds/e-paper/4.2inch-e-paper.htm
 9    * https://www.waveshare.com/product/modules/oleds-lcds/e-paper/4.2inch-e-paper-module.htm
10  """
11
12import time
13import board
14import displayio
15import adafruit_il0398
16
17# Compatibility with both CircuitPython 8.x.x and 9.x.x.
18# Remove after 8.x.x is no longer a supported release.
19try:
20    from fourwire import FourWire
21except ImportError:
22    from displayio import FourWire
23
24displayio.release_displays()
25
26# This pinout works on a Feather M4 and may need to be altered for other boards.
27spi = board.SPI()  # Uses SCK and MOSI
28epd_cs = board.D9
29epd_dc = board.D10
30epd_reset = board.D5
31epd_busy = board.D6
32
33display_bus = FourWire(
34    spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
35)
36time.sleep(1)
37
38display = adafruit_il0398.IL0398(
39    display_bus, width=400, height=300, seconds_per_frame=20, busy_pin=epd_busy
40)
41
42g = displayio.Group()
43
44with open("/display-ruler.bmp", "rb") as f:
45    pic = displayio.OnDiskBitmap(f)
46    # CircuitPython 6 & 7 compatible
47    t = displayio.TileGrid(
48        pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter())
49    )
50    # CircuitPython 7 compatible only
51    # t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
52    g.append(t)
53
54    display.root_group = g
55
56    display.refresh()
57
58    time.sleep(120)

Simple test

Ensure your device works with this simple test.

examples/il0398_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""Simple test script for 4.2" 400x300 tri-color displays.
 5
 6Supported products:
 7  * WaveShare 4.2" Color
 8    * https://www.waveshare.com/product/modules/oleds-lcds/e-paper/4.2inch-e-paper-b.htm
 9    * https://www.waveshare.com/product/modules/oleds-lcds/e-paper/4.2inch-e-paper-c.htm
10    * https://www.waveshare.com/product/modules/oleds-lcds/e-paper/4.2inch-e-paper-module-c.htm
11    * https://www.waveshare.com/product/modules/oleds-lcds/e-paper/4.2inch-e-paper-module-b.htm
12  """
13
14import time
15import board
16import displayio
17import adafruit_il0398
18
19# Compatibility with both CircuitPython 8.x.x and 9.x.x.
20# Remove after 8.x.x is no longer a supported release.
21try:
22    from fourwire import FourWire
23except ImportError:
24    from displayio import FourWire
25
26displayio.release_displays()
27
28# This pinout works on a Feather M4 and may need to be altered for other boards.
29spi = board.SPI()  # Uses SCK and MOSI
30epd_cs = board.D9
31epd_dc = board.D10
32epd_reset = board.D5
33epd_busy = board.D6
34
35display_bus = FourWire(
36    spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
37)
38time.sleep(1)
39
40display = adafruit_il0398.IL0398(
41    display_bus,
42    width=400,
43    height=300,
44    seconds_per_frame=20,
45    highlight_color=0xFF0000,
46    busy_pin=epd_busy,
47)
48
49g = displayio.Group()
50
51with open("/display-ruler.bmp", "rb") as f:
52    pic = displayio.OnDiskBitmap(f)
53    # CircuitPython 6 & 7 compatible
54    t = displayio.TileGrid(
55        pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter())
56    )
57    # CircuitPython 7 compatible only
58    # t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
59    g.append(t)
60
61    display.root_group = g
62
63    display.refresh()
64
65    time.sleep(120)