RepositoryCJPJapan
nopnop2002

nopnop2002/esp-idf-parallel-tft

8bit parallel TFT & 4-line resistance touch screen Driver for esp-idf using i2s paralell mode

135stars
33forks
4issues
1views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: spfd5408

#1 Repository of the month

1
TINIX TRENDING·Topic: ili9325

#1 Repository of the month

1
TINIX TRENDING·Topic: ili9327

#1 Repository of the month

esp-idf-parallel-tft

8 bit parallel TFT & 4-line resistance touch screen Driver for esp-idf.
You can use such a TFT-Shield with esp32.

TFT-Shield

Support driver

Generic Shield

  • ILI9225
  • ILI9226(Same as ILI9225)
  • ILI9320
  • ILI9325
  • ILI9341
  • ILI9342
  • ILI9481
  • ILI9486
  • ILI9488
  • SPFD5408(Same as ILI9320)
  • R61505U(Same as ILI9320)
  • R61509V
  • LGDP4532
  • ST7775(Same as ILI9225)
  • ST7781
  • ST7783(Same as ST7781)
  • ST7793(Same as R61509)
  • ST7796(Same as ILI9486)
  • HX8347A(*2)
  • HX8347D(Almost the same as HX8347A)(*2)
  • HX8347G(Same as HX8347D)(*2)
  • HX8347I(Same as HX8347D)(*2)

OPEN-SMART Products

  • OPEN-SMART ILI9225 TFT-Shield(176x220)(*5)
  • OPEN-SMART ILI9327 TFT-Shield(240x400)(*3)(*5)
  • OPEN-SMART ILI9340 TFT-Shield(240x320)(*5)
  • OPEN-SMART S6D1121 16Pin-Parallel(240x320)(*1)(*5)
  • OPEN-SMART ST7775 16Pin-Parallel(176x220 Same as ILI9225)(*1)(*5)
  • OPEN-SMART ST7783 16Pin-Parallel(240x320)(*1)(*5)
  • OPEN-SMART R61509V 16Pin-Parallel(240x400)(*1)(*5)
  • OPEN-SMART ILI9488 16Pin-Parallel(320x480 Color inversion)(*1)(*4)(*5)

(*1)
I2S parallel does not work.
I don't know why.
GPIO parallel or REGISTER I/O parallel works.
LED pins connect to GND instead of 3.3V.

(*2)
Very Slow.
Most drivers require three commands to display one Pixel.
This driver require 9 commands to display one Pixel.
For some reason, the color of 0xFFFF does not appear.

(*3)
It has a GRAM offset.
See below.

(*4)
Need RGB inverstion.

(*5)
4-line resistance touch screen available.
See below.

These are all 2.4 inch, 320x240 TFTs. TFT-SHIELD-2

3.95 inches is almost twice as large as 2.4 inches. TFT-SHIELD-3

These are OPEN-SMART 16Pin-Parallel Products. OPEN-SMART-16Pin

These are OPEN-SMART TFT-Shield Products. OPEN-SMART-Shield

Software requirements

ESP-IDF V5.0 or later.
ESP-IDF V4.4 release branch reached EOL in July 2024.

Note for ESP-IDF V5.x
I2S parallel interface gives this warning, but work.

#warning "legacy adc driver is deprecated, please migrate to use esp_adc/adc_oneshot.h and esp_adc/adc_continuous.h for oneshot mode and continuous mode drivers respectively"

Note for ESP-IDF V6.x
I2S parallel interface is not supported.

Installation

git clone https://github.com/nopnop2002/esp-idf-parallel-tft
cd esp-idf-parallel-tft/
idf.py set-target {esp32/esp32s2/esp32s3}
idf.py menuconfig
idf.py flash

Note for ESP32-S2
The tjpgd library is not present in ESP32-S2 ROM.
With ESP-IDF Ver5, the JPEG decode library is now provided from the IDF Component Registry, and the JPEG decode library is now available for ESP32-S2.
However, since the SRAM is small, a large image cannot be displayed.
You may encounter memory allocation errors when displaying PNG files.
You can avoid this error by enabling PSRAM.

Configuration

You have to set this config value with menuconfig.

  • CONFIG_DRIVER

    The information provided by sellers on Ebay or AliExpress is largely incorrect.
    You waste time if you don't choose the right driver.
    There are many variations of the 2.4 inch shield.
    You can use this to find out your driver.
    This is for Arduino UNO.
    Do not use this on the ESP32 as the GPIO on the ESP32 is not 5V tolerant.
    Never believe the seller's information.
    I'll say it again.
    Never believe the seller's information.
  • CONFIG_INTERFACE
    Most drivers work using I2S parallel.
    However, some drivers only work using GPIO parallels or REGISTER I/O parallels.
    I2S parallel is the fastest when drawing to consecutive addresses.
    However, REGISTER I/O parallel is the fastest when drawing to non-contiguous addresses.
    When using REGISTER I/O parallel, GPIO from D0 to D7 is 1 to 31.(GPIO0 is boot mode pin)
    I2S parallel is suitable for image-intensive applications.
    REGISTER I/O parallel is suitable for character-intensive applications.
    GPIO parallel is most slow.
  • CONFIG_WIDTH
  • CONFIG_HEIGHT
    Specifies the resolution of the TFT.
  • CONFIG_OFFSETX
  • CONFIG_OFFSETY
    You can specify the GRAM offset.
    You must specify Y offset = 32 for OPEN-SMART-ILI9327.
  • CONFIG_INVERSION
    For some TFTs, the BGR may be inverted.
    Specify if the colors are inverted.

config-menu

config-app1

config-app2

config-app4

Wiring

TFTESP32ESP32S2/S3
LDC_RST--GPIO32GPIO14*1
LDC_CS--GPIO33GPIO13*1
LDC_RS--GPIO15GPIO12*1
LDC_WR--GPIO4GPIO11*1
LDC_RD--GPIO2GPIO10*1
LDC_D0--GPIO12GPIO33*1 *2
LDC_D1--GPIO13GPIO34*1 *2
LDC_D2--GPIO26GPIO35*1 *2
LDC_D3--GPIO25GPIO36*1 *2
LDC_D4--GPIO17GPIO37*1 *2
LDC_D5--GPIO16GPIO38*1 *2
LDC_D6--GPIO27GPIO39*1 *2
LDC_D7--GPIO14GPIO40*1 *2
5V--5V5V*3
3.3V--3.3V3.3V*3
GND--GNDGND

(*1)
You can change any GPIO using menuconfig.

config-app3

(*2)
When using REGISTER I/O parallel, GPIO from D0 to D7 is 1 to 31.(GPIO0 is boot mode pin)

(*3)
With a regulator (mostly AMS1117) is on the back, the supply voltage is 5V.
With a regulator is NOT on the back, the supply voltage is 3.3V.

Back

Note
My R61509V has a regulator on the back.
Normally, a TFT with a regulator works at 5V, but my R61509V doesn't work unless I supply both 5V and 3.3V.

Note
ESP32 development board cannot supply too much current.
It is more stable when supplied from an external power source.
I used a USB-TTL conversion module as an external power source.

ExternalPower

Graphic support

Graphic1 Graphic2 Graphic3 Graphic4 Graphic5 Graphic6 Graphic7 Graphic8

Fonts support

Font1 It's possible to text rotation and invert.
Font2 Font3 Font4 You can specify multiple fonts at the same time.
Font5

Image support

BMP file
Image1 JPEG file
Image2 PNG file
Image3

Using Wemos D1 ESP32

I bought this for $4.
WeMos-R32-11

To attach the TFT-Shield, you need to do changed some pin assignments like this.
Because GPIO34/35/36/39 are READ ONLY.
WeMos-R32-1

WeMos-R32-12

With this change, GPIO will look like this:
WeMos-R32-2

WeMos-R32-3

WeMos-R32-4

It's great because it doesn't require any wiring.
WeMos-R32-13

If you use OPEN-SMART TFT-Shield Products, you must use custom GPIO.
WeMos-R32-OpenSmart

Using TZT D1 ESP32-S3

I bought this for $5.
tzt-d1-esp32s3

You can attach the TFT-Shield without changing anything.
But I2S parallel doesn't work. I don't know why.
tzt-d1-esp32s3-Generic tzt-d1-esp32s3-Open-Smart

If you use TZT D1 ESP32-S3, you must use custom GPIO.
config-esp32s3-generic

JPEG Decoder

The ESP-IDF component includes Tiny JPEG Decompressor.
The document of Tiny JPEG Decompressor is here.
This can reduce the image to 1/2 1/4 1/8.

The jd_prepare() function included in Tiny JPEG Decompressor requires a work area.
The work area is allocated dynamically.
By enabling PSRAM, a larger work area can be allocated.
PSRAM can be enabled using menuconfig.

  • Work area when PSRAM is disabled
W (1886879) decode_jpeg: v5 version. JPEG Decoder is external tjpgd
I (1886889) decode_jpeg: esp_get_free_heap_size=99752
I (1886889) decode_jpeg: MALLOC_CAP_EXEC=0
I (1886889) decode_jpeg: MALLOC_CAP_32BIT=90112
I (1886889) decode_jpeg: jd_work_size=90112
  • Work area when PSRAM is enabled
W (92219) decode_jpeg: v5 version. JPEG Decoder is external tjpgd
I (92229) decode_jpeg: esp_get_free_heap_size=2161660
I (92229) decode_jpeg: MALLOC_CAP_EXEC=0
I (92229) decode_jpeg: MALLOC_CAP_32BIT=2064384
I (92229) decode_jpeg: jd_work_size=2064384

PNG Decoder

The ESP-IDF component includes part of the miniz library, such as mz_crc32.
But it doesn't support all of the miniz.
The document of miniz library is here.

And I ported the pngle library from here.
This can reduce the image to any size.

Font File

This project uses the following as default fonts:

  • font/ILGH16XB.FNT // 8x16Dot Gothic
  • font/ILGH24XB.FNT // 12x24Dot Gothic
  • font/ILGH32XB.FNT // 16x32Dot Gothic
  • font/ILMH16XB.FNT // 8x16Dot Mincyo
  • font/ILMH24XB.FNT // 12x24Dot Mincyo
  • font/ILMH32XB.FNT // 16x32Dot Mincyo

From 0x00 to 0x7f, the characters image of Alphanumeric are stored.
From 0x80 to 0xff, the characters image of Japanese are stored.
Changing this file will change the font.

You can add your original fonts.
The format of the font file is the FONTX format.
Your font file is put in font directory.
Your font file is uploaded to SPIFFS partition using meke flash.

Please refer this page about FONTX format.

Font File Editor(FONTX Editor)

There is a font file editor.
This can be done on Windows 10.
Developer page is here.

fontx-editor-1

Convert from BDF font to FONTX font

step1)
download fontxedit.exe.

step2)
download BDF font file from Internet.
I downloaded from here.
fontxedit.exe can ONLY import Monospaced bitmap fonts file.
Monospaced bitmap fonts can also be downloaded here.

step3)
import the BDF font file into your fontxedit.exe.
this tool can convert from BDF to FONTX.
fontx-editor-2

step4)
adjust font size.
fontx-editor-3

step5)
check font pattern.
when you have made any changes, press the apply button.
fontx-editor-4

step6)
save as .fnt file from your fontedit.exe.
fontx-editor-5

step7)
upload your font file to $HOME/esp-idf-ili9340/font directory.

step8)
add font to use

FontxFile fx32L[2];
InitFontx(fx32L,"/spiffs/LATIN32B.FNT",""); // 16x32Dot LATIN

Font file that From 0x00 to 0x7f, the characters image of Standard ASCII are stored.
AsciiCode-1

Font file that From 0x80 to 0xff, the characters image of Japanese are stored.
AsciiCode-2

Font file that From 0x80 to 0xff, the characters image of Latin are stored.
AsciiCode-3

u8g2 library contains many BDF fonts.
This was converted from emoticons21.bdf.
bdf-font-1

This was converted from Scroll-o-Sprites.bdf.
bdf-font-2

Convert from TTF font to FONTX font

step1)
Download WFONTX64.exe from here. Developer page is here.

step2)
Select ttf font.
WFONTX64-1

step3)
Enter Height, Width, FontX2 name.
Specify half of Height for Width.
Specify your favorite font name in the FontX2 name field using up to 8 characters.
WFONTX64-2

step4)
Specify the file name to save.
WFONTX64-3

step5)
Specify the font style as required.
WFONTX64-4

step6)
Press the RUN button to convert TTF fonts to FONTX format.
WFONTX64-5

step7)
upload your font file to $HOME/esp-idf-ili9340/font directory.

step8)
add font to use

    FontxFile fx16G[2];
    FontxFile fx24G[2];
    FontxFile fx32G[2];
    //InitFontx(fx16G,"/spiffs/ILGH16XB.FNT",""); // 8x16Dot Gothic
    //InitFontx(fx24G,"/spiffs/ILGH24XB.FNT",""); // 12x24Dot Gothic
    //InitFontx(fx32G,"/spiffs/ILGH32XB.FNT",""); // 16x32Dot Gothic
    InitFontx(fx16G,"/spiffs/Gigi16.FNT",""); // 8x16Dot Gigi
    InitFontx(fx24G,"/spiffs/Gigi24.FNT",""); // 12x24Dot Gigi
    InitFontx(fx32G,"/spiffs/Gigi32.FNT",""); // 16x32Dot Gigi

tft_font


4-line resistance touch screen

Some TFT has 4-line resistance touch screen.
The 4-line resistor touch screen uses 4 pins.

  • X(+):Digital Output
  • X(-):Digital Output/Analog Input
  • Y(+):Digital Output/Analog Input
  • Y(-):Digital Output

When using GPIO Parallel Interface or REGISTER Parallel Interface, you can enable 4-line resistance touch screen using menuconfig.

ESP-IDF cannot do both digital output and analog input simultaneously using a single gpio.
Hence two GPIOs are required for simultaneous digital output and analog input.
(X-) and ESP32 are connected with two wires.
(Y+) and ESP32 are connected with two wires.

(X-) ----+---- Gpio for Digital Output(Using GPIO number)
         +---- Gpio for Analog Input(Using ADC1 Channel number)

(Y+) ----+---- Gpio for Digital Output(Using GPIO number)
         +---- Gpio for Analog Input(Using ADC1 Channel number)

Configuration for touch screen

Image

ADC Channel

When reading analog values, ESP-IDF can use ADC1 and ADC2.
This project only supports ADC1 for reading analog values.
ESP32 has 8 channels.
ESP32S2/S3 has 10 channels.

ChannelESP32ESP32S2/S3
#0GPIO36GPIO01
#1GPIO37GPIO02
#2GPIO38GPIO03
#3GPIO39GPIO04
#4GPIO32GPIO05
#5GPIO33GPIO06
#6GPIO34(*1)GPIO07
#7GPIO35(*1)GPIO08
#8GPIO09
#9GPIO10

(*1) Input only.

When using ADC1_6(ADC1 Channel#6) and ADC1_7(ADC1 Channel#7), the following wiring is additionally required.

TFTADC1ESP32ESP32S2/S3
(Y+)Channel#6GPIO34GPIO07
(X-)Channel#7GPIO35GPIO08

GPIO number

It uses four GPIOs, but the GPIOs differ depending on the TFT model.

Save calibration data to NVS

Write calibration data to NVS.
Read calibration data from NVS when starting the firmware and use it.
If you use the same TFT, you don't need to calibrate again.
To clear the calibration data recorded in NVS, execute the following command.

idf.py erase_flash

Image

Check if touch works properly

You can check if touch screen works properly.
Image

If you touch it at this time, the touched coordinates will be displayed.
If there is no touch for 10 seconds, it will end.
Image

Move the touch-pen vertically and horizontally to check the X and Y coordinates.
What you get here is the physical coordinates.
See here about physical coordinates.
Image

OPEN-SMART 16Pin-Parallel Products

X(+)X(-)Y(+)Y(-)
LCD_D6LCD_RSLCD_WRLCD_D7

Touch0

OPEN-SMART TFT-Shield Products

There is no marking about 4-line resistance touch screen.
But 4-line resistance touch screen available.

X(+)X(-)Y(+)Y(-)
LCD_D6LCD_RSLCD_WRLCD_D7

Touch-OpenSmart-Sheild-1

When using ADC1_6(ADC1 Channel#6) and ADC1_7(ADC1 Channel#7), the following wiring is additionally required.

TFTESP32ESP32S2/S3
LCD_WR(Y+)ADC1_6(GPIO34)ADC1_6(GPIO07)
LCD_RS(X-)ADC1_7(GPIO35)ADC1_7(GPIO08)

4-line resistance touch screen cannot be used with the Wemos D1 ESP32.
Because the combination of GPIO and ADC does not match.

ELEGOO TFT-Shield Products

There is no marking about 4-line resistance touch screen.
But 4-line resistance touch screen available.

X(+)X(-)Y(+)Y(-)
LCD_D0LCD_RSLCD_CSLCD_D1

Touch-Elegoo-1

When using ADC1_6(ADC1 Channel#6) and ADC1_7(ADC1 Channel#7), the following wiring is additionally required.

TFTESP32ESP32S2/S3
LCD_CS(Y+)ADC1_6(GPIO34)ADC1_6(GPIO07)
LCD_RS(X-)ADC1_7(GPIO35)ADC1_7(GPIO08)

No additional wiring is required when using the Wemos D1 ESP32.
LCD_CS is assigned to ADC1_6 and LCD_RS is assigned to ADC1_7.

ILI9341 2.4inch TFT-Shield with Yellow Pin-header

There is no marking about 4-line resistance touch screen.
But 4-line resistance touch screen available.

X(+)X(-)Y(+)Y(-)
LCD_D0LCD_RSLCD_CSLCD_D1

Touch-ILI9341-1

When using ADC1_6(ADC1 Channel#6) and ADC1_7(ADC1 Channel#7), the following wiring is additionally required.

TFTESP32ESP32S2/S3
LCD_CS(Y+)ADC1_6(GPIO34)ADC1_6(GPIO07)
LCD_RS(X-)ADC1_7(GPIO35)ADC1_7(GPIO08)

No additional wiring is required when using the Wemos D1 ESP32.
LCD_CS is assigned to ADC1_6 and LCD_RS is assigned to ADC1_7.

ILI9486 3.5inch TFT-Shield

There is no marking about 4-line resistance touch screen.
But 4-line resistance touch screen available.

X(+)X(-)Y(+)Y(-)
LCD_D6LCD_RSLCD_WRLCD_D7

Touch-ILI9486-1

When using ADC1_6(ADC1 Channel#6) and ADC1_7(ADC1 Channel#7), the following wiring is additionally required.

TFTESP32ESP32S2/S3
LCD_WR(Y+)ADC1_6(GPIO34)ADC1_6(GPIO07)
LCD_RS(X-)ADC1_7(GPIO35)ADC1_7(GPIO08)

4-line resistance touch screen cannot be used with the Wemos D1 ESP32.
Because the combination of GPIO and ADC does not match.

Other TFT

I don't know which pin is X(+), X(-), Y(+), Y(-).
If you find, please tell me.

Calibrating the touch screen

Keep touching the corner point.
TouchCalib-1 TouchCalib-2

Draw with touch

If there is no touch for 10 seconds, it will end.
Touch-OpenSmat-16pin Touch-OpenSmart-Shield-2 Touch-Elegoo-2 Touch-ILI9341-2 Touch-ILI9486-2

Button with touch

You can only enter up to 15 characters.
If there is no touch for 10 seconds, it will end.
Touch-Keyboard

Move with touch

If there is no touch for 10 seconds, it will end.
Touch-Move-1 Touch-Move-2

If there is no touch for 10 seconds, it will end.
Touch-Menu-1 Touch-Menu-2

Select image with touch

If there is no touch for 10 seconds, it will end.
I borrowed the icon from here.
Touch-Icon-1 Touch-Icon-2

How dose it works

https://www.sparkfun.com/datasheets/LCD/HOW%20DOES%20IT%20WORK.pdf

How to use this component in your project

Create idf_component.yml in the same directory as main.c.

YourProject --+-- CMakeLists.txt
              +-- main --+-- main.c
                         +-- CMakeLists.txt
                         +-- idf_component.yml

Contents of idf_component.yml.

dependencies:
  nopnop2002/parallel-tft:
    path: components/tft_library/
    git: https://github.com/nopnop2002/esp-idf-parallel-tft.git

When you build a projects esp-idf will automaticly fetch repository to managed_components dir and link with your code.

YourProject --+-- CMakeLists.txt
              +-- main --+-- main.c
              |          +-- CMakeLists.txt
              |          +-- idf_component.yml
              +-- managed_components ----- nopnop2002__parallel-tft

Application layer

LibraryLayer

Performance comparison using ILI9488(320x480)

I2S parallel is not always faster.
Depending on the application, REGISTER I/O parallel may be faster.
Compiling with the O2 option doesn't help much.
The unit of the number is the required time in milliseconds.
A smaller value indicates faster speed.

TestGPIO parallelREGISTER I/O parallelI2S parallelI2S parallel(O2)
AddressTest8202804030
FillTest3900237016201590
ColorBarTest8102906040
ArrowTest860300160140
LineTest206086031502900
CircleTest195083028402610
RoundRectTest197082029302690
RectAngleTest2810134051804880
TriangleTest2960153060905640
DirectionTest900330250230
HorizontalTest1110430610550
VerticalTest1110430610550
FillRectTest1300590200140
ColorTest1660650220180
BMPTest7280650061305790
JPEGTest1210490170140
PNGTest14807504401010

graph

Performance comparison using ILI9341(240x320)

SPI used this.

TestSPIGPIO parallelREGISTER I/O parallelI2S parallel
FillTest1620270019201560
ColorBarTest8041015030
ArrowTest250450160140
LineTest277010304301570
CircleTest24709704101410
RoundRectTest25109704001430
RectAngleTest599020009404050
TriangleTest695021109904740
DirectionTest420500190240
HorizontalTest1030710290590
VerticalTest1010710290590
FillRectTest170710340120
ColorTest250850340150
BMPTest7470688063606120
JPEGTest2530800350150
PNGTest28001070610420

Reference about I2S driver

https://github.com/espressif/esp-iot-solution/tree/master/components/bus
Unfortunately, these codes cannot be built with ESP-IDF V6.

  • for esp32
    i2s_lcd_esp32_driver.c
  • for esp32s2
    i2s_lcd_esp32s2_driver.c
  • for esp32s3
    8080_lcd_esp32s3.c
  • Common header
    i2s_lcd_driver.h

Similar Projects

Discover other similar projects and AI models.

RepositoryC
nopnop2002/esp-idf-ili9340

SPI TFT and XPT2046 touch screen controller driver for esp-idf

263
Nov 24, 2026
RepositoryC
HeyWillow/willow

Open source, local, and self-hosted Amazon Echo/Google Home competitive Voice Assistant alternative

3.1k
Nov 1, 2026
RepositoryC
RavenSystem/esp-homekit-devices

Advanced firmware to add native Apple HomeKit and custom configurations, compatible with any SoC based on ESP32, ESP32-S, ESP32-C and ESP8266 series. (Shelly, Sonoff, Electrodragon, Tuya...)

3.0k
Nov 8, 2026
RepositoryC
RobertoBenjami/stm32_graphics_display_drivers

STM32 LCD drivers (currently: spi(dma), gpio, fsmc(dma), st7735, st7783, ili9325, ili9328, ili9341, ili9486, ili9488, hx8347g)

703
Dec 29, 2022
RepositoryC
RobertoBenjami/stm32_hal_graphics_display_drivers

STM32 graphics LCD and Touchscreen drivers (LCD: st7735, st7781, ili9325, ili9328, ili9341, ili9488, Touch: analog resistive, xpt2046, stmpe811)

116
Nov 15, 2024
RepositoryC++
espressif/arduino-esp32

Arduino core for the ESP32 family of SoCs

17.8k
Dec 1, 2026
RepositoryRust
ruvnet/RuView

π RuView turns commodity WiFi signals into real-time spatial intelligence, vital sign monitoring, and presence detection — all without a single pixel of video.

105.9k
Dec 2, 2026
RepositoryC
lvgl/lvgl

LVGL is a free, full-featured embedded UI library for small MCUs and 3D-capable MPUs, enhanced by LVGL Pro, a professional editor and tooling.

25.3k
Nov 27, 2026
RepositoryC
nodemcu/nodemcu-firmware

Lua based interactive firmware for ESP8266, ESP8285 and ESP32

8.0k
Nov 22, 2026