2.13" 250x122 e-paper (ssd1680) displayed on Raspberry Pi pico/CircuitPython

Exercise to display on 2.13" 250x122 e-paper (with ssd1680 driver), using Raspberry Pi Pico running CircuitPython 8.2.0.


- reference:
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





Connection between Raspberry Pi Pico and 2.13" 250x122 e-paper (ssd1680)

			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

			4x2 header on 2.13" 250x122 e-paper (ssd1680)
			+-----------+
		    GP5	|RES	BUSY| GP0
		    GP4	|CS	D/C | GP1
		    GP3	|SDA	SCL | GP2
		    3V3 |VCC	GND | GND
			+-----------+
			

Libraries needed:
adafruit_ssd1680.mpy
adafruit_display_text folder

Exercise code:

cpyPico_ssd1680_SingleImage.py
"""
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

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=250,
    height=122,
    busy_pin=epd_busy,
    highlight_color=0xFF0000,
    rotation=270,
    busy_pin=epd_busy,
)

g = displayio.Group()

"""
download display-ruler.bmp here:
https://learn.adafruit.com/quickstart-using-adafruit-eink-epaper-displays-with-circuitpython/example-single-bitmap
save to CircuitPython device /.
"""

with open("/display-ruler.bmp", "rb") as f:
    pic = displayio.OnDiskBitmap(f)
    # CircuitPython 6 & 7 compatible
    t = displayio.TileGrid(
        pic, pixel_shader=getattr(pic, "pixel_shader", displayio.ColorConverter())
    )
    # CircuitPython 7 compatible only
    # t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
    g.append(t)

    display.show(g)

    display.refresh()

    print("refreshed")

    time.sleep(120)



cpyPico_ssd1680_SimpleText.py
"""
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

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=250,
    height=122,
    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


Comments

  1. Hey, I am having issues installing the adafruit-circuitpython-ssd1680 library on my pico. It says I dont have enough space. How did you install the library?

    ReplyDelete

Post a Comment

Popular posts from this blog

480x320 TFT/ILI9488 SPI wih EP32C3 (arduino-esp32) using Arduino_GFX Library

my dev.tools - FNIRSI 2C23T 3-in-1 Dual Channel Oscilloscope/Multimeter/Signal Generator