mr/raspberry_pi_epaper_button
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
* ラズパイでe-paperのボタン押下を取得する [#d172e256]
** 使ったもの [#k2a6bd76]
- Raspberry Pi 3B+ with "Debian GNU/Linux 12 (bookworm)"
- [[264x176, 2.7inch E-Ink display HAT for Raspberry Pi, ...
#ref(https://www.waveshare.com/img/devkit/LCD/2.7inch-e-P...
e-paper は、秋葉原 千石通商で買いました([[WaveShare 1335...
** 4つのボタン(key1 .. key4)のGPIOピンアサイン [#zbca45...
- [[2.7inch e-Paper HAT Manual - Waveshare Wiki>https://w...
#ref(https://www.waveshare.com/w/upload/c/ce/2.7inch_e-Pa...
** お手本(サンプルコード) [#z4701b06]
- [[Key example · waveshareteam/e-Paper@22032b7 · GitHub>...
- 残念なことに、bookwormだと動かない(RPi.GPIO.add_event_...
** gpiozero で書き換え [#q6c1ea1e]
- [[button-13354-stdout.py>https://gist.github.com/kemaso...
#gist(0527438f4da33ee8a1249c94d19b7d9f)
実行すると、key1..4の押下と同時に標準出力へ 1..4 を出力し...
#prism(bash){{{
$ python3 button-13354-stdout.py
4
3
2
2
4
^C
Program interrupted. Cleaning up GPIO...
GPIO cleanup complete.
}}}
** 活用例 [#g14f255d]
#prism(bash){{{
python3 button-13354-stdout.py | while read -r b; do
case "$b" in
1)
# key1を押した時の処理
curl -sSL 'https://example.com/api/v1/someapi?id=1&...
;;
2)
# key2を押した時の処理
;;
3)
# key3を押した時の処理
sudo reboot
;;
4)
# key1を押した時の処理
;;
esac
done
}}}
終了行:
* ラズパイでe-paperのボタン押下を取得する [#d172e256]
** 使ったもの [#k2a6bd76]
- Raspberry Pi 3B+ with "Debian GNU/Linux 12 (bookworm)"
- [[264x176, 2.7inch E-Ink display HAT for Raspberry Pi, ...
#ref(https://www.waveshare.com/img/devkit/LCD/2.7inch-e-P...
e-paper は、秋葉原 千石通商で買いました([[WaveShare 1335...
** 4つのボタン(key1 .. key4)のGPIOピンアサイン [#zbca45...
- [[2.7inch e-Paper HAT Manual - Waveshare Wiki>https://w...
#ref(https://www.waveshare.com/w/upload/c/ce/2.7inch_e-Pa...
** お手本(サンプルコード) [#z4701b06]
- [[Key example · waveshareteam/e-Paper@22032b7 · GitHub>...
- 残念なことに、bookwormだと動かない(RPi.GPIO.add_event_...
** gpiozero で書き換え [#q6c1ea1e]
- [[button-13354-stdout.py>https://gist.github.com/kemaso...
#gist(0527438f4da33ee8a1249c94d19b7d9f)
実行すると、key1..4の押下と同時に標準出力へ 1..4 を出力し...
#prism(bash){{{
$ python3 button-13354-stdout.py
4
3
2
2
4
^C
Program interrupted. Cleaning up GPIO...
GPIO cleanup complete.
}}}
** 活用例 [#g14f255d]
#prism(bash){{{
python3 button-13354-stdout.py | while read -r b; do
case "$b" in
1)
# key1を押した時の処理
curl -sSL 'https://example.com/api/v1/someapi?id=1&...
;;
2)
# key2を押した時の処理
;;
3)
# key3を押した時の処理
sudo reboot
;;
4)
# key1を押した時の処理
;;
esac
done
}}}
ページ名: