This feature is very new and not currently available in the latest public build, so you will need to go to https://circuitpython.org/, select your board, and find the "Absolute Newest" image.

It's easy to use the Sharp Memory Display with CircuitPython and the Adafruit CircuitPython SharpMemoryDisplay module. This module allows you to easily write Python code to control the display.

Check the support matrix for your board to see whether it supports the sharpdisplay module.

To demonstrate the usage, we'll initialize the library and the Python REPL will be displayed on it. You can type these lines in directly or put them in code.py.

Initialization

First, import required modules and release the existing display (if any).

Download: file
import board
import displayio
import framebufferio
import sharpdisplay
        
# Release the existing display, if any
displayio.release_displays()

Next, create the display using the appropriate SPI bus, Chip Select (CS) Pin, width, and height. The baudrate can also be set, though the default value of 2MHz should work with all Sharp Memory Displays. Make sure to use the right pin names as you have wired up to your board!  If you use a nonstandard SPI bus, construct it with busio.SPI instead of using board.SPI().

Download: file
bus = board.SPI()
chip_select_pin = board.D6
# Select JUST ONE of the following lines:
# For the 400x240 display (can only be operated at 2MHz)
framebuffer = sharpdisplay.SharpMemoryFramebuffer(bus, chip_select_pin, 400, 240)
# For the 144x168 display (can be operated at up to 8MHz)
#framebuffer = sharpdisplay.SharpMemoryFramebuffer(bus, chip_select_pin, width=144, height=168, baudrate=8000000)

The last thing to do before you can use displayio routines is to connect the framebuffer as a display:

Download: file
display = framebufferio.FramebufferDisplay(framebuffer)

If you are doing this interactively at the Python REPL, you will now see the REPL mirrored onto the Sharp Memory Display.

Drawing

The SharpMemoryDisplay module supports all the methods for drawing that DisplayIO supports: Text, bitmaps, shapes, etc. For instance, if you wanted to display a label using the built-in terminal font, you would use something like the following:

Download: file
from adafruit_display_text.label import Label
from terminalio import FONT
label = Label(font=FONT, text="BLACK\nLIVES\nMATTER", x=120, y=120, scale=4, line_spacing=1.2)
display.show(label)

We cover CircuitPython displayio more in depth in its own guide, so now that you've got the display going, learn more about CircuitPython Display Support Using displayio to get the most out of it.

This guide was first published on Jun 22, 2013. It was last updated on Jun 22, 2013.
This page (CircuitPython displayio Usage) was last updated on Oct 25, 2020.