Skip to content

CircuitPython displayio driver for Pervasive Displays Spectra-based iTC/COG ePaper Displays

License

Notifications You must be signed in to change notification settings

fergbrain/Fergcorp_CircuitPython_PDISpectra

Repository files navigation

Introduction

Documentation Status Discord Build Status Code Style: Black

CircuitPython displayio driver for Pervasive Displays Spectra-based iTC/COG ePaper Displays

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle or individual libraries can be installed using circup.

Installing from PyPI

Note

This library is not available on PyPI yet. Install documentation is included as a standard element. Stay tuned for PyPI availability!

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install fergcorp-circuitpython-pdispectra

To install system-wide (this may be required in some cases):

sudo pip3 install fergcorp-circuitpython-pdispectra

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install fergcorp-circuitpython-pdispectra

Installing to a Connected CircuitPython Device with Circup

Make sure that you have circup installed in your Python environment. Install it with the following command if necessary:

pip3 install circup

With circup installed and your CircuitPython device connected use the following command to install:

circup install pdispectra

Or the following command to update an existing version:

circup update

Usage Example

"""Simple test script for 1.54" 152x152 tri-color display.
"""

import time
import displayio
import busio
import board
import digitalio
from adafruit_display_text import label
import terminalio
from fergcorp_pdispectra import PDISpectra

BLACK = 0x000000
WHITE = 0xFFFFFF
RED = 0xFF0000

# Change text colors, choose from the following values:
# BLACK, RED, WHITE

FOREGROUND_COLOR = BLACK
BACKGROUND_COLOR = WHITE

displayio.release_displays()

spi_bus = busio.SPI(clock=board.GP18, MOSI=board.GP19, MISO=board.GP16)


# eInk Driver Setup
eink_driver_cs = board.GP17
eink_driver_d_c = board.GP12
eink_driver_busy = board.GP11
eink_driver_res = board.GP1

display_bus = displayio.FourWire(
    spi_bus,
    command=eink_driver_d_c,
    chip_select=eink_driver_cs,
    reset=None,
    baudrate=100000,
)




RES = digitalio.DigitalInOut(eink_driver_res)
RES.direction = digitalio.Direction.OUTPUT
RES.drive_mode = digitalio.DriveMode.PUSH_PULL

RES.value = False
time.sleep(5 / 1000)
RES.value = True
time.sleep(5 / 1000)
RES.value = False
time.sleep(10 / 1000)
RES = True
time.sleep(5 / 1000)
print("Reset")

print("Creating display")

display = PDISpectra(
    display_bus,
    height=152,
    width=152,
    rotation=90,
    busy_pin=eink_driver_busy,
    swap_rams=True,
)

g = displayio.Group()

# Set a background
background_bitmap = displayio.Bitmap(152, 152, 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()
print("Refreshed")
time.sleep(120)
print("done")

while True:
    pass

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Documentation

For information on building library documentation, please check out this guide.

About

CircuitPython displayio driver for Pervasive Displays Spectra-based iTC/COG ePaper Displays

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages