●基本的に以下のサイトのコピーです。サイト消失すると困るため。

 ついでに、なかなか日本語解説のページがないので、翻訳します

 ライトな感じでRaspberryPiを始めたばっかりの人が躓いていると思いますので。。。

 あと、私が行った作業に合わせて少し内容変更。

   1.44inch LCD HAT – Waveshare Wiki


SPI インターフェイスの有効化

  • コマンドライン(シェル)からコンフィグ画面を立ち上げます。
#sudo raspi-config

「Interfacing Options」を選択 -> SPI -> 「enable SPI interface」で「はい/Yes」を選択

再起動します:

sudo reboot

※ほかのデバイスでSPIインタフェイスを使っていないこと確認してください

ライブラリーのインストール

  • BCM2835 librariesのインストール
#wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.68.tar.gz
#tar zxvf bcm2835-1.68.tar.gz 
#cd bcm2835-1.68/
#sudo ./configure && sudo make && sudo make check && sudo make install

詳細はこちら: http://www.airspayce.com/mikem/bcm2835/

  • Python librariesのインストール
sudo apt-get update
sudo apt-get install python-pip 
sudo pip install RPi.GPIO
sudo pip install spidev

お試しプログラムのダウンロード

シェルから以下のコマンドを入力

#sudo apt-get install p7zip-full -y
#wget https://www.waveshare.com/w/upload/f/fa/1.44inch-LCD-HAT-Code.7z
#7z x 1.44inch-LCD-HAT-Code.7z
#sudo chmod 777 -R 1.44inch-LCD-HAT-Code
#cd 1.44inch-LCD-HAT-Code/RaspberryPi/

デモンストレーションプログラムの実行

  • C
cd c
make clean
make
sudo ./main
  • For Raspberry Pi 4B もしくはシステムバージョンが raspbian_lite-2019-06-20なら、以下の通り/boot/config.txtの内容を変更する必要があります
config.txtをエディターで開きます
#sudo nano /boot/config.txt

config.txtのケツ([all]の後)に以下を足し、保存し、再起動します。

(たぶん、GPIOのプルアップ設定を明記しないといけなくなったんでしょうね。)

gpio=6,19,5,26,13,21,20,16=pu
  • python
cd python
sudo python main.py
sudo python key_demo.py

FBCP Driverの設定

(1.44LCDのためのVRAMを設定するドライバーかな)

The Framebuffer uses a memory area to store the display content, and changes the data in the memory to change the display content.

There is an open-source project on github: fbcp-ili9341. Compared with other fbcp projects, this project uses partial refresh and DMA to achieve a refresh rate of up to 60fps.

このフレームバッファーはディスプレーに表示するためにメモリーエリアを消費します。

Githubにfbcd-ili9341っていうオープンソースの何チャラ・・・って、訳は各自でどうぞ。

コンパイルと実行

#sudo apt-get install cmake -y
#cd ~
#wget https://www.waveshare.com/w/upload/f/f9/Waveshare_fbcp.7z
#sudo apt-get install p7zip-full
#7z x Waveshare_fbcp.7z
#cd waveshare_fbcp
#mkdir build
#cd build
#cmake -DSPI_BUS_CLOCK_DIVISOR=20 -DWAVESHARE_1INCH44_LCD_HAT=ON -DBACKLIGHT_CONTROL=ON -DSTATISTICS=0 ..
#make -j
#sudo ./fbcp

この最後のfbcdという実行ファイルが、このステップの成果物で、これを実行すると、メモリーエリアに1.44inchLCD用のVRAMを作成し、VRAの表示内容を対応させます。
つまり何が起こるかというと、これを実行した瞬間、1.44inchLCDにコマンドプロンプトが表示されます。

あと、英語には書いていませんが、上の「cmake -DSPI_BUS_CLOCK_DIVISOR=20 -DWAVESHARE_1INCH44_LCD_HAT=ON -DBACKLIGHT_CONTROL=ON -DSTATISTICS=0 ..」ですが、赤の部分、これはスイッチになってて、このままだとバックライトを時間経過で消す設定になっていますんで、そうしたくない場合はここを「DBACKLIGHT_CONTROL=OFF」にすると、幸せです。

上述プログラムの起動時に自動実行するよう設定

/usr/local/binにfbcpをコピーし、起動時に起動するようrc.localに定義します

#sudo cp ./fbcp /usr/local/bin/
#sudo nano /etc/rc.local

以下のようにexit 0の記述の上にfbcp&と追加します。

1in3 lcd fb5.png

ディスプレイ解像度の設定

解像度の設定は/boot/config.txt ファイルで行います

#sudo nano /boot/config.txt

config.txtの[all]の後に以下を記述。(上でプルアップの設定?を行った行の下あたりに書けばいい)

本来このディスプレイ128*128なんですが、それだと一部しか映らなさすぎるので、

字がつぶれるのを覚悟で、表示範囲を広げます。

hdmi_force_hotplug=1
hdmi_cvt=300 300 60 1 0 0 0
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
display_rotate=0

なお、RaspberryPi4を使っている人は以下の設定(OpenGLサポートのドライバ、3G表示のためのもの)を切らないとだめらしいです.なので#でコメントアウトします

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
#dtoverlay=vc4-fkms-v3d
#max_framebuffers=2
その後再起動します
#sudo reboot


以下、試していません


The final display effect is scaled and displayed on the 1.3inch LCD in proportion. The setting of the resolution here should be slightly larger than the LCD resolution, the too high resolution will cause the font display to be blurred.

After rebooting the system, the Raspberry Pi OS user interface will be displayed.

1200px-1.3inch lcd hat fbtftdesktop.png

Analog mouse

There are a joystick and three buttons on the panel of the module, which we can use to control the mouse of the Raspberry Pi

  • Install the library, then download and run the demo
sudo apt-get install python-xlib
sudo pip install PyMouse
wget http://www.waveshare.net/w/upload/d/d3/Mouse.7z
7z x Mouse.7z
sudo python mouse.py

【Note】The mouse.py needs to run under the graphical interface, which will not run under the SSH login. You can skip this step directly, the Pi will run the demo automatically by booting up.

  • If you are using the Raspberry PI 4B and the version of your image is after raspbian_lite-2019-06-20, you need to set as below:
sudo nano /boot/config.txt

And then add the following line at the end of the config.txt.

gpio=6,19,5,26,13,21,20,16=pu

Use the joystick to move up, down, left, and right, you can see that the mouse is moving.

  • Set the auto-start when power on
cd .config/
mkdir autostart
cd autostart/
sudo nano local.desktop

And then add the following lines at the end of the local.desktop

[Desktop Entry]
Type=Application
Exec=python /home/pi/mouse.py

Reboot the system, you can use the buttons to control the mouse.

sudo reboot

Others

If you are interested in getting a game console, you can refer to the following two links:

https://www.sudomod.com/forum/viewtopic.php?f=11&t=5371&start=10
https://pi0cket.com/guides/tiny-software-for-tinypi/#more-99