打開包裝,一張光碟、一片LCD、觸控筆、幾顆螺絲....,光碟搜尋完畢,找不到太多有幫助的資訊,唯一讓我很清楚的,是讓我找到了製造商產品網頁:WaveShare(微雪電子):4inch RPi LCD (A),跟DVD上的資料,沒啥大差異。
光碟內容只有已經裝好驅動程式的作業系統映像檔。如果要進一步控制,就沒輒了!
好吧,既然要花了$,就好好研究一下吧!
首先發現,目前支援rpi的SPI,在github上有notro/fbtft的開源,簡單教學這裏有!還有個日文網站雖然看不懂日文但是可以參考參考。
在github的論壇
首先以模組的模式編譯
以模块的形式编译进内核(需要手动或脚本加载模块)3.12.25+(试验成功)
1.升級韌體:
sudo REPO_URI=https://github.com/notro/rpi-firmware rpi-update
2.raspi-config中,啟動SPI
3.sudo nano /etc/modules ,加入兩行:
flexfb nobacklight regwidth=16 init=-1,0xb0,0x0,-1,0x11,-2,250,-1,0x3A,0x55,-1,0xC2,0x44,-1,0xC5,0x00,0x00,0x00,0x00,-1,0xE0,0x0F,0x1F,0x1C,0x0C,0x0F,0x08,0x48,0x98,0x37,0x0A,0x13,0x04,0x11,0x0D,0x00,-1,0xE1,0x0F,0x32,0x2E,0x0B,0x0D,0x05,0x47,0x75,0x37,0x06,0x10,0x03,0x24,0x20,0x00,-1,0xE2,0x0F,0x32,0x2E,0x0B,0x0D,0x05,0x47,0x75,0x37,0x06,0x10,0x03,0x24,0x20,0x00,-1,0x36,0x48,-1,0x11,-1,0x29,-3 width=320 height=480
fbtft_device name=flexfb speed=16000000 gpios=reset:25,dc:24
其中 -1,0x36,0x48 為:
init width height swapxy calibration
0x28 480 320 1 "3900 240 240 3900"
0x48 320 480 0 "3900 240 3900 240"
0x88 320 480 0 "240 3900 240 3900"
0xE8 480 320 1 "240 3900 3900 240"
4.sudo nano /boot/cmdline.txt:加入:
5.sudo nano /usr/share/X11/xorg.conf.d/99-fbturbo.conf:
6.sudo nano /boot/config.txt:加入
fbcon=map:1 fbcon=font:ProFont6x11
5.sudo nano /usr/share/X11/xorg.conf.d/99-fbturbo.conf:
更改 fb0 為 fb1
6.sudo nano /boot/config.txt:加入
dtoverlay=ads7846,speed=500000,penirq=17
7.安裝校正程式
sudo apt-get install libx11-dev libxext-dev libxi-dev x11proto-input-dev
wget http://github.com/downloads/tias/xinput_calibrator/xinput_calibrator-0.7.5.tar.gz
tar xzvf xinput_calibrator-0.7.5.tar.gz
cd xinput_calibrator-0.7.5/
./configure
make
sudo make install
8.校正觸控螢幕
DISPLAY=":0.0" /usr/local/bin/xinput_calibrator
將校正結果加入
sudo nano /usr/share/X11/xorg.conf.d/99-calibration.conf
Section "InputClass"
Identifier "calibration"
MatchProduct "ADS7846 Touchscreen"
Option "Calibration" "124 3921 3961 198"
EndSection