Datasheet
import digitalio
import busio
import board
from PIL import Image, ImageDraw, ImageFont
from adafruit_epd.il0373 import Adafruit_IL0373
from adafruit_epd.il91874 import Adafruit_IL91874
from adafruit_epd.il0398 import Adafruit_IL0398
from adafruit_epd.ssd1608 import Adafruit_SSD1608
from adafruit_epd.ssd1675 import Adafruit_SSD1675
Next we define some colors that can be used with Pillow.
WHITE = (0xFF, 0xFF, 0xFF)
BLACK = (0x00, 0x00, 0x00)
RED = (0xFF, 0x00, 0x00)
After that, we create some parameters that are easy to change. If you had a smaller display for instance, you could
reduce the FONTSIZE and BORDER parameters. The BORDER will be the size in pixels of the green border between
the edge of the display and the inner purple rectangle. The FONTSIZE will be the size of the font in points so that we
can adjust it easily for different displays. You could play around with the colors as well. One thing to note is that on
monochrome displays, the RED will show up as BLACK .
BORDER = 20
FONTSIZE = 24
BACKGROUND_COLOR = BLACK
FOREGROUND_COLOR = WHITE
TEXT_COLOR = RED
After that, the initializer and rotation sections are exactly the same as in the previous example. If you have are using a
different display than the 2.13" Tri-color, go ahead and adjust your initializer as explained in the previous example.
After that, we will create an image with our dimensions and use that to create a draw object. The draw object will
have all of our drawing functions.
image = Image.new('RGB', (display.width, display.height))
draw = ImageDraw.Draw(image)
Next we clear whatever is on the screen by drawing a rectangle using the BACKGROUND_COLOR that takes up the full
screen.
draw.rectangle((0, 0, display.width, display.height), fill=BACKGROUND_COLOR)
Next we will draw an inner rectangle using the FOREGROUND_COLOR . We use the BORDER parameter to calculate
the size and position that we want to draw the rectangle.
draw.rectangle((BORDER, BORDER, display.width - BORDER - 1, display.height - BORDER - 1),
fill=FOREGROUND_COLOR)
Next we'll load a TTF font. The DejaVuSans.ttf font should come preloaded on your Pi in the location in the code. We
© Adafruit Industries https://learn.adafruit.com/adafruit-eink-display-breakouts Page 52 of 61










