LEDパネルで
光るわぷーを
Create LED lightened Wapuu
自己紹介
Self Introduce
‣
‣


http://www.yuriko.net/
@lilyfanjp
架空鉄道の同人誌は売れない
Sales of imaginary railway books are very small.
LED方向幕を展示
Displayed LED rollsign
ラズパイで制御
Controlled by Raspberry Pi
Raspberry Pi +
RGB Matrix HAT
Switching PSU
Power Tap
“一般的なご家庭には
必ずあるラズパイ”
“At least one RPi in a ordinary home ”
逸般的な誤家庭
none-ordinary & odd home
LED方向幕は
自作できる
You can make a LED rollsign
Hardware
LED Matrix Panel
Signal (in) Next to
Raspberry Pi






Pin Header (to HAT)
HDMI
4x
USB
RGB Matrix HAT
To LED Panel
横長パネルを縦接続
Connect landscape panels vertically
黒テープで補強
Reinforce by black tape
表から見て

面が うこと
Faces are uniformed.
ブックスタンドに貼る
Fix on book stands by magnet
背面の磁石
Magnets on Panel back
Attention!


Software




Raspbian
RPi RGB LED Matrix
OS set up
git libgraphicsmagick++-dev libwebp-dev
Get Lib & Make
$ git clone https://github.com/hzeller/rpi-rgb-led-matrix
$ cd rpi-rgb-led-matrix
$ make -C examples-api-use
$ cd utils
$ make led-image-viewer
Demo
$ cd example-api-use
$ sudo ./demo 

--led-gpio-mapping=adafruit-hat 
--led-no-hardware-pulse 
--led-chain=4 -L 

-D 0
わぷー表示
Show wapuu
Create DATA


わぷー画像を収集
Collect wapuu images
横に並べる
Arrange them
Scroll images
$ sudo ./demo
--led-gpio-mapping=adafruit-hat 
--led-no-hardware-pulse 
--led-chain=4 -L
-D 1 ../../images/wapuu.ppm
Demo
Auto Run
$ crontab -e
@reboot /home/pi/startup.sh
HAT Detection
#!/bin/sh
prod_path="/proc/device-tree/hat/product"
if test -f $prod_path; then
product=$(cat $prod_path)
case $product in
"Adafruit RGB Matrix + RTC HAT - HUB75 / DS1307") ./wapuu.sh;;
Run scroll demo
sudo ./demo 
--led-gpio-mapping=adafruit-hat 
--led-no-hardware-pulse
--led-chain=4 -L 
-D 1 ../../images/wapuu.ppm
表示の止め方
How to stop
$ ssh pi@led.local
ps auwx
sudo kill NNNN
ワンライナー
one liner script
Select by API
WP API で表示変更
http://wp.yuriko.net

/wp-json/wp/v2/pages/60
Response
{"id":60,"date":"2017-09-02T13:45:54",
"date_gmt":"2017-09-02T04:45:54",
"guid":{"rendered":"http://wp.yuriko.net/?page_id=60"},
"modified":"2017-09-02T15:12:12",
"modified_gmt":"2017-09-02T06:12:12",
"slug":"selected",
"status":"publish",
"type":"page",
"link":"http://wp.yuriko.net/selected/",
"title":{"rendered":"Selected"},
"content":{"rendered":"<p>001</p>n","protected":false},
"excerpt":{"rendered":"<p>001</p>n","protected":false},
"author":1,
"featured_media":0,
"parent":0,
"menu_order":0,
"comment_status":"closed",
"ping_status":"closed",
"template":"",
"meta":[],
"_links":{
"self":[{"href":"http://wp.yuriko.net/wp-json/wp/v2/pages/60"}],
"collection":[{"href":"http://wp.yuriko.net/wp-json/wp/v2/pages"}],
"about":[{"href":"http://wp.yuriko.net/wp-json/wp/v2/types/page"}],
"author":[{"embeddable":true,"href":"http://wp.yuriko.net/wp-json/wp/v2/users/
1"}],
"replies":[{"embeddable":true,"href":"http://wp.yuriko.net/wp-json/wp/v2/
comments?post=60"}],
"version-history":[{"href":"http://wp.yuriko.net/wp-json/wp/v2/pages/60/
revisions"}],
"wp:attachment":[{"href":"http://wp.yuriko.net/wp-json/wp/v2/media?parent=60"}],
"curies":[{"name":"wp","href":"https://api.w.org/{rel}","templated":true}]
}}
"content":{
"rendered":"<p>001</p>n",
"protected":false
},
画像番号の取得
#/usr/bin/python
import urllib
import json
import re
import glob
import commands
import time
api = "http://wp.yuriko.net/wp-json/wp/v2/pages/60"
image_dir = "/home/lily/led/images/wapuu/"
viewer = "/home/lily/led/rpi-rgb-led-matrix/utils/
led-image-viewer "
opt = "--led-no-hardware-pulse --led-chain=4" 
+ "-L --led-brightness=50 -f "
APIアクセス
while True:
result = None
try:
result = urllib.urlopen( api ).read()
except ValueError:
print "API Access Failed."
data = json.loads( result )
content = data["content"]["rendered"]
matchOB = re.match( r'<p>(.*)</p>', content)
if not matchOB:
continue
番号抽出して画像表示
number = matchOB.group(1)
files = glob.glob( 
image_dir + number + "-*.png" )
if len(files) < 1:
continue
commands.getoutput( 
"sudo "+viewer+opt+files[0] )
TODO
WordCamp Tokyo 2017
のLTに登壇
Speech at WordCamp Tokyo 2017 LT
2017-09-16

LEDマトリックスで光るわぷー(WordPressで指定編その1)