|
| 1 | +# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries |
| 2 | +# SPDX-FileCopyrightText: Copyright (c) 2021 Melissa LeBlanc-Williams for Adafruit Industries |
| 3 | +# |
| 4 | +# SPDX-License-Identifier: Unlicense |
| 5 | + |
| 6 | +"""Simple test script for 2.13" 250x122 tri-color display. |
| 7 | +Supported products: |
| 8 | + * Adafruit 2.13" Tri-Color eInk Display Breakout |
| 9 | + * https://www.adafruit.com/product/4947 |
| 10 | + * Adafruit 2.13" Tri-Color eInk Display FeatherWing |
| 11 | + * https://www.adafruit.com/product/4814 |
| 12 | + * Adafruit 2.13" Mono eInk Display FeatherWing |
| 13 | + * https://www.adafruit.com/product/4195 |
| 14 | +
|
| 15 | +
|
| 16 | +""" |
| 17 | + |
| 18 | +import time |
| 19 | +import board |
| 20 | +import displayio |
| 21 | +import adafruit_ssd1680 |
| 22 | + |
| 23 | +displayio.release_displays() |
| 24 | + |
| 25 | +# This pinout works on a Metro M4 and may need to be altered for other boards. |
| 26 | +spi = board.SPI() # Uses SCK and MOSI |
| 27 | +epd_cs = board.CE0 |
| 28 | +epd_dc = board.D22 |
| 29 | +epd_reset = board.D27 # Set to None for FeatherWing |
| 30 | +epd_busy = board.D17 # Set to None for FeatherWing |
| 31 | + |
| 32 | +display_bus = displayio.FourWire( |
| 33 | + spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000 |
| 34 | +) |
| 35 | +time.sleep(1) |
| 36 | + |
| 37 | +# For issues with display not updating top/bottom rows correctly set colstart to 8 |
| 38 | +display = adafruit_ssd1680.SSD1680( |
| 39 | + display_bus, |
| 40 | + width=250, |
| 41 | + height=122, |
| 42 | + busy_pin=epd_busy, |
| 43 | + highlight_color=0xFF0000, |
| 44 | + rotation=90, |
| 45 | +) |
| 46 | + |
| 47 | + |
| 48 | +g = displayio.Group() |
| 49 | + |
| 50 | +with open("display-ruler.bmp", "rb") as f: |
| 51 | + pic = displayio.OnDiskBitmap(f) |
| 52 | + t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader) |
| 53 | + g.append(t) |
| 54 | + |
| 55 | + display.show(g) |
| 56 | + |
| 57 | + display.refresh() |
| 58 | + |
| 59 | + print("refreshed") |
| 60 | + |
| 61 | + time.sleep(display.time_to_refresh + 5) |
| 62 | + # Always refresh a little longer. It's not a problem to refresh |
| 63 | + # a few seconds more, but it's terrible to refresh too early |
| 64 | + # (the display will throw an exception when if the refresh |
| 65 | + # is too soon) |
| 66 | + print("waited correct time") |
| 67 | + |
| 68 | + |
| 69 | +# Keep the display the same |
| 70 | +while True: |
| 71 | + time.sleep(10) |
0 commit comments