"""
CircuitPython (8.2.0) exercise run on Raspberry Pi Pico
display on 2.13" 250x122 3-color Epaper (with SSD1680 driver).
- ref -
CircuitPython SSD1680 Library:
https://docs.circuitpython.org/projects/ssd1680/en/latest/index.html
Quickstart using Adafruit eInk/ePaper displays with CircuitPython:
https://learn.adafruit.com/quickstart-using-adafruit-eink-epaper-displays-with-circuitpython
"""
import time
import board
import busio
import displayio
import adafruit_ssd1680
import terminalio
from adafruit_display_text import label
# import label
BLACK = 0x000000
WHITE = 0xFFFFFF
RED = 0xFF0000
FOREGROUND_COLOR = RED
BACKGROUND_COLOR = WHITE
displayio.release_displays()
"""
e-paper Pico GPIO
------------------
1 BUSY GP0
2 RES GP5
3 D/C GP1
4 CS GP4
5 SCL GP2
6 SDA GP3
7 GND GND
8 VCC 3V3
"""
# init display
epd_clk = board.GP2
epd_mosi = board.GP3
epd_spi = busio.SPI(clock=epd_clk, MOSI=epd_mosi)
epd_busy = board.GP0
epd_res = board.GP5
epd_dc = board.GP1
epd_cs = board.GP4
display_bus = displayio.FourWire(
epd_spi, command=epd_dc, chip_select=epd_cs, reset=epd_res, baudrate=1000000
)
time.sleep(1)
# For issues with display not updating top/bottom rows correctly set colstart to 8
display = adafruit_ssd1680.SSD1680(
display_bus,
colstart=1,
width=296,
height=128,
busy_pin=epd_busy,
highlight_color=0xFF0000,
rotation=270,
busy_pin=epd_busy,
)
# Create a display group for our screen objects
g = displayio.Group()
# Set a background
background_bitmap = displayio.Bitmap(display.width, display.height, 1)
# Map colors in a palette
palette = displayio.Palette(1)
palette[0] = BACKGROUND_COLOR
# Create a Tilegrid with the background and put in the displayio group
t = displayio.TileGrid(background_bitmap, pixel_shader=palette)
g.append(t)
# Draw simple text using the built-in font into a displayio group
text_group = displayio.Group(scale=2, x=20, y=40)
text = "Hello World!"
text_area = label.Label(terminalio.FONT, text=text, color=FOREGROUND_COLOR)
text_group.append(text_area) # Add this text to the text group
g.append(text_group)
# Place the display group on the screen
display.show(g)
# Refresh the display to have everything show on the display
# NOTE: Do not refresh eInk displays more often than 180 seconds!
display.refresh()
time.sleep(120)
while True:
pass