/esp-idf-ili9340

SPI TFT Driver for esp-idf

Primary LanguageCMIT LicenseMIT

esp-idf-ili9340

SPI TFT Driver for esp-idf

Installation for ESP32

git clone https://github.com/nopnop2002/esp-idf-ili9340
cd esp-idf-ili9340/
idf.py set-target esp32
idf.py menuconfig
idf.py flash

Installation for ESP32-S2

git clone https://github.com/nopnop2002/esp-idf-ili9340
cd esp-idf-ili9340/
idf.py set-target esp32s2
idf.py menuconfig
idf.py flash

ESP32-S2 Limitation

  • tjpgd library does not exist in ESP32-S2 ROM.
  • JPEG and PNG function is not supported because the ROM is small.

Configuration

You have to set this config value with menuconfig.

  • CONFIG_WIDTH
  • CONFIG_HEIGHT
  • CONFIG_OFFSETX
  • CONFIG_OFFSETY
  • CONFIG_MOSI_GPIO
  • CONFIG_SCLK_GPIO
  • CONFIG_CS_GPIO
  • CONFIG_DC_GPIO
  • CONFIG_RESET_GPIO
  • CONFIG_BL_GPIO
    GPIO of ESP32 cannot supply too much current.
    The TFT backlight is more stable when supplied from an external power source.
    MISO is not use.

config-menu


Tested TFT

M5Stack
4.0" ST7796S 480x320
3.2" ILI9341 320x240
2.8" ILI9341 320x240
2.4" ILI9341 320x240
2.2" ILI9340 320x240
2.0" ILI9225 176x220
2.0" ILI9225G 176x220
1.8" ST7735 128x160
1.77" ST7735 128x160
1.44" ST7735 128x128
0.96" ST7735 80x160

spi-tft


M5Stack

config-m5stack

M5Stick-1 M5Stack-2 M5Stick-3 M5Stick-4 M5Stick-5 M5Stick-6 M5Stick-7 M5Stick-8 M5Stick-9 M5Stick-10 M5Stick-11

BMP file
M5Stack-BMP

JPEG file(ESP32 only)
M5Stack-JPEG

PNG file(ESP32 only)
M5Stack-PNG


4.0" ST7796S 480x320

config-st7796

Left:4.0" Right:2.4" 4_0_st779s


3.2" ILI9341 320x240

2.8" ILI9341 320x240

2.4" ILI9341 320x240

config-ili9341

Left:3.2" Right:2.4" 3_2_ili9341

Left:2.8" Right:2.4" screen_2-8_240x320


2.2" ILI9340 320x240

config-ili9340

Left:2.2" Right:2.4" screen_2-2_240x320


2.0" ILI9225 176x220

config-ili9225

Left:2.0" Right:2.4" 2_0_ili9225


2.0" ILI9225G 176x220

config-ili9225g

Left:2.0" Right:2.4" 2_0_ili9225g


1.8" ST7735 128x160

config-st7735-128x160-1

Left:1.8" Right:2.4" 1_8_st7735


1.8" ST7735 128x160

config-st7735-128x160-2 screen_1-8_128x160-12 screen_1-8_128x160-13


1.8" ST7735 128x160

config-st7735-128x160-3 screen_1-8_128x160-21 screen_1-8_128x160-31


1.77" ST7735 128x160

config-st7735-128x160-4

Left:1.77" Right:1.8" screen_1-77_128x160


1.44" ST7735 128x160

config-st7735-128x160-5

Left:1.44" Right:2.0" screen_1-8_128x160-2


1.44" ST7735 128x128

config-st7735-128x128 screen_1-44_128x128-12 screen_1-44_128x128-13

GRAM Offset may be different


0.96" ST7735 80x160

config-st7735-80x160

Left:1.44" Right:0.96" screen_0-96_80x160-3


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.


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

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.

FontxFile yourFont[2];
InitFontx(yourFont,"/spiffs/your_font_file_name","");
uint8_t ascii[10];
strcpy((char *)ascii, "MyFont");
uint16_t color = RED;
lcdDrawString(&dev, yourFont, x, y, ascii, color);

Font File Editor(FONTX Editor)

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

FontxEditor

This library 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

Changing this file will change the font.


Reference

You can use TFT Shield like this:
TFT-Shield

https://github.com/nopnop2002/esp-idf-parallel-tft