Skip to main content

Better driver for Waveshare 7.5" e-paper display

  • saner API
  • 4-grayscale with dithering for best looking grayscale images (supported by displays sold after 2024-10-23)
  • fast thanks to numpy
  • partial updates that actually work, even if the display has been put to sleep after the last update; this isn't even supported at all by the official driver

How fast is it?

Probably not as fast as a C driver, but a lot faster than the official Python driver. Especially for 4-grayscale images.

Even when it's not much faster in terms of wall clock time, it's always much more efficient in terms of CPU time.

The original driver is particularly bad because it checks if the display is busy by constantly spinning a loop with no sleep, effectively causing 100% CPU usage during this time. But even when patching this flaw, there are still many inefficiencies in data serialization, that I've been able to improve with numpy.

On a RaspberryPi Zero 2 W, number on the left is wall time, number on the right is CPU time:

Update method Original driver Patched orig. driver This driver
Grayscale 13.7 s / 13.9 s 13.7 s / 11.9 s 2.66 s / 190 ms
Full bilevel 4.23 s / 3.90 s 4.24 s / 419 ms 4.19 s / 266 ms
Fast bilevel 2.12 s / 1.72 s 2.13 s / 295 ms 2.08 s / 153 ms
Partial bilevel 965 ms / 622 ms 971 ms / 234 ms 870 ms / 82 ms

Patched orig. driver: simply the original driver with a short "sleep" in the "check display is busy" loop

(Oh and these 190 ms of CPU for a grayscale image? That's with dithering, which doesn't exist in the original driver.)

Usage

The original driver forces you to manually init_X() the display with the correct refresh method, then transform the image to a "buffer" with the corresponding getbuffer_X() method, and finally call the corresponding display_X() method. And then you should not forget to call sleep() to de-energize the display.

That's very tedious and error-prone. This driver does all that for you with the help of context managers.

import betterepd7in5
from PIL import Image

epd = betterepd7in5.EPD(betterepd7in5.RaspberryPi())

my_image = Image.open("my_image.png")

with epd.display_grayscale() as disp:
    disp(my_image)

with epd.display_bilevel_full_refresh() as disp:
    disp(my_image)

with epd.display_bilevel_fast_refresh() as disp:
    disp(my_image)

with epd.display_bilevel_partial_refresh() as disp:
    disp(my_image)

The context manager (with ... as disp:) automatically initializes the display, and gives you a display function that takes a Pillow image that you can call as many times as you want.

When the context manager exits, it automatically puts the display to sleep, unless you pass sleep=False. This can be useful to chain multiple display methods one after the other without having to sleep in between (which takes a couple of seconds).

with epd.display_bilevel_full_refresh(sleep=False) as disp:
    disp(my_base_image)

with epd.display_bilevel_partial_refresh() as disp:
    for update in updates:
        disp(update)

You can also call sleep() and clear() as needed outside of a context.

Auto-resize and auto-rotation

The display functions will automatically resize and rotate the image.

Auto-rotation means that if your image is wider than it is tall, it will be displayed in landscape mode on the display, and otherwise it will be displayed in portrait mode.

To flip either orientation 180 degrees, use EPD(reverse=True).

Of course if you don't want any auto-rotation or resizing, you can simply prepare your image with the correct display size (800x480) before displaying it.

Release files for betterepd7in5 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for betterepd7in5 0.2.1
File Size Uploaded
betterepd7in5-0.2.1.tar.gz 15.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for betterepd7in5 0.2.1
File Interpreter ABI Platform
betterepd7in5-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 23.0 kB

Release files / betterepd7in5-0.2.1.tar.gz

Download URL betterepd7in5-0.2.1.tar.gz
Size 15.4 kB
Tags Source
SHA-256 checksum
How to use checksums
91e4016a464a62648970a69bb09fc63ec4ddfdbab470f13149a541e5820a43ad
BLAKE2b-256 checksum
How to use checksums
22c8b95e4fc9fa2e40c9ea98347d86d3b8a24e12e140cde816f047cf7ccf03ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.4

Release files / betterepd7in5-0.2.1-py3-none-any.whl

Download URL betterepd7in5-0.2.1-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb3b7195705e8030246ed75d50e520fda8584cd2955b88196a600be722486196
BLAKE2b-256 checksum
How to use checksums
f30ff155d7c8e9dccee757657bfcd0e95bd0e278e63fb282e3a4da6902a4fe3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.4

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page