ラズパイ4デジカメ計画①〜格安の(サポートの終了したWiringPI系)液晶タッチパネルを使えるようにする
※ 当ページには【広告/PR】を含む場合があります。
2024/02/05
2024/02/14
+ Bookworm以前、以降でシステムの中身におおきな壁がある
+ WiringPiはもうサポートされないため、BookwormやRPi5だと論外
(破滅の道とは分かっていても...)Bookwormで液晶タッチパネルを試したい!
Bookwormにタッチパネルドライバをインストール
$ mkdir touchpanel-driver
$ cd touchpanel-driver/
$ git clone https://github.com/osoyoo/LCD-show.git
Cloning into 'LCD-show'...
...
$ cd LCD-show/
$ chmod +x lcd35b-show
$ ./lcd35b-show
Reading package lists... Done
Building dependency tree... Done
#...中略
build
[ 50%] Building C object CMakeFiles/fbcp.dir/main.c.o
/home/**********/touchpanel-driver/LCD-show/usr/rpi-fbcp/main.c:9:10: fatal error: bcm_host.h: No such file or directory
9 | #include <bcm_host.h>
| ^~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/fbcp.dir/build.make:76: CMakeFiles/fbcp.dir/main.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/fbcp.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
install: cannot stat 'fbcp': No such file or directory
#...中略
The system will reboot now!
cmake
bcm_host.h
$ sudo apt install libraspberrypi-dev raspberrypi-kernel-headers
$ ./lcd35b-show
#もしくは
sudo apt --fix-broken install
「wiringpi」
cd /tmp
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
WiringPiを強制的にインストールする
$ gpio -v
-bash: gpio: command not found
http://wiringpi.com/index.html
This is wiringpi.com.
As of the end of 2023, you'll not find anything here anymore. It's gone.
Email if you want - if you know my email address. Work it out.
-Gordon
「ほしいなら直接メールしてくれ」
As of 31st October 2023 nobody has shown an interest in properly maintaining it.
Between this, and changes to GPIO in Rasberry Pi OS Bookworm and on the Raspberry Pi 5,
this project is going nowhere.
It has been archived to more clearly indicate this status.
$ wget https://github.com/WiringPi/WiringPi/releases/download/2.61-1/wiringpi-2.61-1-armhf.deb
$ sudo apt install -y ./wiringpi-2.61-1-armhf.deb
gpio: error while loading shared libraries: libcrypt.so.1: cannot open shared object file: No such file or directory
armhf
$ sudo dpkg --add-architecture armhf
#アーキテクチャの確認
$ sudo dpkg --print-foreign-architectures
armhf
#armhf用ライブラリの追加
$ sudo apt install libcrypt1:armhf
$ gpio -v
gpio version: 2.61
Copyright (c) 2012-2018 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty
Oops: Unable to determine board revision from /proc/cpuinfo
-> No "Hardware" line
-> You'd best google the error to find out why.
No "Hardware" line
ラズパイのLegacyイメージでBullseyeで試す
$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye
液晶タッチパネルのドライバーをインストールする
$ mkdir touchpanel-driver
$ cd touchpanel-driver/
$ git clone https://github.com/osoyoo/LCD-show.git
$ cd LCD-show/
$ chmod +x lcd35b-show
$ ./lcd35b-show
#...中略
The system will reboot now!
wiringpiをBullseyeにインストールする
wiringpi
$ wget https://github.com/WiringPi/WiringPi/releases/download/2.61-1/wiringpi-2.61-1-armhf.deb
$ sudo apt install -y ./wiringpi-2.61-1-armhf.deb
$ gpio -v
gpio version: 2.61
Copyright (c) 2012-2018 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty
Raspberry Pi Details:
Type: Pi 4B, Revision: 01, Memory: 2048MB, Maker: Sony
* Device tree is enabled.
*--> Raspberry Pi 4 Model B Rev 1.1
* This Raspberry Pi supports user-level GPIO access.
ラズパイ用液晶タッチパネルで注意すべきこと〜「rpi-update」ダメ絶対
余談〜タッチパネルの反応がおかしくなったときの対処法
lcd35b-show
$ cd LCD-show/
$ sudo ./lcd35b-show 180
ソフトウェアキーボードをSSHから設定する
$ sudo apt install matchbox-keyboard -y
$ sudo apt-get install ttf-kochi-gothic xfonts-intl-japanese xfonts-intl-japanese-big xfonts-kaname -y
scrot
/usr/share/matchbox-keyboard/
$ ls /usr/share/matchbox-keyboard/ | grep xml
base-fragment-ar_EG.xml
#...
keyboard-internet.xml
keyboard-lq1.xml
keyboard-numpad-extended.xml
keyboard-numpad-small.xml
keyboard-symbol.xml
keyboard.xml
keyboard-lq1.xml
~/.matchbox
$ mkdir .matchbox
$ sudo cp /usr/share/matchbox-keyboard/keyboard-lq1.xml ~/.matchbox/keyboard.xml
$ sudo chown <ユーザーID>:<グループID> ~/.matchbox/keyboard.xml
/usr/bin
toggle-matchbox-keyboard.sh
$ sudo nano /usr/bin/toggle-matchbox-keyboard.sh
#!/bin/bash
PID=`pidof matchbox-keyboard`
if [ ! -e $PID ]; then
killall matchbox-keyboard
else
matchbox-keyboard &
fi
$ sudo chmod +x /usr/bin/toggle-matchbox-keyboard.sh
matchbox-keyboard
$ sudo nano /usr/share/applications/inputmethods/matchbox-keyboard.desktop
[Desktop Entry]
Name=Keyboard
Comment=Virtual Keyboard
#Exec=matchbox-keyboard
#👇こっちに書き換え
Exec=toggle-matchbox-keyboard.sh
Type=Application
Icon=matchbox-keyboard.png
Categories=Panel;Utility;MB
X-MB-INPUT-MECHANSIM=True
まとめ
+ Bookworm以前、以降でアーキテクチャレベルにシステムの中身におおきな違いがある
+ WiringPiはサポートされないため、BookwormやRPi5以降は動かない
+ ラズパイでGPIOを使った開発を行いたい場合、別のライブラリの利用を検討する
+ WiringPiを使い続けたい場合にはRaspberry Pi OS Bullseyeをレガシーインストールする
特典〜matchbod-keyboardのキー全部出しサンプル
my-custom-keyboard.xml
$ sudo nano /usr/share/matchbox-keyboard/my-custom-keyboard.xml
<?xml version="1.0" encoding="UTF-8"?>
<keyboard>
<options>
<!-- not yet implemented -->
</options>
<layout id="default keyboard">
<row>
<space width="500" extended="true"/>
<key fill="true">
<default display="Esc" action="escape" />
</key>
<key width="1500">
<default display="1" />
<shifted display="!" />
<mod1 display="F1" action="f1"/>
</key>
<key width="1500">
<default display="2" />
<shifted display='@' />
<mod1 display="F2" action="f2"/>
</key>
<key width="1500">
<default display="3" />
<shifted display="#" />
<mod1 display="F3" action="f3"/>
</key>
<key width="1500">
<default display="4" />
<shifted display="$" />
<mod1 display="F4" action="f4"/>
</key>
<key width="1500">
<default display="5" />
<shifted display="%" />
<mod1 display="F5" action="f5"/>
</key>
<key width="1500">
<default display="6" />
<shifted display="^" />
<mod1 display="F6" action="f6"/>
</key>
<key width="1500">
<default display="7" />
<shifted display="&" />
<mod1 display="F7" action="f7"/>
</key>
<key width="1500">
<default display="8" />
<shifted display="*" />
<mod1 display="F8" action="f8"/>
</key>
<key width="1500">
<default display="9" />
<shifted display="(" />
<mod1 display="F9" action="f9"/>
</key>
<key fill="true">
<default display="0" />
<shifted display=")" />
<mod1 display="F10" action="f10"/>
</key>
<key fill="true">
<default display="-" />
<shifted display="_" />
<mod1 display="F11" action="f11"/>
</key>
<key fill="true">
<default display="=" />
<shifted display="+" />
<mod1 display="F12" action="f12"/>
</key>
<key fill="true">
<default display="Ins" action="insert"/>
</key>
<key fill="true">
<default display="Del" action="delete"/>
</key>
<space width="500" extended="true"/>
<key width="4000" extended="true">
<default display="Home" action="home"/>
</key>
<key width="4000" extended="true">
<default display="PgUp" action="pageup"/>
</key>
<space width="500" extended="true"/>
</row>
<row>
<space width="500" extended="true"/>
<key fill="true">
<!-- <default display="↹" action="tab"/> -->
<default display="Tab" action="tab"/>
</key>
<key>
<default display="`" />
<shifted display="~" />
</key>
<key obey-caps='true'>
<default display="q" />
<shifted display="Q" />
</key>
<key obey-caps='true'>
<default display="w" />
<shifted display="W" />
</key>
<key obey-caps='true'>
<default display="e" />
<shifted display="E" />
</key>
<key obey-caps='true'>
<default display="r" />
<shifted display="R" />
</key>
<key obey-caps='true'>
<default display="t" />
<shifted display="T" />
</key>
<key obey-caps='true'>
<default display="y" />
<shifted display="Y" />
</key>
<key obey-caps='true'>
<default display="u" />
<shifted display="U" />
</key>
<key obey-caps='true'>
<default display="i" />
<shifted display="I" />
</key>
<key obey-caps='true'>
<default display="o" />
<shifted display="O" />
</key>
<key obey-caps='true'>
<default display="p" />
<shifted display="P" />
</key>
<key>
<default display="{" />
<shifted display="[" />
</key>
<key>
<default display="}" />
<shifted display="]" />
</key>
<key>
<default display="\" />
<shifted display="|" />
</key>
<key fill="true">
<default display="Bksp" action="backspace"/>
</key>
<space width="500" extended="true"/>
<key width="4000" extended="true">
<default display="End" action="end"/>
</key>
<key width="4000" extended="true">
<default display="PgDn" action="pagedown"/>
</key>
<space width="500" extended="true"/>
</row>
<row>
<space width="500" extended="true"/>
<key fill="true">
<default display="Caps" action="modifier:caps"/>
</key>
<key obey-caps='true'>
<default display="a" />
<shifted display="A" />
</key>
<key obey-caps='true'>
<default display="s" />
<shifted display="S" />
</key>
<key obey-caps='true'>
<default display="d" />
<shifted display="D" />
</key>
<key obey-caps='true'>
<default display="f" />
<shifted display="F" />
</key>
<key obey-caps='true'>
<default display="g" />
<shifted display="G" />
</key>
<key obey-caps='true'>
<default display="h" />
<shifted display="H" />
</key>
<key obey-caps='true'>
<default display="j" />
<shifted display="J" />
</key>
<key obey-caps='true'>
<default display="k" />
<shifted display="K" />
</key>
<key obey-caps='true'>
<default display="l" />
<shifted display="L" />
</key>
<key>
<default display=";" />
<shifted display=":" />
</key>
<key>
<default display="'" />
<shifted display='"' />
</key>
<key fill="true">
<default display="Enter" action="return"/>
</key>
<space width="500" extended="true"/>
<space width="4000" extended="true" />
<space width="4000" extended="true" />
<space width="500" extended="true"/>
</row>
<row>
<space width="500" extended="true"/>
<key fill="true">
<default display="Shift" action="modifier:shift"/>
</key>
<key obey-caps='true'>
<default display="z" />
<shifted display="Z" />
</key>
<key obey-caps='true'>
<default display="x" />
<shifted display="X" />
</key>
<key obey-caps='true'>
<default display="c" />
<shifted display="C" />
</key>
<key obey-caps='true'>
<default display="v" />
<shifted display="V" />
</key>
<key obey-caps='true'>
<default display="b" />
<shifted display="B" />
</key>
<key obey-caps='true'>
<default display="n" />
<shifted display="N" />
</key>
<key obey-caps='true'>
<default display="m" />
<shifted display="M" />
</key>
<key>
<default display="," />
<shifted display="<" />
</key>
<key>
<default display="." />
<shifted display=">" />
</key>
<key>
<default display="/" />
<shifted display="?" />
</key>
<key fill="true">
<default display="Shift" action="modifier:shift"/>
</key>
<space width="500" extended="true"/>
<key width="4000" extended="true">
<default display="Up" action="up"/>
</key>
<key width="4000" extended="true">
<default display="Down" action="down"/>
</key>
<space width="500" extended="true"/>
</row>
<row>
<space width="500" extended="true"/>
<key width="4000" extended="true">
<default display="Ctrl" action="modifier:ctrl"/>
</key>
<key width="4000" extended="true">
<default display="Alt" action="modifier:alt"/>
</key>
<!-- <key fill="true"> -->
<key width="16000" extended="true">
<default display=" S p a c e B a r " action="space" />
</key>
<key width="5000" extended="true">
<default display="Func" action="modifier:mod1"/>
</key>
<space width="500" extended="true"/>
<key width="4000" extended="true">
<default display="Left" action="left"/>
</key>
<key width="4000" extended="true">
<default display="Right" action="right"/>
</key>
<space width="500" extended="true"/>
</row>
</layout>
</keyboard>
$ sudo cp /usr/share/matchbox-keyboard/my-custom-keyboard.xml ~/.matchbox/keyboard.xml
$ sudo chown <ユーザーID>:<グループID> ~/.matchbox/keyboard.xml
記事を書いた人
ナンデモ系エンジニア
電子工作を身近に知っていただけるように、材料調達からDIYのハウツーまで気になったところをできるだけ細かく記事にしてブログ配信してます。
カテゴリー