{"id":16239324,"url":"https://github.com/nopnop2002/esp-idf-ili9340","last_synced_at":"2025-04-15T12:27:57.688Z","repository":{"id":79564253,"uuid":"186912730","full_name":"nopnop2002/esp-idf-ili9340","owner":"nopnop2002","description":"SPI TFT and XPT2046 touch screen controller driver for esp-idf","archived":false,"fork":false,"pushed_at":"2025-02-22T21:59:30.000Z","size":981,"stargazers_count":192,"open_issues_count":1,"forks_count":38,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-15T12:27:22.042Z","etag":null,"topics":["bmp","esp-idf","esp32","ili9325","ili9340","ili9341","jpeg","jpeg-decoder","m5stack","png","png-decoder","spi","st7735","st7796","touchscreen","xpt2046"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nopnop2002.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-15T22:45:51.000Z","updated_at":"2025-04-08T21:55:55.000Z","dependencies_parsed_at":"2023-10-15T00:54:38.295Z","dependency_job_id":"73b8eda9-f000-49d1-b066-f3a6c65591a3","html_url":"https://github.com/nopnop2002/esp-idf-ili9340","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nopnop2002%2Fesp-idf-ili9340","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nopnop2002%2Fesp-idf-ili9340/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nopnop2002%2Fesp-idf-ili9340/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nopnop2002%2Fesp-idf-ili9340/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nopnop2002","download_url":"https://codeload.github.com/nopnop2002/esp-idf-ili9340/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249070938,"owners_count":21207914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bmp","esp-idf","esp32","ili9325","ili9340","ili9341","jpeg","jpeg-decoder","m5stack","png","png-decoder","spi","st7735","st7796","touchscreen","xpt2046"],"created_at":"2024-10-10T13:43:19.668Z","updated_at":"2025-04-15T12:27:57.662Z","avatar_url":"https://github.com/nopnop2002.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# esp-idf-ili9340\nSPI TFT and XPT2046 touch screen controller driver for esp-idf.\n\n# Software requirements\nESP-IDF V5.0 or later.   \nESP-IDF V4.4 release branch reached EOL in July 2024.   \n\n__Note for ESP32-C6__   \nESP-IDF V5.1 is required when using ESP32-C6.   \n\n# Installation\n\n```\ngit clone https://github.com/nopnop2002/esp-idf-ili9340\ncd esp-idf-ili9340/\nidf.py set-target {esp32/esp32s2/esp32s3/esp32c2/esp32c3/esp32c6}\nidf.py menuconfig\nidf.py flash\n```\n\n__Note for ESP32-S2/ESP32-C2__   \nThe tjpgd library is not included in the ESP32-S2/ESP32-C2 ROM.   \nHowever, you can use [this](https://components.espressif.com/components/espressif/esp_jpeg) IDF component registry.   \nJPEG files can be displayed.   \n\n__Note for ESP32-C2__   \nESP32-C2 has less SRAM, so JPEG and PNG may not be displayed on higher resolution TFTs.   \n```\nE (256560) decode_jpeg: Error allocating memory for line 251\nE (260630) pngle_new: Error allocating memory for line 160\n```\n\n__Note for ESP32-S2__   \nESP32-S2 has less SRAM, but some ESP32-S2 have PSRAM.   \nIf your SoC has PSRAM, you can avoid running out of memory by enabling PSRAM.   \n![config-psram](https://github.com/user-attachments/assets/a71b320d-f5fb-4cd5-9466-f191b8704d40)\n\n\n# Configuration   \nYou have to set this config value with menuconfig.   \n- CONFIG_WIDTH   \n- CONFIG_HEIGHT   \n- CONFIG_OFFSETX   \n- CONFIG_OFFSETY   \n- CONFIG_MOSI_GPIO   \n- CONFIG_SCLK_GPIO   \n- CONFIG_CS_GPIO   \n- CONFIG_DC_GPIO   \n- CONFIG_RESET_GPIO   \n- CONFIG_BL_GPIO   \n __GPIO of ESP32 cannot supply too much current.__   \n __TFT backlight becomes brighter when powered by an external power source.__   \n\n__TFT MISO is not use.__   \n\n![config-menu](https://user-images.githubusercontent.com/6020549/101022538-db9fcb00-35b4-11eb-95a9-ad84a880c7fb.jpg)\n\n---\n\n# Tested TFT   \n- M5Stack   \n- Shenzhen Jingcal Intelligent 3.5\" ST7796 320x480 (ESP32-3248S035)   \n- Shenzhen Jingcal Intelligent 2.8\" ILI9341 240x320 (ESP32-2432S028R)   \n- 4.0\" ST7796 320x480   \n- 3.2\" ILI9341 240x320   \n- 2.8\" ILI9341 240x320   \n- 2.8\" ST7789  240x320   \n- 2.4\" ILI9341 240x320   \n- 2.4\" ST7789  240x320   \n- 2.2\" ILI9340 240x320   \n- 2.0\" ILI9225 176x220   \n- 1.8\" ST7735 128x160   \n- 1.77\" ST7735 128x160   \n- 1.44\" ST7735 128x128   \n- 0.96\" ST7735 80x160   \n\n\n### Generic Product   \n![spi-tft](https://user-images.githubusercontent.com/6020549/59512687-3098de80-8ef4-11e9-9759-530ffe47d659.JPG)\n\n__A note about RESET__   \nPull Up of the RESET pin may be required. I inserted a 100 ohm resistor between Vcc and RESET.   \n\n### Shenzhen Jingcal Intelligent Product   \nThey can use touch screens.   \n![Shenzhen_Jingcal_Intelligent](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/eda884bb-9fac-40ea-8396-d77bb0de074b)\n\n__ESP32-2432S032/ESP32-4827S043/ESP32-8048S043 doesn't work because it's an RGB panel, not SPI.__   \n\n---\n\n# M5Stack\n\n![config-m5stack](https://user-images.githubusercontent.com/6020549/101022626-f96d3000-35b4-11eb-8c60-a8a4896306d9.jpg)\n\n![M5Stick-1](https://user-images.githubusercontent.com/6020549/57977479-7d43e380-7a34-11e9-99b6-6028500436e8.JPG)\n![M5Stack-2](https://user-images.githubusercontent.com/6020549/59008264-f7fa6480-8864-11e9-92f6-ffbd979fa75e.JPG)\n![M5Stick-3](https://user-images.githubusercontent.com/6020549/57977481-7d43e380-7a34-11e9-9bc6-8e415aa52c52.JPG)\n![M5Stick-4](https://user-images.githubusercontent.com/6020549/57977482-7d43e380-7a34-11e9-8188-653cb02f3ba0.JPG)\n![M5Stick-5](https://user-images.githubusercontent.com/6020549/57977483-7ddc7a00-7a34-11e9-936e-4d97b1411610.JPG)\n![M5Stick-6](https://user-images.githubusercontent.com/6020549/57977484-7ddc7a00-7a34-11e9-8750-52db073c96c2.JPG)\n![M5Stick-7](https://user-images.githubusercontent.com/6020549/57977485-7e751080-7a34-11e9-95f9-ffb12879d1b0.JPG)\n![M5Stick-8](https://user-images.githubusercontent.com/6020549/57977486-7e751080-7a34-11e9-9ac8-c546f248fdec.JPG)\n![M5Stick-9](https://user-images.githubusercontent.com/6020549/57977487-7e751080-7a34-11e9-9a3e-6a0bd7359efb.JPG)\n![M5Stick-10](https://user-images.githubusercontent.com/6020549/57977488-7e751080-7a34-11e9-9a12-e2b70334604d.JPG)\n![M5Stick-11](https://user-images.githubusercontent.com/6020549/57977489-7f0da700-7a34-11e9-9ea3-c0420a785a3e.JPG)\n\nBMP file   \n![M5Stack-BMP](https://user-images.githubusercontent.com/6020549/78413964-dcaee000-7654-11ea-88f2-e70662d761e1.JPG)\n\nJPEG file(Cannot be displayed on ESP32S2)   \n![M5Stack-JPEG](https://user-images.githubusercontent.com/6020549/78413968-e0426700-7654-11ea-9040-0fdfd0f2de2e.JPG)\n\nPNG file   \n![M5Stack-PNG](https://user-images.githubusercontent.com/6020549/78613610-40c8e280-78a7-11ea-95b0-a89ce14dc196.JPG)\n\nPNG icon\n![M5Stack-ICON](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/120af5a4-9b31-476a-a9db-258c2d0072e7)\n\n---\n\n# 4.0\" ST7796S 320x480\n\n![config-st7796](https://user-images.githubusercontent.com/6020549/101022680-0e49c380-35b5-11eb-914f-f522b33bb49a.jpg)\n\nLeft:4.0\" Right:2.4\"\n![4_0_st779s](https://user-images.githubusercontent.com/6020549/85913118-e7040300-b86c-11ea-87fd-fdcd97c5bf26.JPG)\n\n---\n\n# Shenzhen Jingcal Intelligent 3.5\" ST7796 320x480\nVendor part number is ESP32-3248S035.   \n\n![config-ESP32-3248S035](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/68749d5a-9047-4725-bc06-281f37e44539)\n![ESP32-3248S035-1](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/ee2b7eb5-2627-4bbf-b7a5-8a31005cf22d)\n![ESP32-3248S035-2](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/56d7bc3b-ab03-4486-bd51-bc16d6138d1c)\n\n---\n\n# 3.2\" ILI9341 240x320\n# 2.8\" ILI9341 240x320\n# 2.4\" ILI9341 240x320\n\n![config-ili9341](https://user-images.githubusercontent.com/6020549/101022718-1b66b280-35b5-11eb-8103-7bbb1f0a7a30.jpg)\n\nLeft:3.2\" Right:2.4\"\n![3_2_ili9341](https://user-images.githubusercontent.com/6020549/85909286-0b9fb100-b854-11ea-9935-942fe7344f25.JPG)\n\nLeft:2.8\" Right:2.4\"\n![screen_2-8_240x320](https://user-images.githubusercontent.com/6020549/59007633-3f332600-8862-11e9-8d8f-bbfb303456f4.JPG)\n\n---\n\n# 2.8\" ST7789 240x320\n# 2.4\" ST7789 240x320\n\n![config_st7789_2-4_240x320](https://github.com/user-attachments/assets/0ce336db-8a51-4b76-b268-0dda76559f9a)\n\nLeft:2.4\" Right:2.8\"\n![screen_st7789_240x320](https://github.com/user-attachments/assets/ccb5335d-2800-4300-a91e-182e07772c3d)\n\n---\n\n# Shenzhen Jingcal Intelligent 2.8\" ILI9341 240x320\nVendor part number is ESP32-2432S028R.   \n\n![config-ESP32-2432S028R-1](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/317e365c-3c1a-4c6f-9c14-f07feacbd4d8)\n![ESP32-2432S028R-1](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/e9e4b502-4063-49b2-b58a-d60aeccdd380)\n![ESP32-2432S028R-2](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/d6d6cc27-463a-4ad5-a739-441d6ebdc037)\n\n\n---\n\n# 2.2\" ILI9340 240x320\n\n![config-ili9340](https://user-images.githubusercontent.com/6020549/101022746-2588b100-35b5-11eb-8eaa-1f86cc4c9f93.jpg)\n\nLeft:2.2\" Right:2.4\"\n![screen_2-2_240x320](https://user-images.githubusercontent.com/6020549/59007758-d304f200-8862-11e9-8d61-fa4b734f4b9a.JPG)\n\n---\n\n# 2.0\" ILI9225 176x220\n\n![config-ili9225](https://user-images.githubusercontent.com/6020549/101022807-3a654480-35b5-11eb-9e3d-b2eb5e396f08.jpg)\n\nLeft:2.0\" Right:2.4\"\n![2_0_ili9225](https://user-images.githubusercontent.com/6020549/85910092-004e8480-b858-11ea-98f9-2ba9efe5880a.JPG)\n\n---\n\n# 1.8\" ST7735 128x160\n\n![config-st7735-128x160-1](https://user-images.githubusercontent.com/6020549/101023253-dc852c80-35b5-11eb-97c8-4873200f85e7.jpg)\n\nLeft:1.8\" Right:2.4\"\n![1_8_st7735](https://user-images.githubusercontent.com/6020549/85910349-3cceb000-b859-11ea-98a0-ecda6870d5aa.JPG)\n\n---\n\n# 1.8\" ST7735 128x160\n\n![config-st7735-128x160-2](https://user-images.githubusercontent.com/6020549/101023297-ec9d0c00-35b5-11eb-924b-a4aefc0dc9f2.jpg)\n![screen_1-8_128x160-12](https://user-images.githubusercontent.com/6020549/59007829-21b28c00-8863-11e9-945d-91f1c2fa2d14.JPG)\n![screen_1-8_128x160-13](https://user-images.githubusercontent.com/6020549/77221889-4cbb6180-6b91-11ea-9e3f-97d9ddafb82d.JPG)\n\n---\n\n# 1.8\" ST7735 128x160\n\n![config-st7735-128x160-3](https://user-images.githubusercontent.com/6020549/101023341-f6267400-35b5-11eb-8835-7ea3278ba6eb.jpg)\n![screen_1-8_128x160-21](https://user-images.githubusercontent.com/6020549/59007852-3858e300-8863-11e9-8f03-ce4ae9eb652b.JPG)\n![screen_1-8_128x160-31](https://user-images.githubusercontent.com/6020549/59970608-b9271700-95a5-11e9-94f8-062740fe135c.JPG)\n\n---\n\n# 1.77\" ST7735 128x160\n\n![config-st7735-128x160-4](https://user-images.githubusercontent.com/6020549/101023366-01799f80-35b6-11eb-8608-96bab43d909f.jpg)\n\nLeft:1.77\" Right:1.8\"\n![screen_1-77_128x160](https://user-images.githubusercontent.com/6020549/59970576-bd066980-95a4-11e9-9f4a-88d69733f034.JPG)\n\n---\n\n# 1.44\" ST7735 128x160\n\n![config-st7735-128x160-5](https://user-images.githubusercontent.com/6020549/101023395-0a6a7100-35b6-11eb-887c-3ebfc93bb0eb.jpg)\n\nLeft:1.44\" Right:2.0\"\n![screen_1-8_128x160-2](https://user-images.githubusercontent.com/6020549/59007892-63433700-8863-11e9-86a7-1b92e8b15efd.JPG)\n\n---\n\n# 1.44\" ST7735 128x128\n![config-st7735-128x128](https://user-images.githubusercontent.com/6020549/101023420-16eec980-35b6-11eb-9c75-ca90a8b7f99a.jpg)\n![screen_1-44_128x128-12](https://user-images.githubusercontent.com/6020549/59007915-7eae4200-8863-11e9-901f-037cbc0baed2.JPG)\n![screen_1-44_128x128-13](https://user-images.githubusercontent.com/6020549/77222202-775ae980-6b94-11ea-8eed-0f6829833da8.JPG)\n\n__GRAM Offset may be different__\n\n---\n\n# 0.96\" ST7735 80x160\n\n![config-st7735-80x160](https://user-images.githubusercontent.com/6020549/101023455-240bb880-35b6-11eb-9008-e69c59efb825.jpg)\n\nLeft:1.44\" Right:0.96\"\n![screen_0-96_80x160-3](https://user-images.githubusercontent.com/6020549/59007940-9ede0100-8863-11e9-85ba-6eca86b6f441.JPG)\n\n---\n\n# JPEG Decoder   \nThe ESP-IDF component includes Tiny JPEG Decompressor.   \nThe document of Tiny JPEG Decompressor is [here](http://elm-chan.org/fsw/tjpgd/00index.html).   \nThis can reduce the image to 1/2 1/4 1/8.   \n\n---\n\n# PNG Decoder   \nThe ESP-IDF component includes part of the miniz library, such as mz_crc32.   \nBut it doesn't support all of the miniz.   \nThe document of miniz library is [here](https://github.com/richgel999/miniz).   \n\nAnd I ported the pngle library from [here](https://github.com/kikuchan/pngle).   \nThis can reduce the image to any size.   \n\n---\n\n# Font File   \nThis project uses the following as default fonts:   \n- font/ILGH16XB.FNT // 8x16Dot Gothic\n- font/ILGH24XB.FNT // 12x24Dot Gothic\n- font/ILGH32XB.FNT // 16x32Dot Gothic\n- font/ILMH16XB.FNT // 8x16Dot Mincyo\n- font/ILMH24XB.FNT // 12x24Dot Mincyo\n- font/ILMH32XB.FNT // 16x32Dot Mincyo\n\nFrom 0x00 to 0x7f, the characters image of Alphanumeric are stored.   \nFrom 0x80 to 0xff, the characters image of Japanese are stored.   \nChanging this file will change the font.\n\nYou can add your original fonts.   \nThe format of the font file is the FONTX format.   \nYour font file is put in font directory.   \nYour font file is uploaded to SPIFFS partition using meke flash.   \n\nPlease refer [this](http://elm-chan.org/docs/dosv/fontx_e.html) page about FONTX format.   \n\n---\n\n# Font File Editor(FONTX Editor)   \n[There](http://elm-chan.org/fsw/fontxedit.zip) is a font file editor.   \nThis can be done on Windows 10.   \nDeveloper page is [here](http://elm-chan.org/fsw_e.html).   \n\n![fontx-editor-1](https://github.com/user-attachments/assets/76a8c96f-74c3-4583-a4f1-5664f0e81f3a)\n\n# Convert from BDF font to FONTX font   \nstep1)   \ndownload Font File Editor(FONTX Editor) from [here](http://elm-chan.org/fsw_e.html).   \n\nstep2)   \ndownload BDF font file from Internet.   \nI downloaded from [here](https://github.com/fcambus/spleen).   \nfontxedit.exe can __ONLY__ import Monospaced bitmap fonts file.   \nMonospaced bitmap fonts can also be downloaded [here](https://github.com/Tecate/bitmap-fonts).\n\nstep3)   \nimport the BDF font file into your fontxedit.exe.   \nthis tool can convert from BDF to FONTX.   \n![fontx-editor-2](https://github.com/user-attachments/assets/3353bf23-01f0-455d-8c9c-b56d55b4dc9c)\n\nstep4)   \nadjust font size.   \n![fontx-editor-3](https://github.com/user-attachments/assets/0a99fb0b-1725-472e-8310-ca57362ae6d1)\n\nstep5)   \ncheck font pattern.   \nwhen you have made any changes, press the apply button.   \n![fontx-editor-4](https://github.com/user-attachments/assets/44b8ed95-0c3e-4507-87fa-b94c3c2349de)\n\nstep6)   \nsave as .fnt file from your fontedit.exe.   \n![fontx-editor-5](https://github.com/user-attachments/assets/db5b62a8-3a61-49aa-8505-b906067f1111)\n\nstep7)   \nupload your font file to $HOME/esp-idf-ili9340/font directory.   \n\nstep8)   \nadd font to use   \n```\nFontxFile fx32L[2];\nInitFontx(fx32L,\"/spiffs/LATIN32B.FNT\",\"\"); // 16x32Dot LATIN\n```\nFont file that From 0x00 to 0x7f, the characters image of Standard ASCII are stored.   \n![M5Statck-Font-1](https://user-images.githubusercontent.com/6020549/132110943-98e8f481-8840-4e96-b649-f525aa427826.JPG)\n\nFont file that From 0x80 to 0xff, the characters image of Japanese are stored.   \n![M5Statck-Font-2](https://user-images.githubusercontent.com/6020549/132110947-d161678f-0424-4934-91b6-22eb12a57435.JPG)\n\nFont file that From 0x80 to 0xff, the characters image of Latin are stored.   \n![M5Statck-Font-3](https://user-images.githubusercontent.com/6020549/132110951-e7faaaa9-cdf2-429d-8eea-d20fe0748524.JPG)\n\nu8g2 library contains many BDF fonts.   \nThis is a 24x24 font converted from emoticons21.bdf.   \n![bdf-font-1](https://github.com/user-attachments/assets/0c5470df-ab99-4b73-b3ac-624b6e6a5230)\n\nThis is a 16x16 font converted from Scroll-o-Sprites.bdf.   \n![bdf-font-2](https://github.com/user-attachments/assets/41dd693d-cb3d-4928-b213-49bf7cad4f6a)\n\n# Convert from TTF font to FONTX font  \nstep1)   \nDownload WFONTX64.exe from [here](https://github.com/nemuisan/WFONTX64/releases).\nDeveloper page is [here](https://github.com/nemuisan/WFONTX64).   \n\nstep2)   \nSelect ttf font.   \n___Please note that if you select a proportional font, some fonts may not convert correctly.___   \nIf you select a proportional font, some fonts will need to be modified using fontxedit.exe.   \nMonospaced fonts can be converted correctly.   \nYou can find Monospaced fonts [here](https://en.wikipedia.org/wiki/List_of_monospaced_typefaces).   \n![WFONTX64-1](https://github.com/user-attachments/assets/2193a3c4-021c-48e6-8486-2ce500bdac36)\n\nstep3)   \nEnter Height, Width, FontX2 name.   \nSpecify half of Height for Width.   \nSpecify your favorite font name in the FontX2 name field using up to 8 characters.   \n![WFONTX64-2](https://github.com/user-attachments/assets/c87a9ec9-8e28-4d34-8475-60b15a47fb22)\n\nstep4)   \nSpecify the file name to save.   \n![WFONTX64-3](https://github.com/user-attachments/assets/9715d4bf-e460-41a6-9a4b-38c0f10020f7)\n\nstep5)   \nSpecify the font style as required.   \n![WFONTX64-4](https://github.com/user-attachments/assets/0ff3072d-6a78-48ae-b855-60c692f8d771)\n\nstep6)   \nPress the RUN button to convert TTF fonts to FONTX format.   \n![WFONTX64-5](https://github.com/user-attachments/assets/d9797e3d-1fd6-4504-b161-c1280f1242c0)\n\nstep7)   \nupload your font file to $HOME/esp-idf-ili9340/font directory.   \n\nstep8)   \nadd font to use   \n```\n    FontxFile fx16G[2];\n    FontxFile fx24G[2];\n    FontxFile fx32G[2];\n    //InitFontx(fx16G,\"/spiffs/ILGH16XB.FNT\",\"\"); // 8x16Dot Gothic\n    //InitFontx(fx24G,\"/spiffs/ILGH24XB.FNT\",\"\"); // 12x24Dot Gothic\n    //InitFontx(fx32G,\"/spiffs/ILGH32XB.FNT\",\"\"); // 16x32Dot Gothic\n    InitFontx(fx16G,\"/spiffs/Gigi16.FNT\",\"\"); // 8x16Dot Gigi\n    InitFontx(fx24G,\"/spiffs/Gigi24.FNT\",\"\"); // 12x24Dot Gigi\n    InitFontx(fx32G,\"/spiffs/Gigi32.FNT\",\"\"); // 16x32Dot Gigi\n\n```\n\n![ttf_font](https://github.com/user-attachments/assets/9f01959b-b083-4a67-806f-86909630ad32)\n\n# How to add your color   \nChange here.   \n```\n#define RED    rgb565(255,   0,   0) // 0xf800\n#define GREEN  rgb565(  0, 255,   0) // 0x07e0\n#define BLUE   rgb565(  0,   0, 255) // 0x001f\n#define BLACK  rgb565(  0,   0,   0) // 0x0000\n#define WHITE  rgb565(255, 255, 255) // 0xffff\n#define GRAY   rgb565(128, 128, 128) // 0x8410\n#define YELLOW rgb565(255, 255,   0) // 0xFFE0\n#define CYAN   rgb565(  0, 156, 209) // 0x04FA\n#define PURPLE rgb565(128,   0, 128) // 0x8010\n```\n\n---\n\n# XPT2046 Touch Screen   \nA library of XPT2046 Touch Screen is included in this project.   \nThere is a TFT equipped with XPT2046.   \n![XPT2046-3](https://user-images.githubusercontent.com/6020549/144333924-5236bff3-3f4d-4be4-8e99-b6e31878e4f3.jpg)\n\nXPT2046 shares the TFT and SPI bus.   \nUse the menu to enable XPT2046.   \n![config-xpt2046-1](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/61323301-4b6a-4012-84f8-ee95dadb2db0)\n\n- Touch position accuacy   \nThe coordinates read from XPT2046 are physical coordinates.   \nPhysical coordinates are converted to logical coordinates.   \nThen draw using logical coordinates.   \nIn TouchPenTest, when you touch the screen, a circle is drawn at the touched position, but if you touch the same position as the previous time, it is not drawn.   \nThis value is the threshold that determines whether the touch location is the same as the previous touch location.   \nDecreasing this value will make the position more accurate, but less responsive.   \nIncreasing this value will make the position more inaccurate but more responsive.   \n\n\n### HR2046 Chip   \nThere is a TFT equipped with HR2046.   \nXPT2046 and HR2046 are very similar. But HR2046 does not work properly.   \n![XPT2046-2](https://user-images.githubusercontent.com/6020549/144332571-717f33b1-df03-4a0a-9a23-c7c99b9d4d32.JPG)\n\n\n### Wirering for XPT2046  \n\n|TFT||ESP32|ESP32-S2/S3|ESP32-C2/C3||\n|:-:|:-:|:-:|:-:|:-:|:-:|\n|VCC|--|3.3V|3.3V|3V3||\n|GND|--|GND|GND|GND||\n|CS|--|GPIO14|GPIO34|GPIO2||\n|RES|--|GPIO33|GPIO41|GPIO4|(*1)|\n|D/C|--|GPIO27|GPIO40|GPIO3|(*1)|\n|MOSI|--|GPIO23|GPIO35|GPIO0|(*1) (*2)|\n|SCK|--|GPIO18|GPIO36|GPIO1|(*1) (*2)|\n|LED|--|3.3V|3.3V|3.3V|(*1) (*3)|\n|MISO|--|N/C|N/C|N/C||\n|T_CLK|--|GPIO18|GPIO36|GPIO1|(*1) (*2)|\n|T_CS|--|GPIO21|GPIO38|GPIO7|(*1) (*4)|\n|T_DIN|--|GPIO23|GPIO35|GPIO0|(*1) (*2)|\n|T_OUT|--|GPIO19|GPIO37|GPIO6|(*1) (*4)|\n|T_IRQ|--|GPIO22|GPIO39|GPIO8|(*1) (*4)|\n\n(*1) You can change it to any gpio using menuconfig. But some gpio's are input only.   \n\n(*2) These are shared by TFT and XPT2046.   \n\n(*3) It can be controlled using gpio. However, GPIO of ESP32 cannot supply too much current. TFT backlight becomes brighter when powered by an external power source.   \n\n(*4) I found that there are limits to the GPIOs that can be used as touch panel controls.   \n\n### Check if XPT2046 works properly   \nYou can check if XPT2046 works properly.   \n![config-xpt2046-2](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/4fe1f528-c443-4e93-a22f-e85f9f02ef84)\n\nIf you touch it at this time, the touched coordinates will be displayed.   \nIf there is no touch for 10 seconds, it will end.   \n![TouchPosition-1](https://user-images.githubusercontent.com/6020549/147400381-cdd61863-c619-45e0-95ee-2aba593b22da.jpg)\n\nMove the touch-pen vertically and horizontally to check the X and Y coordinates.   \nWhat you get here is the physical coordinates.   \nSee [here](https://github.com/nopnop2002/esp-idf-ili9340/issues/39) about physical coordinates.   \n![TouchPosition-2](https://user-images.githubusercontent.com/6020549/147400385-20b035b4-653a-4605-9d36-6d325a1f68a3.jpg)\n\n### Using ESP32-3248S035   \nThis module also has an XPT2046.   \n![ESP32-3248S035-2](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/56d7bc3b-ab03-4486-bd51-bc16d6138d1c)\n![ESP32-3248S035-3](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/bed91135-fd74-4789-949e-f9c8398b565f)\n\nXPT2046 uses the same SPI bus as TFT.   \nXPT2046's SCLK and MOSI use the same GPIO as the TFT.   \n![config-ESP32-3248S035-2](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/7388f072-8e4f-43c0-b8c4-545bf774f0db)\n\n### Using ESP32-2432S028R   \nThis module also has an XPT2046.   \n![ESP32-2432S028R-2](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/af351771-6c08-4949-b541-1c9d35e97c8e)\n![ESP32-2432S028R-3](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/4cdd0bed-a248-4a69-83aa-5c44e2f2e02d)\n\nXPT2046 uses a different SPI bus than TFT.   \nXPT2046's SCLK and MOSI use separate GPIOs from the TFT.   \n![config-ESP32-2432S028R-2](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/65679e0c-c08f-4dca-bc2a-13f9f52dadd4)\n\n### Calibration   \nKeep touching the point.   \n![XPT2046-1](https://user-images.githubusercontent.com/6020549/145127021-6f311ab1-0def-4577-9212-39b3848756ae.JPG)\n![XPT2046-2](https://user-images.githubusercontent.com/6020549/145127026-be6496bc-90d6-48f7-8a0e-da7c1a7ac618.JPG)\n\n### Draw with touch   \nIf there is no touch for 10 seconds, it will end.   \n![TouchPen-1](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/83c25554-aa45-49cd-b8d7-6eda9303b31d)\n\n### Button with touch   \nYou can only enter up to 15 characters.   \nIf there is no touch for 10 seconds, it will end.   \n![TouchKeyboard](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/fdba50c7-e349-4fba-8b70-5d50a96aa708)\n\n### Move with touch   \nIf there is no touch for 10 seconds, it will end.   \n![TouchMove-1](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/d6cd524d-b576-4109-bcf7-98e26f36f99c)\n![TouchMove-2](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/7be77525-9f61-4deb-9025-f502ab6df76a)\n\n### Menu with Touch   \nIf there is no touch for 10 seconds, it will end.   \n![TouchMenu-1](https://github.com/user-attachments/assets/bf57ac5a-65a1-4081-b172-01e7771cef06)\n![TouchMenu-2](https://github.com/user-attachments/assets/69ed7f60-cf73-4c7e-ac24-a1122ec71a0d)\n\n### Select with touch   \nIf there is no touch for 10 seconds, it will end.   \nI borrowed the icon from [here](https://www.flaticon.com/packs/social-media-343).   \n![TouchIcon-1](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/e0aa7955-adad-4b33-93aa-a283585e2cf1)\n![TouchIcon-2](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/e909df95-1a02-4fa6-a973-b6baf24c9c20)\n\n### Save calibration data to NVS   \n\nWrite calibration data to NVS.   \nRead calibration data from NVS when starting the firmware and use it.   \nIf you use the same TFT, you don't need to calibrate again.   \nTo clear the calibration data recorded in NVS, execute the following command.   \n```\nidf.py erase_flash\n```\n\n![config-xpt2046-4](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/27bc35da-db6a-460d-ba8a-311d4bb72637)\n\n# SPI Clock speed   \nAccording to the datasheet, the minimum SPI clock cycles for each driver are as follows:   \nMaximum SPI clock frequency is the reciprocal of this.   \n|Driver|minimum SPI clock cycle|maximum SPI clock frequency|\n|:-:|:-:|:-:|\n|ILI9225|100ns|10MHz|\n|ILI9340|66ns|15MHz|\n|ILI9341|100ns|10MHz|\n|ST7735|66ns|15MHz|\n|ST7796|66ns|15MHz|\n\nThe SPI clock frequency used by this project is 10MHz.   \nHigher SPI clock frequencies can be specified using ```spi_clock_speed()```.   \nWhen using higher SPI clock frequencies, you need to be careful about the length of the wire cable.   \n```\n    int speed = 15000000; // 15MHz\n    spi_clock_speed(speed);\n    spi_master_init(\u0026dev, CONFIG_MOSI_GPIO, CONFIG_SCLK_GPIO, CONFIG_TFT_CS_GPIO, CONFIG_DC_GPIO,\n        CONFIG_RESET_GPIO, CONFIG_BL_GPIO, XPT_MISO_GPIO, XPT_CS_GPIO, XPT_IRQ_GPIO, XPT_SCLK_GPIO, XPT_MOSI_GPIO);\n    lcdInit(\u0026dev, model, CONFIG_WIDTH, CONFIG_HEIGHT, CONFIG_OFFSETX, CONFIG_OFFSETY);\n```\n\n# SPI BUS selection   \n![config-spi-bus](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/bdfd8436-31c7-435f-b21d-3d4b8e5350d3)\n\nThe ESP32 series has three SPI BUSs.   \nSPI1_HOST is used for communication with Flash memory.   \nYou can use SPI2_HOST and SPI3_HOST freely.   \nWhen you use SDSPI(SD Card via SPI), SDSPI uses SPI2_HOST BUS.   \nWhen using this module at the same time as SDSPI or other SPI device using SPI2_HOST, it needs to be changed to SPI3_HOST.   \nWhen you don't use SDSPI, both SPI2_HOST and SPI3_HOST will work.   \nPreviously it was called HSPI_HOST / VSPI_HOST, but now it is called SPI2_HOST / SPI3_HOST.   \n\n# Using Frame Buffer   \n![config_framebuffer](https://github.com/user-attachments/assets/21c3b031-0796-4227-b48e-47bb7537e3b8)\n\nWhen FrameBuffer is enabled, all output will be stored in the internal FrameBuffer and reflected to the device with ```lcdDrawFinish```.   \nIf you don't use FrameBuffer, ```lcdDrawFinish``` does nothing.   \nIf your main purpose is to display text, it's well worth using FrameBuffer.   \nIf your main purpose is to display images, there is no value in using FrameBuffer.   \nEnabling FrameBuffer does not make image display faster.   \nThis is because image analysis takes time.   \n\nThis option requires large RAM space.   \nIf your SoC has PSRAM, you can avoid running out of memory by enabling PSRAM.   \n![config-psram](https://github.com/user-attachments/assets/a71b320d-f5fb-4cd5-9466-f191b8704d40)\n\nBenchmarking using ESP32-S2@240 \u0026 2.4 inch TFT   \n\n||Disable Frame Buffer|Enable Frame Buffer|\n|:-:|:-:|:-:|\n|FillTest|1390|1450|\n|ColorBarTest|150|160|\n|ArrowTest|330|160|\n|LineTest|2670|180|\n|CircleTest|2390|190|\n|RoundRectTest|2430|180|\n|DirectionTest|500|160|\n|HorizontalTest|1110|170|\n|VerticalTest|1100|180|\n|FillRectTest|300|180|\n|ColorTest|370|170|\n|CodeTest|1760|180|\n|BMPTest|3000|2810|\n|JPEGTest|2760|2760|\n|PNGTest|2940|2960|\n|IconTest|740|870|\n\n# How to use this component in your project   \nCreate idf_component.yml in the same directory as main.c.   \n```\nYourProject --+-- CMakeLists.txt\n              +-- main --+-- main.c\n                         +-- CMakeLists.txt\n                         +-- idf_component.yml\n```\n\nContents of idf_component.yml.\n```\ndependencies:\n  nopnop2002/ili9340:\n    path: components/ili9340/\n    git: https://github.com/nopnop2002/esp-idf-ili9340.git\n```\n\nWhen you build a projects esp-idf will automaticly fetch repository to managed_components dir and link with your code.   \n```\nYourProject --+-- CMakeLists.txt\n              +-- main --+-- main.c\n              |          +-- CMakeLists.txt\n              |          +-- idf_component.yml\n              +-- managed_components ----- nopnop2002__ili9340\n```\n\n---\n\n# Using SPI TFT Adapter   \n\nI purchased this adapter on AliExpress.   \nIt comes with an ESP32 and costs $4.   \n![14pin-adapter-1](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/f73208ee-2c41-4541-bffd-e731e14cbff3)\n![14pin-adapter-2](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/a989ec43-41f4-4929-9352-6d148f1d6e60)\n\nHowever, this adapter's T_IRQ is not connected anywhere.   \nTo use the touch panel, you need to add a jumper.   \n![14pin-adapter-3](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/fba70ca5-1ab1-4f0c-8962-1b4efb195b35)\n\nAs a result, the GPIO will be:   \n|TFT||ESP32||\n|:-:|:-:|:-:|:-:|\n|VCC|--|3.3V||\n|GND|--|GND||\n|CS|--|GPIO15||\n|RES|--|GPIO04||\n|D/C|--|GPIO02||\n|MOSI|--|GPIO23||\n|SCK|--|GPIO18||\n|LED|--|3.3V|*1|\n|MISO|--|N/C||\n|T_CLK|--|GPIO18||\n|T_CS|--|GPIO05||\n|T_DIN|--|GPIO23||\n|T_OUT|--|GPIO19||\n|T_IRQ|--|GPIO21||\n\n(*1) BL_EN is directly connected to 3.3V, so it cannot control BackLight.   \n\nWhen not using the touch panel.   \n![config-14pin-adapter-1](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/b9d4d2a1-5e58-439f-b2ef-69a85e1810ae)\n\nWhen using the touch panel.   \n![config-14pin-adapter-2](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/5b7664e2-c1c1-4cfa-9979-59856ea37d42)\n\n![14pin-adapter-4](https://github.com/nopnop2002/esp-idf-ili9340/assets/6020549/9a098ae6-aa09-4ee5-9568-18f06260e4a9)\n\n\n---\n\n# Reference   \nA TFT shield like this can be used with ESP-IDF.   \n![TFT-Shield](https://user-images.githubusercontent.com/6020549/104253960-10a71380-54b9-11eb-8789-a12c2c769ab4.JPG)\n\nIt can be attached directly to this ESP32.   \n![tzt-d1-esp32s3](https://github.com/nopnop2002/esp-idf-parallel-tft/assets/6020549/ba6772f1-c8b7-4e7d-9d0a-0fb8fb8cbea5)\n\nhttps://github.com/nopnop2002/esp-idf-parallel-tft\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnopnop2002%2Fesp-idf-ili9340","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnopnop2002%2Fesp-idf-ili9340","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnopnop2002%2Fesp-idf-ili9340/lists"}