Matrix Display über Python ansteuern

Folgende Befehle wurden ausgeführt um über python ein Moin auf dem Matrix Display auszugeben.

Zunächst

sudo apt update

sudo apt install -y git build-essential python3-dev python3-pip python3-pil

cd ~

git clone https://github.com/hzeller/rpi-rgb-led-matrix.git

cd rpi-rgb-led-matrix

make

Nach dem bauen in das Verzeichnis wechseln und die Demo starten

rpi-rgb-led-matrix/examples-api-use

./demo -D 12  --led-rows=32   --led-cols=64   --led-gpio-mapping=adafruit-hat

Über die Angabe D können verschiedene Demos ausgeführt werden.

Für das python Modul sind folgende Befehle notwendig

sudo apt update

sudo apt install python3-dev python3-pip python3-venv cython3 build-essential

python3 -m venv ~/matrixenv

source ~/matrixenv/bin/activate

cd ~/rpi-rgb-led-matrix

pip install -U pip setuptools wheel

pip install .

Das Script zur Ausgabe des Textes:

from rgbmatrix import RGBMatrix, RGBMatrixOptions

from PIL import Image, ImageDraw

options = RGBMatrixOptions()

options.rows = 32

options.cols = 64

options.chain_length = 1

options.hardware_mapping = "adafruit-hat"

matrix = RGBMatrix(options=options)

image = Image.new("RGB", (64, 32))

draw = ImageDraw.Draw(image)

draw.text((2, 10), "Moin!", fill=(255, 255, 0))

matrix.SetImage(image)

input("Enter zum Beenden...")

Das Script wird mit sudo ~/matrixenv/bin/python3 text.py ausgeführt.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert