Difference between revisions of "Matrix - 2'8 SPI Key TFT"

From FriendlyELEC WiKi
Jump to: navigation, search
(Applications)
(Compile & Run Test Program)
Line 173: Line 173:
  
 
==Compile & Run Test Program==
 
==Compile & Run Test Program==
 +
===H3/H5配合Linux-4.x主线内核===
 +
当使用的开发板为H3或者H5系列时,假设使用的ROM是基于Linux-4.x主线内核的Ubuntu-Core with Qt-Embedded系统,那么首先需要通过npi-config工具来使能Matrix-2'8_SPI_Key_TFT。启动系统,在root用户下执行下列命令运行npi-config:
 +
<syntaxhighlight lang="bash">
 +
$ npi-config
 +
</syntaxhighlight>
 +
然后依次进入下列菜单项:<br>
 +
[[File:tft-1.png|frameless|1000px|tft-1]]<br>
 +
进入SPI菜单:<br>
 +
[[File:tft-2.png|frameless|1000px|tft-2]]<br>
 +
选择是否使能SPI0:<br>
 +
[[File:tft-3.png|frameless|1000px|tft-3]]<br>
 +
选择enable SPI0后,再选择SPI0上连接的设备为Matrix-2'8_SPI_Key_TFT:<br>
 +
[[File:tft-4.png|frameless|1000px|tft-4]]<br>
 +
最后返回主菜单,选择<Finish>,然后根据提示重启系统。重新启动系统后,执行下列命令检查Matrix-2'8_SPI_Key_TFT的显示芯片和触摸芯片是否被使能:
 +
<syntaxhighlight lang="bash">
 +
$ ls /dev/fb-st7789s
 +
/dev/fb-st7789s
 +
</syntaxhighlight>
 +
/dev/fb-st7789s就是显示芯片的framebuffer设备节点。
 +
<syntaxhighlight lang="bash">
 +
$ ls /dev/input/ts-ads7846
 +
/dev/input/ts-ads7846
 +
</syntaxhighlight>
 +
/dev/input/ts-ads7846就是触摸芯片的设备节点。
 +
第一次进入系统时会进行触摸校准,根据屏幕的提示点击5个点完成校准即可。<br>
 +
[[File:tslib.png|frameless|1000px|tft-tslib]]<br>
 +
注意:在Linux4.x主线内核中,默认支持的是使用Pin12作为触摸芯片的使能引脚的Matrix-2'8_SPI_Key_TFT-1706版本。<br>
 +
通过npi-config使能Matrix-2'8_SPI_Key_TFT后,系统会将默认的登录显示设备设置为Matrix-2'8_SPI_Key_TFT。如果你想开机运行Qt-demo程序,可以在npi-config中进行如下配置,进入Boot Options菜单:<br>
 +
[[File:tft-qt-demo-1.png|frameless|1000px|tft-qt-demo-1]]<br>
 +
进入Autologin菜单:<br>
 +
[[File:tft-qt-demo-2.png|frameless|1000px|tft-qt-demo-2]]<br>
 +
进去Qt/Embedded菜单:<br>
 +
[[File:tft-qt-demo-3.png|frameless|1000px|tft-qt-demo-3]]<br>
 +
使能Qt/E Demo:<br>
 +
[[File:tft-qt-demo-4.png|frameless|1000px|tft-qt-demo-4]]<br>
 +
最后返回主菜单,选择<Finish>,然后根据提示重启系统。重新启动系统后,屏幕上会自动运行Qt/E demo,效果如下:<br>
 +
[[File:qt-demo-status.png|frameless|600px|qt-demo-status]]<br>
 +
 +
===H3配合Linux-3.4内核 / S5P4418配合Linux-3.4内核===
 +
====在Ubuntu-Core上运行Qt程序====
 +
由于Ubuntu-Core系统带有Qt环境,我们可以在该系统上运行一个简单且带图形界面的Qt程序。<br>
 +
启动开发板并运行Ubuntu-Core系统,进入系统后克隆Matrix代码仓库:
 +
<syntaxhighlight lang="bash">
 +
$ apt-get update && apt-get install git
 +
$ git clone https://github.com/friendlyarm/matrix.git
 +
</syntaxhighlight>
 +
克隆完成后会得到一个名为matrix的目录。
 +
 +
编译并运行Qt测试程序:
 +
<syntaxhighlight lang="bash">
 +
cd matrix/demo/nanopi-status
 +
./build.sh
 +
./run.sh /dev/fb-st7789s
 +
</syntaxhighlight>
 +
nanopi-status是一个简单的Qt程序,可用于显示系统的基本信息,效果如下:<br>
 +
[[File:st7789s-status.png|frameless|600px|st7789s-status]]<br>
 +
脚本run.sh会先加载tft屏的驱动模块然后运行Qt程序,驱动模块加载成功后会生成设备节点/dev/fb-st7789s,下列命令可以确定驱动模块是否成功加载:
 +
<syntaxhighlight lang="bash">
 +
lsmod
 +
Module                  Size  Used by
 +
fbtft_device          29235  0
 +
</syntaxhighlight>
 +
在确定tft驱动模块已加载的前提下,运行下列命令可以显示三原色:
 +
<syntaxhighlight lang="bash">
 +
cd matrix/demo/matrix-lcdtest
 +
make
 +
export LCDSET_FB_DEV=/dev/fb-st7789s
 +
./matrix-lcdtest
 +
</syntaxhighlight>
 +
三原色可以呈现出屏幕的最佳显示效果。
 +
 +
====在2.8寸屏上显示Debian桌面====
 +
对于支持Debian系统的开发板,用户可以通过下列操作将Debian的桌面显示在2.8寸屏上。<br>
 +
 +
启动开发板并运行Debian系统,进入系统后克隆Matrix代码仓库:
 +
<syntaxhighlight lang="bash">
 +
$ apt-get update && apt-get install git
 +
$ git clone https://github.com/friendlyarm/matrix.git
 +
</syntaxhighlight>
 +
克隆完成后会得到一个名为matrix的目录。
 +
 +
对于H3系列的开发板,需要先修改X11的配置文件:
 +
<syntaxhighlight lang="bash">
 +
$ vi /etc/X11/xorg.conf
 +
</syntaxhighlight>
 +
将字样“/dev/fb0”修改为“/dev/fb-st7789s”。
 +
 +
执行下列命令在2.8寸屏上启动Debian桌面:
 +
<syntaxhighlight lang="bash">
 +
$ cd matrix/demo/nanopi-status/
 +
$ ./display-debian.sh /dev/fb-st7789s
 +
</syntaxhighlight>
 +
用触摸笔在屏幕上点击4个点完成校准并进入Debian桌面,效果如下:<br>
 +
[[File:fbtft-debian.png|frameless|600px|fbtft-debian]]
 +
 +
完成触摸校准后终端会有类似如下的打印信息:
 +
<syntaxhighlight lang="bash">
 +
Section "InputClass"
 +
        Identifier      "calibration"
 +
        MatchProduct    "ADS7846 Touchscreen"
 +
        Option  "Calibration"  "196 3825 3887 358"
 +
        Option  "SwapAxes"      "0"
 +
EndSection
 +
</syntaxhighlight>
 +
将上述内容手动保存在/usr/share/X11/xorg.conf.d/99-calibration.conf中,以后就再也无需进行校准了。
 +
 +
<!---
 
===Run Qt Programs on Ubuntu-Core===
 
===Run Qt Programs on Ubuntu-Core===
 
FriendlyElec's Ubuntu-Core supports Qt. Users can run a Qt application by following the steps below.<br>
 
FriendlyElec's Ubuntu-Core supports Qt. Users can run a Qt application by following the steps below.<br>
Line 224: Line 331:
 
</syntaxhighlight>
 
</syntaxhighlight>
 
Copy and paste the information to the "/usr/share/X11/xorg.conf.d/99-calibration.conf" file, save it and this will be used as your calibration data when you reboot your board.
 
Copy and paste the information to the "/usr/share/X11/xorg.conf.d/99-calibration.conf" file, save it and this will be used as your calibration data when you reboot your board.
 +
--->
  
 
==Resources==
 
==Resources==

Revision as of 07:46, 5 July 2017

查看中文

1 Introduction

Matrix-2'8 SPI Key TFT.png
  • The Matrix-2.8_SPI_Key_TFT LCD is a FriendlyARM developed LCD module with resistive touch panel. Its resolution is 240 x 320. It uses the ST7789S IC and XPT2046 resistive touch IC. It has SPI interface and three configurable user keys.
  • Specification
LCD Dimension 2.8"
Display Area 57.6mm*43.2mm
Driver IC ST7789S
Resolution 240 * 320(RGB)
MCU Interface SPI
Power Supply 5V
Backlight Voltage 5V
Touch Resistive Touch, tempered glass touch panel

By default the module's backlight is turned on after the module is powered on. LED_EN can be set to turn off the backlight. If you don’t want the backlight to be turned on after the module is powered on you can take off R12 and in this case you can turn on the backlight by pulling up LED_EN.

2 Features

  • PCB dimension(mm):

Matrix-2'8 SPI Key TFT PCB.png

  • Pin Description:

FriendlyElec has released two versions. Here are the spec:

Matrix-2'8_SPI_Key_TFT-1512
Pin# Description Pin# Description
1 VDD_3.3V 2 VDD_5V
3 NC 4 VDD_5V
5 NC 6 GND
7 LCD_RESET 8 NC
9 GND 10 NC
11 LED_EN 12 NC
13 KEY_1 14 GND
15 KEY_2 16 KEY_3
17 VDD_3.3V 18 T_IRQ
19 SPI_MOSI 20 GND
21 SPI_MISO 22 LCD_D/C
23 SPI_CLK 24 LCD_CS
25 GND 26 T_CS
Matrix-2'8_SPI_Key_TFT-1706
Pin# Description Pin# Description
1 VDD_3.3V 2 VDD_5V
3 NC 4 VDD_5V
5 NC 6 GND
7 LCD_RESET 8 NC
9 GND 10 NC
11 LED_EN 12 T_CS
13 KEY_1 14 GND
15 KEY_2 16 KEY_3
17 VDD_3.3V 18 T_IRQ
19 SPI_MOSI 20 GND
21 SPI_MISO 22 LCD_D/C
23 SPI_CLK 24 LCD_CS
25 GND 26 NC

The Matrix-2'8_SPI_Key_TFT-1706 exposes T_CS from Pin26 to Pin12. And NEO/NEO2/NEO-Plus2 all of which have a 24Pin connector will be able to work with its touch.

3 Applicable Boards & OS

Index SoC Model Board Model OS
1 H3 NanoPi NEO/NEO Air/M1/M1 Plus Allwinner's released Linux-3.4 kernel and Mainline Linux-4.x kernel
2 H5 NanoPi NEO2/NEO Plus2 Mainline Linux-4.x kernel
3 S5P4418 NanoPi2/NanoPi M2/NanoPi2 Fire Samsung's released Linux-3.4 kernel

4 Applications

4.1 H3 Based Boards

Connect to NanoPi M1:
Refer to the following hardware setup to connect the module to the NanoPi M1:
Matrix-2'8_SPI_Key_TFT_nanopi_m1

Connect to NanoPi M1 Plus:
Refer to the following hardware setup to connect the module to the NanoPi M1 Plus:
Matrix-2'8_SPI_Key_TFT_nanopi_m1_plus

Connect to NanoPi NEO:
Refer to the following hardware setup to connect the module to the NanoPi NEO:
Matrix-2'8_SPI_Key_TFT_nanopi_neo

Connect to NanoPi NEO Air:
Refer to the following hardware setup to connect the module to the NanoPi NEO Air:
Matrix-2'8_SPI_Key_TFT_nanopi_neo_air

4.2 H5 Based Boards

Connect to NanoPi NEO2:
Matrix-2'8_SPI_Key_TFT_nanopi_neo2

Connect to NanoPi NEOPlus2:
Matrix-2'8_SPI_Key_TFT_nanopi_neo_plus2

4.3 S5P4418 Based Boards

Connect to NanoPi 2:
Refer to the following hardware setup to connect the module to the NanoPi 2:
Matrix-2'8_SPI_Key_TFT_nanopi2

Connect to NanoPi M2 / NanoPi 2 Fire:
Refer to the following hardware setup to connect the module to the NanoPi M2 / NanoPi 2 Fire:
Matrix-2'8_SPI_Key_TFT_nanopi_m2

5 Compile & Run Test Program

5.1 H3/H5配合Linux-4.x主线内核

当使用的开发板为H3或者H5系列时,假设使用的ROM是基于Linux-4.x主线内核的Ubuntu-Core with Qt-Embedded系统,那么首先需要通过npi-config工具来使能Matrix-2'8_SPI_Key_TFT。启动系统,在root用户下执行下列命令运行npi-config:

$ npi-config

然后依次进入下列菜单项:
tft-1
进入SPI菜单:
tft-2
选择是否使能SPI0:
tft-3
选择enable SPI0后,再选择SPI0上连接的设备为Matrix-2'8_SPI_Key_TFT:
tft-4
最后返回主菜单,选择<Finish>,然后根据提示重启系统。重新启动系统后,执行下列命令检查Matrix-2'8_SPI_Key_TFT的显示芯片和触摸芯片是否被使能:

$ ls /dev/fb-st7789s 
/dev/fb-st7789s

/dev/fb-st7789s就是显示芯片的framebuffer设备节点。

$ ls /dev/input/ts-ads7846 
/dev/input/ts-ads7846

/dev/input/ts-ads7846就是触摸芯片的设备节点。 第一次进入系统时会进行触摸校准,根据屏幕的提示点击5个点完成校准即可。
tft-tslib
注意:在Linux4.x主线内核中,默认支持的是使用Pin12作为触摸芯片的使能引脚的Matrix-2'8_SPI_Key_TFT-1706版本。
通过npi-config使能Matrix-2'8_SPI_Key_TFT后,系统会将默认的登录显示设备设置为Matrix-2'8_SPI_Key_TFT。如果你想开机运行Qt-demo程序,可以在npi-config中进行如下配置,进入Boot Options菜单:
tft-qt-demo-1
进入Autologin菜单:
tft-qt-demo-2
进去Qt/Embedded菜单:
tft-qt-demo-3
使能Qt/E Demo:
tft-qt-demo-4
最后返回主菜单,选择<Finish>,然后根据提示重启系统。重新启动系统后,屏幕上会自动运行Qt/E demo,效果如下:
qt-demo-status

5.2 H3配合Linux-3.4内核 / S5P4418配合Linux-3.4内核

5.2.1 在Ubuntu-Core上运行Qt程序

由于Ubuntu-Core系统带有Qt环境,我们可以在该系统上运行一个简单且带图形界面的Qt程序。
启动开发板并运行Ubuntu-Core系统,进入系统后克隆Matrix代码仓库:

$ apt-get update && apt-get install git
$ git clone https://github.com/friendlyarm/matrix.git

克隆完成后会得到一个名为matrix的目录。

编译并运行Qt测试程序:

cd matrix/demo/nanopi-status
./build.sh
./run.sh /dev/fb-st7789s

nanopi-status是一个简单的Qt程序,可用于显示系统的基本信息,效果如下:
st7789s-status
脚本run.sh会先加载tft屏的驱动模块然后运行Qt程序,驱动模块加载成功后会生成设备节点/dev/fb-st7789s,下列命令可以确定驱动模块是否成功加载:

lsmod
Module                  Size  Used by
fbtft_device           29235  0

在确定tft驱动模块已加载的前提下,运行下列命令可以显示三原色:

cd matrix/demo/matrix-lcdtest
make
export LCDSET_FB_DEV=/dev/fb-st7789s
./matrix-lcdtest

三原色可以呈现出屏幕的最佳显示效果。

5.2.2 在2.8寸屏上显示Debian桌面

对于支持Debian系统的开发板,用户可以通过下列操作将Debian的桌面显示在2.8寸屏上。

启动开发板并运行Debian系统,进入系统后克隆Matrix代码仓库:

$ apt-get update && apt-get install git
$ git clone https://github.com/friendlyarm/matrix.git

克隆完成后会得到一个名为matrix的目录。

对于H3系列的开发板,需要先修改X11的配置文件:

$ vi /etc/X11/xorg.conf

将字样“/dev/fb0”修改为“/dev/fb-st7789s”。

执行下列命令在2.8寸屏上启动Debian桌面:

$ cd matrix/demo/nanopi-status/
$ ./display-debian.sh /dev/fb-st7789s

用触摸笔在屏幕上点击4个点完成校准并进入Debian桌面,效果如下:
fbtft-debian

完成触摸校准后终端会有类似如下的打印信息:

Section "InputClass" 
        Identifier      "calibration" 
        MatchProduct    "ADS7846 Touchscreen" 
        Option  "Calibration"   "196 3825 3887 358" 
        Option  "SwapAxes"      "0" 
EndSection

将上述内容手动保存在/usr/share/X11/xorg.conf.d/99-calibration.conf中,以后就再也无需进行校准了。


6 Resources

7 Update Log

7.1 Feb-24-2016

  • Added the driver's source code location in Section 5.2

7.2 June-17-2016

  • Re-organized and simplified wiki

7.3 March-5-2017

  • Added sections 3.2, 3.3, 3.4 and 4.1