/Raspberry-ili9340spi

ILI9340 SPI TFT Library & XPT2046 Touch Screen Library for Raspberry

Primary LanguageC

Raspberry-ili9340spi

ILI9340 SPI TFT Library for Raspberry Pi/Orange Pi

You can show a chart to ILI9340/ILI9341/ILI9163C/ST7735 SPI TFT.
You can choose bmc2835 library/WiringPi(WiringOp) library.

I tested these TFT.
1.44 inch 128x128 ST7735
1.44 inch 128x128 ILI9163C
1.8 inch 128x160 ST7735
2.2 inch 240x320 ILI9340
2.4 inch 240x320 ILI9341
2.4 inch 240x320 ILI9341


Wirering

TFT Rpi/Opi
VCC -- 3.3V
GND -- GND
CS -- Pin#24(SPI CE0)
RES -- Pin#5(*)
D/C -- Pin#3(*)
MOSI -- Pin#19(SPI MOSI)
SCK -- Pin#23(SPI SCLK)
LED -- 3.3V
MISO -- N/C

(*) You can change any pin.

Note:
Opi have only 1 SPI.
OPi-PC have CE0 and GPIO8.
OPi ZERO have CE1 and GPIO8.


Build using bcm2835 library

RPi Only, Very fast

wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.56.tar.gz
tar zxvf bcm2835-1.56.tar.gz
cd bcm2835-1.56
./configure
make
sudo make check
sudo make install

* This tool require 1.56 or later.
* Because this tool uses bcm2835_spi_write.

cd $HOME   
git clone https://github.com/nopnop2002/Raspberry-ili9340spi
cd Raspberry-ili9340spi
cc -o demo demo.c fontx.c ili9340.c -lbcm2835 -lm -DBCM

Build using WiringPi/WiringOp library

Both of RPi/OPi, But slow

git clone https://github.com/nopnop2002/Raspberry-ili9340spi
cd Raspberry-ili9340spi
cc -o demo demo.c fontx.c ili9340.c -lwiringPi -lm -DWPI

TFT resolution and GRAM offset

TFT resolution is set to tft.conf.

If your TFT doesn't use a memory from 0th address in GRAM, It use GRAM offset which set to tft.conf.


ili9340-11 ili9340-12 ili9340-13 ili9340-14 ili9340-15 ili9340-16 ili9340-17 ili9340-18 ili9340-19 ili9340-20 ili9340-21


This library can use ILI9341 TFT.

From left 2.8" ILI9341,2.4" ILI9341, 2.2" ILI9340.

ili9341-a

ili9341-b

ili9341-c


This library can use ILI9163C/ST7735 TFT.

From left to right.
2.2 inch 240x320 ILI9340
1.44 inch 128x128 ST7735
1.44 inch 128x128 ILI9163C
1.8 inch 128x160 ST7735

ili9163-1


A library of XPT2046 Touch Screen is included in this library

Wirering

TFT Rpi
T_IRQ -- Pin#22(*)
T_OUT -- Pin#21(SPI MISO)
T_DIN -- Pin#19(SPI MOSI)
T_CS -- Pin#26(SPI CE1)
T_CLK -- Pin#23(SPI SCLK)
MISO -- N/C
LED -- 3.3V
SCK -- Pin#23(SPI SCLK)
MOSI -- Pin#19(SPI MOSI)
D/C -- Pin#3(*)
RES -- Pin#5(*)
CS -- Pin#24(SPI CE0)
GND -- GND
VCC -- 3.3V

(*) You can change any pin.


cc -o xpt xpt.c xpt2046.c -lbcm2835

If you touch screen, point will show.

touch-11


cc -o touch touch.c fontx.c ili9340.c xpt2046.c -lbcm2835 -lm -DBCM

If you touch area, number will show.

touch-12