{"id":18434900,"url":"https://github.com/loboris/esp32_tft_library","last_synced_at":"2025-04-13T02:19:47.176Z","repository":{"id":45742576,"uuid":"91979913","full_name":"loboris/ESP32_TFT_library","owner":"loboris","description":"Full featured TFT library for ESP32 with demo application","archived":false,"fork":false,"pushed_at":"2024-06-19T01:46:09.000Z","size":25822,"stargazers_count":599,"open_issues_count":66,"forks_count":222,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-04-04T04:12:26.951Z","etag":null,"topics":["demo","display","esp-wrover-kit","esp32","ili9341","ili9488","library","tft"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loboris.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-05-21T18:49:05.000Z","updated_at":"2025-03-31T19:06:24.000Z","dependencies_parsed_at":"2023-02-13T01:46:07.221Z","dependency_job_id":"81628242-d22f-4a02-a8ff-c7b4b9658420","html_url":"https://github.com/loboris/ESP32_TFT_library","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/loboris%2FESP32_TFT_library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loboris%2FESP32_TFT_library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loboris%2FESP32_TFT_library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loboris%2FESP32_TFT_library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loboris","download_url":"https://codeload.github.com/loboris/ESP32_TFT_library/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654491,"owners_count":21140311,"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":["demo","display","esp-wrover-kit","esp32","ili9341","ili9488","library","tft"],"created_at":"2024-11-06T06:06:19.398Z","updated_at":"2025-04-13T02:19:47.156Z","avatar_url":"https://github.com/loboris.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n### TFT library for ESP32\n\n---\n\n**This library must be built with the latest esp-idf master branch and xtensa toolchain**\n\nIf you are using the esp-idf v2.1, checkout the commit *0518df81a6566820352dad7bf6c539995d41ad18*\n\n---\n\n#### Features\n\n* Full support for **ILI9341**, **ILI9488**, **ST7789V** and **ST7735** based TFT modules in 4-wire SPI mode. Support for other controllers will be added later\n* **18-bit (RGB)** color mode used\n* **SPI displays oriented SPI driver library** based on *spi-master* driver\n* Combined **DMA SPI** transfer mode and **direct SPI** for maximal speed\n* **Grayscale mode** can be selected during runtime which converts all colors to gray scale\n* SPI speeds up to **40 MHz** are tested and works without problems\n* **Demo application** included which demonstrates most of the library features\n\n\n* **Graphics drawing functions**:\n  * **TFT_drawPixel**  Draw pixel at given x,y coordinates\n  * **TFT_drawLine**  Draw line between two points\n  * **TFT_drawFastVLine**, **TFT_drawFastHLine**  Draw vertical or horizontal line of given lenght\n  * **TFT_drawLineByAngle**  Draw line on screen from (x,y) point at given angle\n  * **TFT_drawRect**, **TFT_fillRect**  Draw rectangle on screen or fill given rectangular screen region with color\n  * **TFT_drawRoundRect**, **TFT_fillRoundRect**  Draw rectangle on screen or fill given rectangular screen region with color with rounded corners\n  * **TFT_drawCircle**, **TFT_fillCircle**  Draw or fill circle on screen\n  * **TFT_drawEllipse**, **TFT_fillEllipse**  Draw or fill ellipse on screen\n  * **TFT_drawTriangel**, **TFT_fillTriangle**  Draw or fill triangle on screen\n  * **TFT_drawArc**  Draw circle arc on screen, from ~ to given angles, with given thickness. Can be outlined with different color\n  * **TFT_drawPolygon**  Draw poligon on screen with given number of sides (3~60). Can be outlined with different color and rotated by given angle.\n* **Fonts**:\n  * **fixed** width and proportional fonts are supported; 8 fonts embeded\n  * unlimited number of **fonts from file**\n  * **7-segment vector font** with variable width/height is included (only numbers and few characters)\n  * Proportional fonts can be used in fixed width mode.\n  * Related functions:\n    * **TFT_setFont**  Set current font from one of embeded fonts or font file\n    * **TFT_getfontsize**  Returns current font height \u0026 width in pixels.\n    * **TFT_getfontheight**  Returns current font height in pixels.\n    * **set_7seg_font_atrib**  Set atributes for 7 segment vector font\n    * **getFontCharacters**  Get all font's characters to buffer\n* **String write function**:\n  * **TFT_print**  Write text to display.\n    * Strings can be printed at **any angle**. Rotation of the displayed text depends on *font_ratate* variable (0~360)\n    * if *font_transparent* variable is set to 1, no background pixels will be printed\n    * If the text does not fit the screen/window width it will be clipped ( if *text_wrap=0* ), or continued on next line ( if *text_wrap=1* )\n    * Two special characters are allowed in strings: *\\r* CR (0x0D), clears the display to EOL, *\\n* LF (ox0A), continues to the new line, x=0\n    * Special values can be entered for X position:\n      * *CENTER*  centers the text\n      * *RIGHT*   right justifies the text horizontaly\n      * *LASTX*   continues from last X position; offset can be used: *LASTX+n*\n    * Special values can be entered for Y:\n      * *CENTER*  centers the text verticaly\n      * *BOTTOM*  bottom justifies the text\n      * *LASTY*   continues from last Y position; offset can be used: *LASTY+n*\n  * **TFT_getStringWidth** Returns the string width in pixels based on current font characteristics. Useful for positioning strings on the screen.\n  * **TFT_clearStringRect** Fills the rectangle occupied by string with current background color\n* **Images**:\n  * **TFT_jpg_image**  Decodes and displays JPG images\n    * Limits:\n      * Baseline only. Progressive and Lossless JPEG format are not supported.\n      * Image size: Up to 65520 x 65520 pixels\n      * Color space: YCbCr three components only. Gray scale image is not supported.\n      * Sampling factor: 4:4:4, 4:2:2 or 4:2:0.\n    * Can display the image **from file** or **memory buffer**\n    * Image can be **scaled** by factor 0 ~ 3  (1/1, 1/2, 1/4 or 1/8)\n    * Image is displayed from X,Y position on screen/window:\n      * X: image left position; constants CENTER \u0026 RIGHT can be used; *negative* value is accepted\n      * Y: image top position;  constants CENTER \u0026 BOTTOM can be used; *negative* value is accepted\n  * **TFT_bmp_image**  Decodes and displays BMP images\n    * Only uncompressed RGB 24-bit with no color space information BMP images can be displayed\n    * Can display the image **from file** or **memory buffer**\n    * Image can be **scaled** by factor 0 ~ 7; if scale\u003e0, image is scaled by factor 1/(scale+1)\n    * Image is displayed from X,Y position on screen/window:\n      * X: image left position; constants CENTER \u0026 RIGHT can be used; *negative* value is accepted\n      * Y: image top position;  constants CENTER \u0026 BOTTOM can be used; *negative* value is accepted\n* **Window functions**:\n  * Drawing on screen can be limited to rectangular *window*, smaller than the full display dimensions\n  * When defined, all graphics, text and image coordinates are translated to *window* coordinates\n  * Related functions\n    * **TFT_setclipwin**  Sets the *window* area coordinates\n    * **TFT_resetclipwin**  Reset the *window* to full screen dimensions\n    * **TFT_saveClipWin**  Save current *window* to temporary variable\n    * **TFT_restoreClipWin**  Restore current *window* from temporary variable\n    * **TFT_fillWindow**  Fill *window* area with color\n* **Touch screen** supported (for now only **XPT2046** controllers)\n  * **TFT_read_touch**  Detect if touched and return X,Y coordinates. **Raw** touch screen or **calibrated** values can be returned.\n    * calibrated coordinates are adjusted for screen orientation.\n* **Read from display memory** supported\n  * **TFT_readPixel**  Read pixel color value from display GRAM at given x,y coordinates.\n  * **TFT_readData**  Read color data from rectangular screen area\n* **Other display functions**:\n  * **TFT_fillScreen**  Fill the whole screen with color\n  * **TFT_setRotation**  Set screen rotation; PORTRAIT, PORTRAIT_FLIP, LANDSCAPE and LANDSCAPE_FLIP are supported\n  * **TFT_invertDisplay**  Set inverted/normal colors\n  * **TFT_compare_colors**  Compare two color structures\n  * **disp_select()**  Activate display's CS line\n  * **disp_deselect()**  Deactivate display's CS line\n  * **find_rd_speed()**  Find maximum spi clock for successful read from display RAM\n  * **TFT_display_init()**  Perform display initialization sequence. Sets orientation to landscape; clears the screen. SPI interface must already be setup, *tft_disp_type*, *_width*, *_height* variables must be set.\n  * **HSBtoRGB**  Converts the components of a color, as specified by the HSB model to an equivalent set of values for the default RGB model.\n  * **TFT_setGammaCurve()** Select one of 4 Gamma curves\n* **compile_font_file**  Function which compiles font c source file to font file which can be used in *TFT_setFont()* function to select external font. Created file have the same name as source file and extension *.fnt*\n\n\n* **Global wariables**\n  * **orientation**  current screen orientation\n  * **font_ratate**  current font rotate angle (0~395)\n  * **font_transparent**  if not 0 draw fonts transparent\n  * **font_forceFixed**  if not zero force drawing proportional fonts with fixed width\n  * **text_wrap**  if not 0 wrap long text to the new line, else clip\n  * **_fg**  current foreground color for fonts\n  * **_bg**  current background for non transparent fonts\n  * **dispWin** current display clip window\n  * **_angleOffset**  angle offset for arc, polygon and line by angle functions\n  * **image_debug**  print debug messages during image decode if set to 1\n  * **cfont**  Currently used font structure\n  * **TFT_X**  X position of the next character after TFT_print() function\n  * **TFT_Y**  Y position of the next character after TFT_print() function\n  * **tp_calx**  touch screen X calibration constant\n  * **tp_caly**  touch screen Y calibration constant\n  * **gray_scale**  convert all colors to gray scale if set to 1\n  * **max_rdclock**  current spi clock for reading from display RAM\n  * **_width** screen width (smaller dimension) in pixels\n  * **_height** screen height (larger dimension) in pixels\n  * **tft_disp_type**  current display type (DISP_TYPE_ILI9488 or DISP_TYPE_ILI9341)\n\n---\n\nFull functions **syntax and descriptions** can be found in *tft.h* and *tftspi.h* files.\n\nFull **demo application**, well documented, is included, please **analyze it** to learn how to use the library functions.\n\n---\n\n#### Connecting the display\n\n| ESP32 pin | Display module | Notes |\n| - | - | - |\n| Any output pin | MOSI | SPI input on Display module |\n| Any pin | MISO | SPI output from Display module, optional |\n| Any output pin | SCK | SPI clock input on Display module |\n| Any output pin | CS  | SPI CS input on Display module |\n| Any output pin | DC  | DC (data/command) input on Display module |\n| Any output pin | TCS  | Touch pannel CS input (if touch panel is used |\n| Any output pin | RST  | **optional**, reset input of the display module, if not used **pullup the reset input** to Vcc |\n| Any output pin | BL  | **optional**, backlight input of the display module, if not used connect to +3.3V (or +5V) |\n| GND | GND  | Power supply ground |\n| 3.3V or +5V | Vcc  | Power supply positive |\n\n**Make shure the display module has 3.3V compatible interface, if not you must use level shifter!**\n\n---\n\nTo run the demo, attach ILI9341, ILI9488 or ST7735 based display module to ESP32. Default pins used are:\n* mosi: 23\n* miso: 19\n*  sck: 18\n*   CS:  5 (display CS)\n*   DC: 26 (display DC)\n*  TCS: 25 (touch screen CS)\n\n---\n\n*To run the demo on* **ESP-WROWER-KIT v3** *select the following pin configuration:*\n*  mosi: 23\n*  miso: 25\n*   sck: 19\n*    CS: 22 (display CS)\n*    DC: 21 (display DC)\n*   TCS:  0 (touch screen CS), not used\n*   RST: 18 (display RESET)\n* BKLIT:  5 (Display Back light)\n\nAlso set **TFT_RGB_BGR** to 0x00 and **TFT_INVERT_ROTATION1** to 1 in *tftspi.h*\n\n**You can also select EXAMPLE_ESP_WROVER_KIT in menuconfig to automaticaly define correct configuration**\n\n---\n\n**If you want to use different pins, change them in** *tftspi.h*\n\n**if you want to use the touch screen functions, set** `#define USE_TOUCH 1` in *tftspi.h*\n\nUsing *make menuconfig* **select tick rate 1000** ( → Component config → FreeRTOS → Tick rate (Hz) ) to get more accurate timings\n\n---\n\n#### How to build\n\nConfigure your esp32 build environment as for **esp-idf examples**\n\nClone the repository\n\n`git clone https://github.com/loboris/ESP32_TFT_library.git`\n\nExecute menuconfig and configure your Serial flash config and other settings. Included *sdkconfig.defaults* sets some defaults to be used.\n\nNavigate to **TFT Display DEMO Configuration** and set **SPIFFS** options.\n\nSelect if you want to use **wifi** (recommended) to get the time from **NTP** server and set your WiFi SSID and password.\n\n`make menuconfig`\n\nMake and flash the example.\n\n`make all \u0026\u0026 make flash`\n\n---\n\n#### Prepare **SPIFFS** image\n\n*The demo uses some image and font files and it is necessary to flash the spiffs image*\n\n**To flash already prepared image to flash** execute:\n\n`make copyfs`\n\n---\n\nYou can also prepare different SFPIFFS **image** and flash it to ESP32. *This feature is only tested on Linux.*\n\nFiles to be included on spiffs are already in **components/spiffs_image/image/** directory. You can add or remove the files you want to include.\n\nThen execute:\n\n`make makefs`\n\nto create **spiffs image** in *build* directory **without flashing** to ESP32\n\nOr execute:\n\n`make flashfs`\n\nto create **spiffs image** in *build* directory and **flash** it to ESP32\n\n---\n\n\n---\n\n**Example output:**\n\n```\n\nI (0) cpu_start: App cpu up.\nI (312) heap_init: Initializing. RAM available for dynamic allocation:\nI (319) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM\nI (325) heap_init: At 3FFBB0B8 len 00024F48 (147 KiB): DRAM\nI (331) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM\nI (338) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM\nI (344) heap_init: At 40091F94 len 0000E06C (56 KiB): IRAM\nI (350) cpu_start: Pro cpu start user code\nI (144) cpu_start: Starting scheduler on PRO CPU.\nI (0) cpu_start: Starting scheduler on APP CPU.\n\n==============================\nTFT display DEMO, LoBo 09/2017\n==============================\n\nSPI: display device added to spi bus (2)\nSPI: attached display device, speed=8000000\nSPI: bus uses native pins: false\nSPI: display init...\nOK\nSPI: Changed speed to 26666666\n\n---------------------\nGraphics demo started\n---------------------\nI (2815) [TFT Demo]: Time is not set yet. Connecting to WiFi and getting time over NTP.\nI (2845) wifi: wifi firmware version: ee52423\nI (2846) wifi: config NVS flash: enabled\nI (2846) wifi: config nano formating: disabled\nI (2846) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE\nI (2856) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE\nI (2890) wifi: Init dynamic tx buffer num: 32\nI (2890) wifi: Init data frame dynamic rx buffer num: 32\nI (2890) wifi: Init management frame dynamic rx buffer num: 32\nI (2894) wifi: wifi driver task: 3ffc83d8, prio:23, stack:4096\nI (2899) wifi: Init static rx buffer num: 10\nI (2903) wifi: Init dynamic rx buffer num: 32\nI (2907) wifi: Init rx ampdu len mblock:7\nI (2911) wifi: Init lldesc rx ampdu entry mblock:4\nI (2916) wifi: wifi power manager task: 0x3ffcd844 prio: 21 stack: 2560\nI (2922) [TFT Demo]: Setting WiFi configuration SSID LoBoInternet...\nI (2951) phy: phy_version: 359.0, e79c19d, Aug 31 2017, 17:06:07, 0, 0\nI (2951) wifi: mode : sta (24:0a:c4:11:a4:0c)\nI (3073) wifi: n:11 0, o:1 0, ap:255 255, sta:11 0, prof:1\nI (3731) wifi: state: init -\u003e auth (b0)\nI (3734) wifi: state: auth -\u003e assoc (0)\nI (3738) wifi: state: assoc -\u003e run (10)\nI (3776) wifi: connected with LoBoInternet, channel 11\nI (5827) event: ip: 192.168.0.21, mask: 255.255.255.0, gw: 192.168.0.1\nI (5828) [TFT Demo]: Initializing SNTP\nI (6331) [TFT Demo]: System time is set.\nI (6331) wifi: state: run -\u003e init (0)\nI (6332) wifi: n:11 0, o:11 0, ap:255 255, sta:11 0, prof:1\nI (6344) wifi: flush txq\nI (6344) wifi: stop sw txq\nI (6344) wifi: lmac stop hw txq\nE (6344) wifi: esp_wifi_connect 836 wifi not start\n\n\nI (8441) [SPIFFS]: Registering SPIFFS file system\nI (8441) [SPIFFS]: Mounting SPIFFS files system\nI (8441) [SPIFFS]: Start address: 0x280000; Size 1024 KB\nI (8447) [SPIFFS]:   Work buffer: 2048 B\nI (8451) [SPIFFS]:    FDS buffer: 384 B\nI (8456) [SPIFFS]:    Cache size: 2048 B\nI (8500) [SPIFFS]: Mounted\n\n==========================================\nDisplay: ILI9488: PORTRAIT 240,320 Color\n\n     Clear screen time: 60 ms\nSend color buffer time: 228 us (240 pixels)\n       JPG Decode time: 287 ms\n    BMP time, scale: 5: 422 ms\n    BMP time, scale: 4: 431 ms\n    BMP time, scale: 3: 430 ms\n    BMP time, scale: 2: 434 ms\n    BMP time, scale: 1: 442 ms\n    BMP time, scale: 0: 335 ms\n\n==========================================\nDisplay: ILI9488: LANDSCAPE 320,240 Color\n\n     Clear screen time: 57 ms\nSend color buffer time: 301 us (320 pixels)\nI (126333) event: station ip lost\n       JPG Decode time: 286 ms\n    BMP time, scale: 5: 422 ms\n    BMP time, scale: 4: 431 ms\n    BMP time, scale: 3: 433 ms\n    BMP time, scale: 2: 435 ms\n    BMP time, scale: 1: 444 ms\n    BMP time, scale: 0: 260 ms\n\n==========================================\nDisplay: ILI9488: PORTRAIT FLIP 240,320 Color\n\n     Clear screen time: 60 ms\nSend color buffer time: 228 us (240 pixels)\n       JPG Decode time: 287 ms\n    BMP time, scale: 5: 420 ms\n    BMP time, scale: 4: 430 ms\n    BMP time, scale: 3: 429 ms\n    BMP time, scale: 2: 436 ms\n    BMP time, scale: 1: 446 ms\n    BMP time, scale: 0: 338 ms\n\n==========================================\nDisplay: ILI9488: PORTRAIT FLIP 240,320 Color\n\n     Clear screen time: 60 ms\nSend color buffer time: 228 us (240 pixels)\n       JPG Decode time: 287 ms\n    BMP time, scale: 5: 420 ms\n    BMP time, scale: 4: 430 ms\n    BMP time, scale: 3: 429 ms\n    BMP time, scale: 2: 436 ms\n    BMP time, scale: 1: 446 ms\n    BMP time, scale: 0: 338 ms\n\n\n```\n\n---\n\n### Tested on\n\nESP32-WROVER-KIT v3, ST7789V controller, 240x320\n![Tested on](https://raw.githubusercontent.com/loboris/MicroPython_ESP32_psRAM_LoBo/master/Documents/disp_wrower-kit.jpg)\n\n2.4\" 240x320 ILI9341 conroller with Touch panel from eBay\n![Tested on](https://raw.githubusercontent.com/loboris/MicroPython_ESP32_psRAM_LoBo/master/Documents/disp_ili9341.jpg)\n\n3.5\" 320x480 ILI9844 controller with Touch panel from BuyDisplay\n![Tested on](https://raw.githubusercontent.com/loboris/MicroPython_ESP32_psRAM_LoBo/master/Documents/disp_9488.jpg)\n\n1.8\" 128x160 ST7735 conroller from eBay\n![Tested on](https://raw.githubusercontent.com/loboris/MicroPython_ESP32_psRAM_LoBo/master/Documents/disp_7735.jpg)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floboris%2Fesp32_tft_library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floboris%2Fesp32_tft_library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floboris%2Fesp32_tft_library/lists"}