Skip to main content

A driver middleware for LED matrix software compatible with rpi-rgb-led-matrix

Project description

RGBMatrixDriver

pypi Badge

RGBMatrixDriver is a driver middleware for rpi-rgb-led-matrix/RGBMatrixEmulator compatible display scripts.

Write your display script once, then run it on either real hardware or via software emulation. Out of the box, the middleware lets you get off the ground with a sensible default configuration while allowing extensibility and additional features.

Installation

RGBMatrixDriver is in the Python Package Index (PyPI). Installing with pip is recommended for all systems.

pip install RGBMatrixDriver

Setup

Projects that are compatible with RGBMatrixDriver will rely on importing classes from rpi-rgb-led-matrix. These will need to be replaced by equivalent RGBMatrixDriver classes.

For example, usage on a Rasberry Pi might look like this:

from rgbmatrix import RGBMatrix, RGBMatrixOptions

Using the driver middleware, you will need to use RGBMatrixDriver classes:

from RGBMatrixDriver import RGBMatrix, RGBMatrixOptions

To take full advantage of the driver middleware, you will need to parse arguments using the RGBMatrixArguments class instead of a standard argparse.ArgumentParser. You can run this example in /samples/quick_start.py.

from random import randint as r
from RGBMatrixDriver import RGBMatrix, RGBMatrixArguments, prefilled_matrix_options


# Support all the defaults that RGBMatrixDriver includes
args = RGBMatrixArguments().parse_args()

# Fill out an RGBMatrixOptions instance with all the arguments
options = prefilled_matrix_options(args)

# Create a matrix and canvas
matrix = RGBMatrix(options=options)
canvas = matrix.CreateFrameCanvas()

# Push the pixels!
while True:
  # Simulate static -- Set R, G, B equal to each other at random
  for y in range(matrix.height):
    for x in range(matrix.width):
      canvas.SetPixel(x, y, *tuple([r(0, 255)] * 3))

  canvas = matrix.SwapOnVSync(canvas)

You can also set a driver log level if you want, which is useful if you use any reporting middleware (such as the --driver-fps=log flag).

import logging, RGBMatrixDriver


RGBMatrixDriver.logger.setLevel(logging.INFO)

Usage

For the most part, startup of the existing script will be unchanged, unless you want to pass additional driver flags, as listed in the Flags section below.

The driver can handle both hardware and software emulation display modes.

Hardware Mode

By default the driver tries to load in hardware mode. This is the mode end users will typically want to run as, so there are no additional flags needed to work on Raspberry Pi.

Software Emulation Mode

If hardware loading fails for any reason, the driver will fallback to software emulation via RGBMatrixEmulator. A command line flag --emulated can also be used to force emulation.

See RGBMatrixEmulator README for customization options when running software emulation mode.

Flags

You can pass the -h / --help flags at any time to show a list of arguments that your script supports. This will be a default list of arguments provided for rpi-rgb-led-matrix, driver flags provided by this library, and finally, any custom flags you have implemented for your own script.

You should reference the project README for rpi-rgb-led-matrix library when necessary.

Driver Flags

--driver-fps {log,overlay}
  Calculate FPS and display via selected method: log, overlay
--emulated
  Run the script in software emulation mode via RGBMatrixEmulator

Contributing

If you want to help develop RGBMatrixDriver, you must also install the dev dependencies, which can be done by running pip install -e .[dev] from within the directory.

Before submitting a PR, please open an issue to help us track development. All development should be based off of the dev branch. This branch is kept up-to-date with main after releases.

Contact

Tyler Porter

tyler.b.porter@gmail.com

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

rgbmatrixdriver-0.1.3.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

rgbmatrixdriver-0.1.3-py2.py3-none-any.whl (22.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file rgbmatrixdriver-0.1.3.tar.gz.

File metadata

  • Download URL: rgbmatrixdriver-0.1.3.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for rgbmatrixdriver-0.1.3.tar.gz
Algorithm Hash digest
SHA256 cc02af45be5bca57a532816a4400fc5499a4684c08becc5d36caf7cd5d0cc5a7
MD5 6f325cbabed885eeeea78f910bf621d2
BLAKE2b-256 1a21a09d286f5d959920910182477bbfa82f2d2de64d53f2bb803105cdf86b00

See more details on using hashes here.

File details

Details for the file rgbmatrixdriver-0.1.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for rgbmatrixdriver-0.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 73ef714ee1f870e28f217306bc3139681f5e89cdace1fcb8f34d29ae73d71bfb
MD5 e5759b0637e2cedea2ebc37c1b5ac436
BLAKE2b-256 106f1f142e9bc0e28f42108892fb73949f1b4c47e9094b46757efa9620deb751

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