Embedded Display TFT Ilitek ILI9341
This embedded TFT display is based on the Ilitek ILI9341 chipset and is compatible with the SPI
serial interface. This TFT display has a resolution of 240x320 pixels and 262K colors. A special feature of this screen is that it is also sold with a Touch
Screen controller based on the XPTEK XPT2046 chipset. This allows, with proper libraries, to manage the display via touch commands. For ease we are going to connect it to the FTDI FT232H device, of which there is a dedicated page on this site - refer to the above page for installation.
Connection via SPI
This display must be connected to the FTDI FT232H development board via SPI protocol.
The connection connectors are listed below:
The following Python library allows to manage 3 auxiliary pins, "Reset", "Touch IRQ" and "Screen
Backlight". Since there are only 2 pins available (AD6 to AD7), the backlight ("LED" pin) is connected to the "+3.3V" of the
FTDI FT232H development board. Actually it is possible to control the backlight via software by inverting the connections between the "RESET" pin and the
"LED" pin, that is by connecting the "RESET" pin of the screen to the "+3.3V" of the development board and connecting the "LED" pin
of the screen to pin "AD6" of the development board. This is because the display works only when its "RESET" pin is in "High" mode (ie with the
presence of power), therefore the "RESET" pin of the screen must be connected either to the "+3.3V" pin or to a pin available on the development
The use of the "T_IRQ" pin is optional in the following Python library, as it is only used to specify a "handler" method for retrieving "touch"
information. Normally the Python library does not require to specify this pin, as the touch reading can always be done in real time (see the examples
included with the Python library).
To manage this display, we can use the Python library named
"ILI9341 FTDI". This library only requires the presence of the
"PyFTDI" library and was built from the following Python
libraries on Internet:
- For the display
- For the touch
This library has the following features:
- During the initialization of the "ILI9341" class, the "dc" parameter (related to the "D/C" pin of the display) is
mandatory, since it is used by the library to send data or commands to the display.
- During the initialization of the "ILI9341" class, the "rst" parameter (related to the "RESET" pin of the display) is optional,
since this pin can be connected directly to the "+3.3V" pin of the development board (see previous paragraph).
- During the initialization of the "ILI9341" class, the "rotation" parameter is optional, since the default value is "0" (the screen
is set in native mode, ie in "portrait" or vertical mode). The library supports "0", "90", "180" and "270" values for both
screen and touch.
- During the initialization of the "ILI9341" class, the "int_pin" and "int_handler" parameters are optional, as the default
value for both is "None". If the "T_IRQ" pin is passed with the "int_pin" parameter and a "handler" method is passed with the "int_handler"
parameter, the library will use a separate "thread" to retrieve the "touch" information.
- During the initialization of the "ILI9341" class, the "usepillow" parameter is optional, as the default value is "True". This means
that the library will use the PIL library (or its "Pillow" fork) by default. If we want to use the built-in commands instead, derived from the
"MicroPython" code, then we will need to set this parameter to "False". However it should be noted that the integrated management of the
screen rotation (see the above-mentioned "rotation" parameter) only works if this parameter is set to "True" (if it is "False", it will
be the user's responsibility to manage both display rotation and touch rotation).
- During the initialization of the "ILI9341" class, the "backlight" parameter is optional, as the default value is "None". If with
this parameter is specified a pin of the development board that supplies the backlight power to the screen (pin "LED"), then the management of the
backlight will be managed by the user via software through the "enable_backlight" method.
- The compressed file provides examples for both the screen and the touch.
- All files whose name begins with "demo" are files written with "MicroPython" code and do not require the PIL library (or
its "Pillow" fork). These example files write directly to the screen without using a video buffer, this significantly slows down the
on-screen drawing of complex shapes.
- All files whose names begin with "test" are files that require the PIL library (or its "Pillow" fork). These example files
write to the screen using a video buffer, which makes drawing complex shapes on the screen quite fast.