update: 2016/09/13
reference:
1. Home · notro/fbtft Wiki
測試硬體: 1.8" TFT LCD ST7735R (160x128)
A. Pi 啟用 SPI 功能
$ sudo raspi-config
> Advanced Options
> A5 SPI Enable/Disable automatic loading of SPI kernel module (needed for e.g. PiFace)
> Enable
-----------------------------------------------------------------------------------------------
B. 查詢支援的 fbtft_device
$ sudo modprobe fbtft_device name=list; dmesg | tail -50
...
[ 1262.538743] fbtft_device: Supported displays:
[ 1262.538751] fbtft_device: adafruit18
[ 1262.538758] fbtft_device: adafruit18_green
....
-----------------------------------------------------------------------------------------------
C. 載入 Framebuffer TFT LCD 設備
$ sudo modprobe fbtft_device name=adafruit18
p.s. There is one required module parameter, and that is name. It specifies which display (device) to register.
-----------------------------------------------------------------------------------------------
D. 查詢是否載入成功
$ ls -al /dev/fb*
/dev/fb0 ----> default display output
/dev/fb1 ----> fbtft
$ dmesg
[ 2532.384028] fbtft_device: module is from the staging directory, the quality is unknown, you have been warned.
[ 2532.391421] spidev spi0.0: spidev spi0.0 500kHz 8 bits mode=0x00
[ 2532.391453] spidev spi0.1: spidev spi0.1 500kHz 8 bits mode=0x00
[ 2532.391494] bcm2708_fb soc:fb: soc:fb id=-1 pdata? no
[ 2532.391549] spidev spi0.0: Deleting spi0.0
[ 2532.392348] fbtft_device: GPIOS used by 'adafruit18':
[ 2532.392368] fbtft_device: 'reset' = GPIO25
[ 2532.392377] fbtft_device: 'dc' = GPIO24
[ 2532.392385] fbtft_device: 'led' = GPIO18
[ 2532.392402] spidev spi0.1: spidev spi0.1 500kHz 8 bits mode=0x00
[ 2532.392418] spi spi0.0: fb_st7735r spi0.0 32000kHz 8 bits mode=0x00
[ 2532.425447] fb_st7735r: module is from the staging directory, the quality is unknown, you have been warned.
[ 2533.359781] graphics fb1: fb_st7735r frame buffer, 128x160, 40 KiB video memory, 4 KiB DMA buffer memory, fps=20, spi0.0 at 32 MHz
$ dmesg | grep graphics
[ 2067.729317] graphics fb1: fb_st7735r frame buffer, 128x160, 40 KiB video memory, 4 KiB DMA buffer memory, fps=20, spi0.0 at 32 MHz
-----------------------------------------------------------------------------------------------
E. 測試:
1. Console
> Map console 1 to framebuffer 1, login screen will show up on the display
$
con2fbmap 1 1
$ sudo apt-get -y install fbi
$ wget http://art110.wikispaces.com/file/view/Mystery-100x100.jpg/30649064/Mystery-100x100.jpg
$ chmod 755 Mystery-100x100.jpg
$ fbi -d /dev/fb1 -T 1 -noverbose -a Mystery-100x100.jpg
$ sudo apt-get install -y mplayer
$ wget http://fredrik.hubbe.net/plugger/test.mpg
$ chmod 755 test.mpg
// play with loop infinitely
sudo SDL_VIDEODRIVER=fbcon SDL_FBDEV=/dev/fb1 mplayer -loop 0 -vo sdl -framedrop test.mpg
F. 開機時自動啟動播放影片(建議方式)
$ sudo nano .bashrc
....
# auto load fbtft_device:adafruit18 & play loop video: test.mpg
sudo modprobe fbtft_device name=adafruit18
sudo SDL_VIDEODRIVER=fbcon SDL_FBDEV=/dev/fb1 mplayer -loop 0 -vo sdl -framedrop test.mpg
-----------------------------------------------------------------------------------------------
G. Shell Script
檔名: run_nuit_blanche.sh
#!/bin/bash
sudo modprobe fbtft_device name=adafruit18
sudo SDL_VIDEODRIVER=fbcon SDL_FBDEV=/dev/fb1 mplayer -loop 0 -vo sdl -framedrop nuit_blanche.mpg
-----------------------------------------------------------------------------------------------
H. Framebuffer mirroring
1. 說明:
By mirroring /dev/fb0 onto /dev/fb1, we can take advantage of the GPU for
hardware accelrated video playback.
fbcp takes a snapshot of /dev/fb0, copies it to /dev/fb1 and waits 25ms before
repeating.
Snapshotting takes ~10ms and with a 25ms delay it gives roughly
1000/(10+25) = 28fps
CPU usage: ~2%
Note: Snapshot and /dev/fb1 driver refresh is not syncronized.
2. Install fbcp:
$ sudo apt-get install cmake
$ git clone https://github.com/tasanakorn/rpi-fbcp
$ cd rpi-fbcp/
$ mkdir build
$ cd build/
$ cmake ..
$ make
$ sudo install fbcp /usr/local/bin/fbcp
3. Load drivers and fbcp:
$ sudo nano .bashrc
....
############
# start fbcp
echo "tty = $(tty)"
if [ $(tty) == "/dev/tty1" ]; then
echo "We have a match."
cd
# Load fbcp drivers and run fbcp
sudo modprobe fbtft dma
sudo modprobe fbtft_device name=adafruit18
#
rotate=90 speed=48000000 fps=50
# Start fb copying process in the background
sleep 3
fbcp &
#/usr/local/bin/fbcp &
# Play video on /dev/fb0, which will also show up on /dev/fb1
# 720x480
# --win x1,y1,x2,y2
sleep 1
omxplayer -b --loop --win 180,120,540,360 160x128.mp4
# Stop framebuffer copy
#killall fbcp
else
echo "We dont match."
fi
-----------------------------------------------------------------------------------------------
I. 其他
1. 檢查沒有接螢幕時的預設視窗大小
$ /opt/vc/bin/tvservice -s
state 0x120006 [DVI DMT (4) RGB full 4:3], 720x480 @ 60.00Hz, progressive
2. 設定預設視窗大小
$ sudo nano /boot/config.txt
....
# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720
#framebuffer_width=720
#framebuffer_height=480
....
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。