Scroll pHAT HD
に美咲フォント
Scroll pHAT いいよね
Scroll pHAT HDでた
日本語出せそう
やってみた
レシピ
pimoroni.com
pHATについて


https://www.raspberrypi.org/blog/introducing-raspberry-pi-hats/
Setup
Raspbian
Python library
curl https://get.pimoroni.com/
scrollphathd | bash
Proxy 通す
export http_proxy="user:pass@http://
proxy.example.jp:8080"
export https_proxy="user:pass@http://
proxy.example.jp:8080"
Defaults env_keep+="http_proxy"
Defaults env_keep+="https_proxy"
ping 8.8.8.8 対策
curl get.pimoroni.com/scrollphathd > scrhd.sh
sudo ping -q -w 10 -c 1 8.8.8.8 | 
grep "received, 0" &> /dev/null && 
return 0 || return 1
curl -I shop.pimoroni.com | 
grep "HTTP/1.1 301 Moved" &> /dev/null && 
return 1 || return 0
日本語表示
Fontファイル
/usr/lib/python2.7/dist-packages/
scrollphathd/fonts/font5x7.py
data = {
0x00000041: [[0x00,0xff,0xff,0xff,0x00],
[0xff,0x00,0x00,0x00,0xff],
[0xff,0x00,0x00,0x00,0xff],
[0xff,0xff,0xff,0xff,0xff],
[0xff,0x00,0x00,0x00,0xff],
[0xff,0x00,0x00,0x00,0xff],
[0xff,0x00,0x00,0x00,0xff]],
}
Unicode
美咲フォント
美咲フォント
BDF ヘッダ
STARTFONT 2.1
FONT -Misaki-Gothic-Medium-R-Normal--8-80-75-75-C-80-jisx0208.1990-0
SIZE 8 75 75
FONTBOUNDINGBOX 8 8 0 -2
STARTPROPERTIES 19
FONTNAME_REGISTRY ""
FOUNDRY "Misaki"
……
CHARSET_REGISTRY "jisx0208.1990"
CHARSET_ENCODING "0"
DEFAULT_CHAR 8481
FONT_DESCENT 2
FONT_ASCENT 6
COPYRIGHT "Copyright(C) 2002-2012 Num Kadoma"
ENDPROPERTIES
1文字の定義
STARTCHAR 2442
ENCODING 9282
SWIDTH 960 0
DWIDTH 8 0
BBX 8 8 0 -2
BITMAP
0a
7e
10
1c
22
02
1c
00
ENDCHAR
美咲フォントは
JIS X 0208
ビットマップ定義
Unicode変換
モナーフォント
jis2unicode.pl
cat misaki_gothic.bdf | perl jis2unicode
-b > misaki_gothic_unicode.bdf
ヘッダは手動で変更
STARTFONT 2.1
FONT -Misaki-Gothic-Medium-R-Normal--8-80-75-75-C-80-iso10646-1
SIZE 8 75 75
FONTBOUNDINGBOX 8 8 0 -2
STARTPROPERTIES 19
FONTNAME_REGISTRY ""
FOUNDRY "Misaki"
……
CHARSET_REGISTRY "iso10646"
CHARSET_ENCODING "1"
DEFAULT_CHAR 8481
FONT_DESCENT 2
FONT_ASCENT 6
COPYRIGHT "Copyright(C) 2002-2012 Num Kadoma"
ENDPROPERTIES
Scroll pHAT 用変換
BDF→Python 配列
STARTCHAR 2422
ENCODING 12354
SWIDTH 960 0
DWIDTH 8 0
BBX 8 8 0 -2
BITMAP
20
7c
20
3c
6a
b2
64
00
ENDCHAR
0x00003042:

[[0x00,0x00,0xff,0x00,0x00,0x00,0x00],
[0x00,0xff,0xff,0xff,0xff,0xff,0x00],
[0x00,0x00,0xff,0x00,0x00,0x00,0x00],
[0x00,0x00,0xff,0xff,0xff,0xff,0x00],
[0x00,0xff,0xff,0x00,0xff,0x00,0xff],
[0xff,0x00,0xff,0xff,0x00,0x00,0xff],
[0x00,0xff,0xff,0x00,0x00,0xff,0x00]],
変換方法
やっつけ Perl コード
#!/usr/bin/perl -w
use strict;
use Encode;
local $_;
print "# -*- coding: utf-8 -*-ndata = {n";
while (<>) {
chomp;
next unless /^STARTCHAR ([a-fA-Fd]+)/;
my $startchar = $1;
my $encoding = 0;
my @bitmap = ();
CHAR: while (<>) {
chomp;
if (/^ENCODING (d+)/) {
$encoding = $1;
}
next unless /^BITMAP/;
while (<>) {
chomp;
last CHAR if /^ENDCHAR/;
push @bitmap, hex($_);
}
}
if ($encoding == 0) {
print STDERR "No BITMAP found!n";
next;
}
my $char = chr($encoding);
my $last = pop(@bitmap);
if ($last != 0) {
printf(STDERR "No clear bottom line at %sn", 
encode('utf-8', $char));
}
my @glyph = ();
foreach (@bitmap) {
my @line = ();
if ($_ % 2) {
printf(STDERR "LSB found at %s: %02Xn",
encode('utf-8', $char), $_);
}
$_ >>= 1;
for (my $j = 0 ; $j < 7 ; $j++) {
unshift @line, ($+ % 2 ? '0xff' : '0x00');
$_ >>= 1;
}
push @glyph, sprintf('[%s]', join(',', @line));
}
printf("0x%08X: [%s], #%sn", 
$encoding, join(",n", @glyph), 
$startchar, encode('utf-8', $char));
}
print "width = 7nheight = 7n";
完成した FONT コード
# -*- coding: utf-8 -*-
data = {
0x00003001:[[0x00,0x00,0x00,0x00,0x00,0x00,0x00],
[0x00,0x00,0x00,0x00,0x00,0x00,0x00],
[0x00,0x00,0x00,0x00,0x00,0x00,0x00],
[0x00,0x00,0x00,0x00,0x00,0x00,0x00],
[0x00,0x00,0x00,0x00,0x00,0x00,0x00],
[0xff,0x00,0x00,0x00,0x00,0x00,0x00],
[0x00,0xff,0x00,0x00,0x00,0x00,0x00]],#2122:、
0x00003002:[[0x00,0x00,0x00,0x00,0x00,0x00,0x00],
[0x00,0x00,0x00,0x00,0x00,0x00,0x00],
[0x00,0x00,0x00,0x00,0x00,0x00,0x00],
[0x00,0x00,0x00,0x00,0x00,0x00,0x00],
[0x00,0xff,0x00,0x00,0x00,0x00,0x00],
[0xff,0x00,0xff,0x00,0x00,0x00,0x00],
[0x00,0xff,0x00,0x00,0x00,0x00,0x00]],#2123:。
起動時に日本語表示
起動時 cron
$ crontab -e
@reboot /home/pi/startup.sh
Scroll pHAT 判定
#!/bin/sh
sudo i2cdetect -y 1 0x74 0x74 | grep "74" -
if [ "$?" -eq 0 ]; then
sudo python /home/pi/ahiru.py
fi
fi
「あひる焼き」表示
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
import scrollphathd as scrhd
import misaki_gothic
scrhd.rotate(180)
scrhd.write_string(u" あひる焼き", x=0, y=0, 
font=misaki_gothic, brightness=0.5)
while True:
scrhd.show()
scrhd.scroll()
time.sleep(0.05)
電源ONでスクロール
http://www.yuriko.net/
@lilyfanjp
github.com/lilyfanjp/scrhd-ja
https://www.slideshare.net/
lilyfan/scroll-phathdja
想定質問
想定質問2
想定質問3

More Related Content

PDF
Bag of tricks
PDF
Advanced modulinos
PDF
Parsing JSON with a single regex
PDF
Functional php
PDF
Git avançado
PDF
Perl Bag of Tricks - Baltimore Perl mongers
PDF
The Magic Of Tie
ZIP
全裸でワンライナー(仮)
Bag of tricks
Advanced modulinos
Parsing JSON with a single regex
Functional php
Git avançado
Perl Bag of Tricks - Baltimore Perl mongers
The Magic Of Tie
全裸でワンライナー(仮)

What's hot (20)

PPT
Unix shell scripting basics
PDF
De 0 a 100 con Bash Shell Scripting y AWK
PDF
Meet up symfony 16 juin 2017 - Les PSR
PDF
C project on a bookshop for saving of coustmer record
PDF
20 modules i haven't yet talked about
PDF
Beware: Sharp Tools
PDF
Javascript - The basics
PDF
ES6 - Level up your JavaScript Skills
PDF
Taking Inspiration From The Functional World
PPTX
Bioinformatica p4-io
PDF
Generating Power with Yield
PDF
Asynchronous I/O in PHP
PDF
Beware sharp tools
PPTX
Perl: Coro asynchronous
DOCX
bank management system
PDF
Gogo shell
PDF
プログラム実行の話と
OSとメモリの挙動の話
TXT
Tgh.pl
PDF
Using the Command Line with Magento
PDF
Darkmira Tour PHP 2016 - Automatizando Tarefas com Phing
Unix shell scripting basics
De 0 a 100 con Bash Shell Scripting y AWK
Meet up symfony 16 juin 2017 - Les PSR
C project on a bookshop for saving of coustmer record
20 modules i haven't yet talked about
Beware: Sharp Tools
Javascript - The basics
ES6 - Level up your JavaScript Skills
Taking Inspiration From The Functional World
Bioinformatica p4-io
Generating Power with Yield
Asynchronous I/O in PHP
Beware sharp tools
Perl: Coro asynchronous
bank management system
Gogo shell
プログラム実行の話と
OSとメモリの挙動の話
Tgh.pl
Using the Command Line with Magento
Darkmira Tour PHP 2016 - Automatizando Tarefas com Phing
Ad

More from Yuriko IKEDA (20)

PDF
トルクメニスタンのインターネット事情
PDF
デフォルト誕生日を知らべてみた
PDF
Settaya
PDF
WordCamp 5.3 & Community
PDF
Photography staff at WordCamp Tokyo 2019
PDF
端末開発のススメ
PDF
WordPressでIoTをはじめよう
PDF
Local 10 周年パーティーに行ってきた話
PDF
Fastest routes from Meisei-univ to Shinjuku
PDF
Faster route from Shinjuku to Meisei univ.
PDF
Introduce raspberry pi's 7 years
PDF
WordPress 次期バージョンと日本のコミュニティ
PDF
カルト宗教の始め方
PDF
WordCamp Osaka の熱気を可視化してみた
PDF
WordPressで制御するこれからのIoT
PDF
Create LED lightened Wapuu (LEDパネルで光るわぷーを)
PDF
世界No.1 CMS WordPressへのいざない
PDF
LEDマトリックスで光るわぷー(WordPressで指定編その1)
PDF
Raspi intro-20170805
PDF
raspi-led-matrix
トルクメニスタンのインターネット事情
デフォルト誕生日を知らべてみた
Settaya
WordCamp 5.3 & Community
Photography staff at WordCamp Tokyo 2019
端末開発のススメ
WordPressでIoTをはじめよう
Local 10 周年パーティーに行ってきた話
Fastest routes from Meisei-univ to Shinjuku
Faster route from Shinjuku to Meisei univ.
Introduce raspberry pi's 7 years
WordPress 次期バージョンと日本のコミュニティ
カルト宗教の始め方
WordCamp Osaka の熱気を可視化してみた
WordPressで制御するこれからのIoT
Create LED lightened Wapuu (LEDパネルで光るわぷーを)
世界No.1 CMS WordPressへのいざない
LEDマトリックスで光るわぷー(WordPressで指定編その1)
Raspi intro-20170805
raspi-led-matrix
Ad

Recently uploaded (20)

PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
Improvisation in detection of pomegranate leaf disease using transfer learni...
PDF
CloudStack 4.21: First Look Webinar slides
PDF
A review of recent deep learning applications in wood surface defect identifi...
PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
Comparative analysis of machine learning models for fake news detection in so...
PPTX
Chapter 5: Probability Theory and Statistics
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
Consumable AI The What, Why & How for Small Teams.pdf
PDF
Architecture types and enterprise applications.pdf
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PDF
Convolutional neural network based encoder-decoder for efficient real-time ob...
PDF
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
PDF
Credit Without Borders: AI and Financial Inclusion in Bangladesh
PDF
UiPath Agentic Automation session 1: RPA to Agents
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Enhancing plagiarism detection using data pre-processing and machine learning...
PPT
Module 1.ppt Iot fundamentals and Architecture
Developing a website for English-speaking practice to English as a foreign la...
Improvisation in detection of pomegranate leaf disease using transfer learni...
CloudStack 4.21: First Look Webinar slides
A review of recent deep learning applications in wood surface defect identifi...
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
Final SEM Unit 1 for mit wpu at pune .pptx
Comparative analysis of machine learning models for fake news detection in so...
Chapter 5: Probability Theory and Statistics
Getting started with AI Agents and Multi-Agent Systems
NewMind AI Weekly Chronicles – August ’25 Week III
Consumable AI The What, Why & How for Small Teams.pdf
Architecture types and enterprise applications.pdf
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
Convolutional neural network based encoder-decoder for efficient real-time ob...
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
Credit Without Borders: AI and Financial Inclusion in Bangladesh
UiPath Agentic Automation session 1: RPA to Agents
1 - Historical Antecedents, Social Consideration.pdf
Enhancing plagiarism detection using data pre-processing and machine learning...
Module 1.ppt Iot fundamentals and Architecture

Scroll pHAT HD に美咲フォント