Skip to main content

A library to create and send image data to an ePaper display connected to a Firmata powered microcontroller. Supports both pyFirmata and pyFirmata2!

Project description

pyFirmata ePaper display library

A library to create and send image data to an ePaper display connected to a firmata powered microcontroller.

Supports both pyFirmata and pyFirmata2 libraries!

Library supports Python 3.0+ and should (according to vermin) also support Python 2.3+

Info

Code has been tested with the Waveshare 2.9 inch black-white and red-white display.

The code should support other displays as well, because Waveshare provides .cpp and .h files for each of their displays.

Guide below should help you. If you were to run into issues after you done all the steps according to your display, then you could make an issue if there isn't one for your display yet.

Setting up

You cannot just use the default StandardFirmata.ino file without making changes to it for this code to work.

See code_pieces_for_ino.md for the changes you need to make.

After that install either pyFirmata2 OR pyFirmata library using pip.

Then you can install this library using pip install pyfirmata-epd

API/Example

Here is an example code with comments to explain the API functions:

# Import pyfirmata2
from pyfirmata2 import Arduino
# or import pyfirmata
# from pyfirmata import Arduino

# Imports
from pyfirmata_epd.epd import Epd
from pyfirmata_epd.paint import Paint, COLORED, UNCOLORED
from pyfirmata_epd.fonts import Font12, Font16

# Open connection to board:
board = Arduino(Arduino.AUTODETECT)
print('Started up')
# Always enable sampling!
board.samplingOn()

# Init epaper display:
epd = Epd(board)
# Wake the display up (since it will always go in sleep mode)
epd.Reset()

# To clear the display:
epd.Clear()

# To display pixels:
epd.DisplayFrame([0xFF, ..., 0xFF], [0xFF, ..., 0xFF]) # black-white data, red-white data



# To easily draw shapes and stuff:
paint = Paint([], 128, 296) # Init empty buffer with width of 128 (must be multiple of 8, since 8 pixels are in 1 byte) and height of 296
# Init another paint for red pixels
paintRed = Paint([], 128, 296)

# Clear paint
paint.Clear(UNCOLORED)
paintRed.Clear(UNCOLORED)

# Draw string
paint.DrawStringAt(24, 32, "e-Paper Demo", Font12, COLORED)

# Draw string with 'inversed background'
paintRed.DrawFilledRectangle(0, 64, 128, 82, COLORED)
paintRed.DrawStringAt(2, 66, "Hello world", Font16, UNCOLORED)

# Draw rectangle with cross
paint.DrawRectangle(8, 120, 48, 170, COLORED)
paint.DrawLine(8, 120, 48, 170, COLORED)
paint.DrawLine(48, 120, 8, 170, COLORED)

# Draw circle
paint.DrawCircle(96, 152, 30, COLORED)

# Draw filled rectangle
paintRed.DrawFilledRectangle(8, 200, 48, 250, COLORED)

# Draw filled circle
paintRed.DrawFilledCircle(96, 232, 30, COLORED)

# Display on epaper display
epd.DisplayFrame(paint.GetImage(), paintRed.GetImage())

The paint should look like: democode result

Extra API documentation can be found on the ReadTheDocs documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyfirmata_epd-1.0.1.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyfirmata_epd-1.0.1-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

Details for the file pyfirmata_epd-1.0.1.tar.gz.

File metadata

  • Download URL: pyfirmata_epd-1.0.1.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.2

File hashes

Hashes for pyfirmata_epd-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1fc6cabc9330bea417af6efd900ef2514603b05ad73d2eb3863c46cadf733118
MD5 3a5f857e08b3cb5fe97fd4c7df2cbe8d
BLAKE2b-256 1b34ef44a0d848a9c837d2418c8a60325a753d173ad77adcb0603506a1403388

See more details on using hashes here.

File details

Details for the file pyfirmata_epd-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyfirmata_epd-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.2

File hashes

Hashes for pyfirmata_epd-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 165cc1ee872710f8fb6eca8e2228f809b54307e2466b2b38195312ef476c6bb1
MD5 d9f228adf78c148c7ffbe544d571d93c
BLAKE2b-256 ecded66c770e6497ce45c780f9b57031e431a3744e010cd53d164a672243cded

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page