The examples in this guide are no longer supported. Please check out the Adafruit eInk Display Breakouts guide for CircuitPython and Python usage: https://learn.adafruit.com/adafruit-eink-display-breakouts

Compiling

These test programs should compile with no additional libraries, but the EPD driver needs the fuse development library installed. And a few examples make us of the Python Imaging Library (PIL)

Raspberry Pi

sudo apt-get install libfuse-dev python-imaging

# For the Twitter Demo
sudo apt-get install python-setuptools 
sudo easy_install pip

git clone https://github.com/repaper/gratis.git
cd gratis/PlatformWithOS
make rpi
sudo make rpi-install

BeagleBone Black

sudo opkg install libfuse-dev python-imaging

# For the Twitter demo
opkg install python-pip python-setuptools

# Extra item for BeagleBone
# The program uses device tree files to access the GPIOs
git clone https://github.com/nomel/beaglebone.git
cp -p beaglebone/gpio-header/generated/gpio-P9.* /lib/firmware

git clone https://github.com/repaper/gratis.git
cd gratis/PlatformWithOS
make bb
sudo make bb-install

EPD fuse

This allows the display to be represented as a virtual directory of files, which are:
File         Read/Write   Description
--------     -----------  ---------------------------------
version      Read Only    The driver version number
panel        Read Only    String describing the panel and giving 
                          its pixel width and height
current      Read Only    Binary image that  matches the currently 
                          displayed image (big endian)
display      Read Write   Image being assembled for next display 
                          (big endian)
temperature  Read Write   Set this to the current temperature in Celsius
command      Write Only   Execute display operation
BE           Directory    Big endian version of current and display
LE           Directory    Little endian version of current and display

Command   Byte   Description
--------  -----  --------------------------------
'C'       0x43   Clear the EPD, set `current` to all zeros, `display` 
                 is not affected
'U'       0x5A   Erase `current` from EPD, output `display` to EPD, 
                 copy display to `current`
Notes:
  • The default bit ordering for the display is big endian i.e. the top left pixel is the value 0x80 in the first byte.
  • The `BE` directory is the same as the root `current` and `display`.
  • The `LE` directory `current` and `display` reference the top left pixel as 0x01in the first byte.
  • The `current_inverse` and `display_inverse` represent black as zero (0) and white as one (1) while those item without the suffix represent the display's natural coding (0=>white, 1=>black)
  • The particular combination of `BE/display_inverse` is used in the Python EPD demo since it fits better with the Imaging library used.
Set Panel Size in FUSE Configuration
cat /etc/default/epd-fuse
Expected Output:
# Default settings for epd-fuse file is sourced by /bin/sh from
# /etc/init.d/epd-fuse

# Options to pass to epd_fuse
#EPD_MOUNTPOINT=/dev/epd
#EPD_SIZE=2.0
#EPD_OPTS=
Note: All the configurations are commented out and represent the default settings. If your panel is NOT the 2.0", then you must change this configuration.

How to edit the configuration file:
sudo nano /etc/default/epd-fuse
Uncomment the EPD_SIZE and change the value to your panel size (either 2.7 or 1.44). Save and exit.
Start the Driver
sudo service epd-fuse start
cat /dev/epd/panel
Expected Output for a 2.7" panel:
EPD 2.7 264x176

Python Demo Programs - directory "demo"

Drawing Demo

Draw some lines, graphics and text:
python demo/DrawDemo.py
Nothing happening on the screen? You may have a "COG 2" version of the display. See the FAQ page!

Image demo

  • Accepts a lists of image files on the command line.
  • Converts them to grey scale to ensure formats like PNG, JPEG and GIF will work.
  • Inverts the image since the E-Ink panel is reverse (i.e. black on white).
  • Converts image to single bit (PIL "1" mode).
  • Display the middle of the image (using crop function).
  • Delay.
  • Display the re-sized image.
  • Delay before fetching next file.
Note: if scratch is installed on the system, the following commands will show some cartoon animals. The images when re-sized will be distorted if the aspect ration of the original image is not the same as the display.
python demo/ImageDemo.py /usr/share/scratch/Media/Costumes/Animals/cat*
python demo/ImageDemo.py /usr/share/scratch/Media/Costumes/Animals/d*.png

Twitter Demo

Setup easy_install and use it to get pip, then use pip to get tweepy. Copy the sample configuration an edit to include your authentication information. Rather than using the basic authentication it is better to set up a Twitter App and generate a token for this. The token generation is quick at
https://dev.twitter.com/.

After creating the App, just click the button to create an access token.

Use Ctrl-C to stop this program.
sudo pip install tweepy

# setup the config
cp demo/tweepy_auth.py-SAMPLE demo/tweepy_auth.py

# *** edit the config
nano demo/tweepy_auth.py

# run the demo (this watches for linux)
python demo/TwitterDemo.py linux

Partial Demo


Display random overlapping rectangles using partial update. First argument is number of rectangle to generate before updating the EPD, second number is the number of frames to display before the program exits.
python demo/PartialDemo.py 3 20

Counter Demo


Display a 4 digit hex counter uses partial update to only change the updated digits. This will look somewhat strange as the display inversion will make the counter appear to go through a sequence like: 0000 0001 0000 0001 ...delay... 0001 0002 0001 0002

Use Ctrl-C to stop this program.
python demo/CounterDemo.py 3 20

This guide was first published on Dec 20, 2013. It was last updated on Mar 08, 2024.

This page (Driver and Examples) was last updated on Mar 08, 2024.

Text editor powered by tinymce.