|
1 |
| -"""Simple test script for 2.13" 212x104 tri-color display. |
2 |
| -
|
| 1 | +"""Simple test script for Adafruit 2.13" 212x104 tri-color display |
3 | 2 | Supported products:
|
4 | 3 | * Adafruit 2.13" Tri-Color Display Breakout
|
5 |
| - * https://www.adafruit.com/product/4086 |
6 |
| - """ |
| 4 | + * https://www.adafruit.com/product/4086 (breakout) or |
| 5 | + * https://www.adafruit.com/product/4128 (FeatherWing) |
| 6 | +""" |
7 | 7 |
|
8 | 8 | import time
|
9 | 9 | import board
|
10 | 10 | import displayio
|
11 | 11 | import adafruit_il0373
|
12 | 12 |
|
| 13 | +# Used to ensure the display is free in CircuitPython |
13 | 14 | displayio.release_displays()
|
14 | 15 |
|
15 |
| -# This pinout works on a Feather M4 and may need to be altered for other boards. |
16 |
| -spi = board.SPI() # Uses SCK and MOSI |
| 16 | +# Define the pins needed for display use |
| 17 | +# This pinout is for a Feather M4 and may be different for other boards |
| 18 | +spi = board.SPI() # Uses SCK and MOSI |
17 | 19 | epd_cs = board.D9
|
18 | 20 | epd_dc = board.D10
|
19 | 21 | epd_reset = board.D5
|
20 | 22 | epd_busy = board.D6
|
21 | 23 |
|
22 |
| -display_bus = displayio.FourWire(spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, |
23 |
| - baudrate=1000000) |
24 |
| -time.sleep(1) |
| 24 | +# Create the displayio connection to the display pins |
| 25 | +display_bus = displayio.FourWire(spi, command=epd_dc, chip_select=epd_cs, |
| 26 | + reset=epd_reset, baudrate=1000000) |
| 27 | +time.sleep(1) # Wait a bit |
25 | 28 |
|
26 |
| -display = adafruit_il0373.IL0373(display_bus, width=212, height=104, rotation=90, busy_pin=epd_busy, |
| 29 | +# Create the display object - the third color is red (0xff0000) |
| 30 | +display = adafruit_il0373.IL0373(display_bus, width=212, height=104, |
| 31 | + rotation=90, busy_pin=epd_busy, |
27 | 32 | highlight_color=0xff0000)
|
28 | 33 |
|
| 34 | +# Create a display group for our screen objects |
29 | 35 | g = displayio.Group()
|
30 | 36 |
|
| 37 | +# Display a ruler graphic from the root directory of the CIRCUITPY drive |
31 | 38 | f = open("/display-ruler.bmp", "rb")
|
32 | 39 |
|
33 | 40 | pic = displayio.OnDiskBitmap(f)
|
| 41 | +# Create a Tilegrid with the bitmap and put in the displayio group |
34 | 42 | t = displayio.TileGrid(pic, pixel_shader=displayio.ColorConverter())
|
35 | 43 | g.append(t)
|
36 | 44 |
|
| 45 | +# Place the display group on the screen |
37 | 46 | display.show(g)
|
38 | 47 |
|
| 48 | +# Refresh the display to have it actually show |
| 49 | +# NOTE: Do not refresh eInk displays more often than seconds or more! |
39 | 50 | display.refresh()
|
40 |
| - |
41 | 51 | print("refreshed")
|
42 | 52 |
|
43 | 53 | time.sleep(120)
|
0 commit comments