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

From FriendlyELEC WiKi
Jump to: navigation, search
(Applications)
(Compile & Run Test Program)
Line 114: Line 114:
  
 
==Compile & Run Test Program==
 
==Compile & Run Test Program==
Boot your ARM board with Debian and copy the matrix code:
+
===Run Qt Programs on Ubuntu-Core===
 +
FriendlyElec's Ubuntu-Core supports Qt. Users can run a Qt application by following the steps below.<br>
 +
Boot Ubuntu-Core on a board and clone the Matrix code samples:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ apt-get update && apt-get install git
 
$ apt-get update && apt-get install git
 
$ git clone https://github.com/friendlyarm/matrix.git
 
$ git clone https://github.com/friendlyarm/matrix.git
 
</syntaxhighlight>
 
</syntaxhighlight>
If your cloning is done successfully a "matrix" directory will be generated.
+
After it is done a "matrix" directory will be generated.
  
Compile and install Matrix:
+
Compile and Run Qt Test Program:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
cd matrix/demo/nanopi-status
 
cd matrix/demo/nanopi-status
Line 127: Line 129:
 
./run.sh /dev/fb-st7789s
 
./run.sh /dev/fb-st7789s
 
</syntaxhighlight>
 
</syntaxhighlight>
The nanopi-status is a small Qt utility which can be used to list system's basic information. Here is what you should expect to observe:<br>
+
The nanopi-status is a simple Qt program which shows system information. Here is what you expect to observe:<br>
 
[[File:st7789s-status.png|frameless|600px|st7789s-status]]
 
[[File:st7789s-status.png|frameless|600px|st7789s-status]]
  
<!---
 
Please login the matrix hub and enter the nanopi2 branch
 
<syntaxhighlight lang="bash">
 
$ cd matrix
 
$ git checkout nanopi2
 
</syntaxhighlight>
 
  
Compile the Matrix code
 
<syntaxhighlight lang="bash">
 
$ make CROSS_COMPILE=arm-linux- clean
 
$ make CROSS_COMPILE=arm-linux-
 
$ make CROSS_COMPILE=arm-linux- install
 
</syntaxhighlight>
 
Note: please make sure to install the cross compiler "arm-linux-gcc-4.9.3" on your PC, which is used to compile files for the NanoPi 2.<br>
 
Generated library files are under the "install/lib" directory. The test program is under the "install/usr/bin" directory.<br>
 
The modules are under the "modules" directory. The driver's source code is in github: https://github.com/friendlyarm/linux-3.4.y.git <br>
 
  
===Load Driver===
 
Please insert a TF card which is flashed with Debian to a Linux host and mount its boot and rootfs sections.<br>
 
We assume the rootfs is mounted to /media/rootfs then please run the following commands to copy the driver, library and test program to the card.<br>
 
<syntaxhighlight lang="bash">
 
$ cp modules /media/rootfs/ -r
 
$ cp install/lib/* /media/rootfs/lib/ -d
 
$ cp install/usr/bin/* /media/rootfs/usr/bin/
 
</syntaxhighlight>
 
  
Insert this TF card to your NanoPi 2, power on and run the following commands to load the driver.<br>
 
<syntaxhighlight lang="bash">
 
$ cd /modules
 
$ insmod fbtft_device.ko name=matrix-st7789s gpios=dc:97,reset:60,cs:94
 
$ insmod matrix_ads7846.ko
 
</syntaxhighlight>
 
"fbtft_device" is the LCD's driver. "matrix_ads7846" is the touch driver. If they are successfully loaded the LCD will be cleared and reset.<br>
 
  
===Test LCD Display===
+
Boot your ARM board with Debian and copy the matrix code:
Please run the following commands to set the display device to the Matrix-2'8_SPI_Key_TFT:
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ sudo FRAMEBUFFER=/dev/fb-st7789s startx &
+
$ apt-get update && apt-get install git
 +
$ git clone https://github.com/friendlyarm/matrix.git
 
</syntaxhighlight>
 
</syntaxhighlight>
"&" schedules the program to run background and you will see the following messages:<br>
+
If your cloning is done successfully a "matrix" directory will be generated.
<syntaxhighlight lang="bash">
+
Log file: "/var/log/Xorg.2.log"
+
</syntaxhighlight>
+
Here the message shows that the X window's DISPLAY value is 2<br>
+
  
===Calibrate Touch===
+
Compile and install Matrix:
Please run the following commands to calibrate touch:
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ DISPLAY=:2.0 xinput_calibrator
+
cd matrix/demo/nanopi-status
 +
./build.sh
 +
./run.sh /dev/fb-st7789s
 
</syntaxhighlight>
 
</syntaxhighlight>
After you click on the four points highlighted on the LCD you will get calibration done and observe the following messages:
+
The nanopi-status is a small Qt utility which can be used to list system's basic information. Here is what you should expect to observe:<br>
<syntaxhighlight lang="bash">
+
[[File:st7789s-status.png|frameless|600px|st7789s-status]]
Section "InputClass"
+
        Identifier      "calibration"
+
        MatchProduct    "ADS7846 Touchscreen"
+
        Option  "Calibration"  "196 3825 3887 358"
+
        Option  "SwapAxes"      "0"
+
EndSection
+
</syntaxhighlight>
+
Save these calibration data to the "/usr/share/X11/xorg.conf.d/99-calibration.conf" file and reboot the system your touch will be ready to go.
+
--->
+
 
+
<!---
+
==Connect to NanoPi==
+
===Preparations===
+
Please install a Debian on a NanoPi and an appropriate cross compiler on a PC. Please refer to wiki:[[NanoPi/zh|NanoPi]] <br>
+
Compile a NanoPi kernel. Note: please use the kernel's source code from the nanopi-v4.1.y-matrix branch. <br>
+
<syntaxhighlight lang="bash">
+
$ git clone https://github.com/friendlyarm/linux-4.x.y.git
+
$ cd linux-4.x.y
+
$ git checkout nanopi-v4.1.y-matrix
+
$ make nanopi_defconfig
+
$ touch .scmversion
+
$ make
+
</syntaxhighlight>
+
 
+
===Hardware Connection===
+
Please refer to the following connection diagram to connect the Matrix-2'8 SPI_TFT to the NanoPi <br>
+
[[File:Matrix-2'8 SPI_TFT_nanopi.jpg|frameless|600px|Matrix-2'8 SPI_TFT_nanopi]]
+
 
+
Connection Details:
+
{| class="wikitable"
+
|-
+
|Matrix-2'8 SPI_TFT || NanoPi
+
|-
+
|  ||
+
|-
+
|}
+
 
+
===Load Driver===
+
Power on the NanoPi and run the following command in Debian's terminal to load drivers:
+
<syntaxhighlight lang="bash">
+
$ modprobe fbtft_device name=matrix-spi_tft gpios=dc:161,reset:162,cs:163
+
$ modprobe matrix_ads7846
+
</syntaxhighlight>
+
The "fbtft_device" module is the driver for the st7789s chip and the "matrix_ads7846" module is the driver for the xpt2046 chip.
+
 
+
===Install Package===
+
Please run the following commands in Debian's terminal to install "qtembedded" and "matrix-tslib"
+
<syntaxhighlight lang="bash">
+
$ apt-get update
+
$ apt-get install qtembedded
+
$ apt-get install matrix-tslib
+
</syntaxhighlight>
+
The "qtembedded" library is what qt applications rely on and the "matrix-tslib" library is what screen calibration relies on.
+
 
+
===Run Test Program===
+
Start Qt applications
+
<syntaxhighlight lang="bash">
+
$ . /usr/bin/matrix-setqt4env
+
$ /usr/local/Trolltech/QtEmbedded-4.8.5-arm/examples/tetrix -qws
+
</syntaxhighlight>
+
The matrix-setqt4env script sets the environmental variables which Qt and tslib rely on. If it is run on a platform for the first time a screen calibration GUI will be launched. Users need to go through a five-point calibration process to calibrate the screen.
+
The tetrix application is a game developed in Qt4.
+
 
+
==Connect to Tiny4412==
+
 
+
==Connect to RaspberryPi==
+
 
+
==Connect to Arduino==
+
--->
+
  
 
==Display Debian GUI on 2.8"LCD==
 
==Display Debian GUI on 2.8"LCD==

Revision as of 16:35, 4 March 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 320 x 240. 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 320 * 240(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:
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


3 Applications

3.1 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

3.2 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

3.3 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

3.4 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

3.5 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

3.6 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

4 Compile & Run Test Program

4.1 Run Qt Programs on Ubuntu-Core

FriendlyElec's Ubuntu-Core supports Qt. Users can run a Qt application by following the steps below.
Boot Ubuntu-Core on a board and clone the Matrix code samples:

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

After it is done a "matrix" directory will be generated.

Compile and Run Qt Test Program:

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

The nanopi-status is a simple Qt program which shows system information. Here is what you expect to observe:
st7789s-status



Boot your ARM board with Debian and copy the matrix code:

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

If your cloning is done successfully a "matrix" directory will be generated.

Compile and install Matrix:

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

The nanopi-status is a small Qt utility which can be used to list system's basic information. Here is what you should expect to observe:
st7789s-status

5 Display Debian GUI on 2.8"LCD

Boot your ARM board with Debian and and launch the Debian GUI by running the following commands:

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

Calibrate the screen by following the four points' movement:
fbtft-debian

After calibration is done you will see the following system information:

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

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.

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