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