RGBマトリクスに、引数文字とRGBでppmファイルを生成します。
(python3はまだ調整できず)
nodejsと組み合わせれば、Webインターフェースでリアルタイムで文字表示できます。
1.ライブラリインストール
apt install fonts-takao-mincho
apt install libjpeg-dev
pip install Pillow
makePpm.pl
# encoding:UTF-8
# -*- codinf:utf-8 -*-
import sys
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
args = sys.argv
inText = args[1].decode('utf-8')
rgb = args[2].split(",")
list = list(map(int,rgb))
viewText = []
viewText.append( ((u" ") + inText ,tuple(list)))
text = tuple(viewText)
font = ImageFont.truetype("/usr/share/fonts/truetype/takao-mincho/TakaoMincho.ttf", 16)
all_text = ""
for text_color_pair in text:
t = text_color_pair[0]
all_text = all_text + t
width, ignore = font.getsize(all_text)
im = Image.new("RGB", (width + 30, 16), "black")
draw = ImageDraw.Draw(im)
x = 0;
for text_color_pair in text:
t = text_color_pair[0]
c = text_color_pair[1]
#print("t=" + t + " " + str(c) + " " + str(x))
draw.text((x, 0), t, c, font=font)
x = x + font.getsize(t)[0]
im.save("/var/tmp/text.ppm")
2.実行
python makePpm.pl 文字列 255,255,255
3.その他
参考にしたサイト
https://digirakuda.org/contents/report/products/raspberrypi/electric-bulletin-board/