{"id":2081,"date":"2023-10-28T06:06:24","date_gmt":"2023-10-28T06:06:24","guid":{"rendered":"https:\/\/blog.embeddedexpert.io\/?p=2081"},"modified":"2023-10-28T06:06:29","modified_gmt":"2023-10-28T06:06:29","slug":"working-with-stm32f429-discovery-display-part-2-lcd-initializing","status":"publish","type":"post","link":"https:\/\/blog.embeddedexpert.io\/?p=2081","title":{"rendered":"Working with STM32F429-discovery Display Part 2: LCD Initializing"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"672\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/10\/F9093660-01-1.jpeg\" alt=\"\" class=\"wp-image-2082\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/10\/F9093660-01-1.jpeg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/10\/F9093660-01-1-300x197.jpeg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/10\/F9093660-01-1-768x504.jpeg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/10\/F9093660-01-1-750x492.jpeg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/10\/F9093660-01-1-400x263.jpeg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/10\/F9093660-01-1-250x164.jpeg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>In the previous guide (<a rel=\"noreferrer noopener\" href=\"https:\/\/blog.embeddedexpert.io\/?p=2077\" data-type=\"URL\" data-id=\"https:\/\/blog.embeddedexpert.io\/?p=2077\" target=\"_blank\">here<\/a>), we took a look at STM32F429 Discovery and it&#8217;s features and the environment has been setup. In this guide, we shall cover the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Delay initializing.<\/li><li>LCD initializing.<\/li><li>Support functions.<\/li><li>Code<\/li><li>Results.<\/li><\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Delay initializing:<\/h2>\n\n\n\n<p>We start off by creating new header file with name of delay.h.<\/p>\n\n\n\n<p>Within the header file, include the header guard:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#ifndef DELAY_H_\n#define DELAY_H_\n\n\n\n#endif \/* DELAY_H_ *\/<\/pre><\/div>\n\n\n\n<p>Include the following header file:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#include &quot;stdint.h&quot;<\/pre><\/div>\n\n\n\n<p>Declare the following functions:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">void delay_init(uint32_t freq);\nuint64_t millis();\nvoid delay(uint32_t time);<\/pre><\/div>\n\n\n\n<p>Hence, the entire header file as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#ifndef DELAY_H_\n#define DELAY_H_\n\n#include &quot;stdint.h&quot;\n\nvoid delay_init(uint32_t freq);\nuint64_t millis();\nvoid delay(uint32_t time);\n\n\n\n\n#endif \/* DELAY_H_ *\/<\/pre><\/div>\n\n\n\n<p>Now. Create new source code with name of delay.c.<\/p>\n\n\n\n<p>Within the source file:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#include &quot;delay.h&quot;\n#include &quot;stm32f4xx.h&quot;\n\n\n\n#define\tCTRL_ENABLE\t\t\t\t\t(1U&lt;&lt;0)\n#define CTRL_CLKSRC\t\t\t\t\t(1U&lt;&lt;2)\n#define CTRL_COUNTFLAG\t\t\t\t(1U&lt;&lt;16)\n#define CTRL_TICKINT\t\t\t\t(1U&lt;&lt;1)\n\n\nvolatile uint64_t mil;\n\nvoid delay_init(uint32_t freq)\n{\n\n\tSysTick-&gt;LOAD  = (freq\/1000) - 1;\n\n\t\/*Clear systick current value register *\/\n\tSysTick-&gt;VAL = 0;\n\n\t\/*Enable systick and select internal clk src*\/\n\tSysTick-&gt;CTRL = CTRL_ENABLE | CTRL_CLKSRC ;\n\n\t\/*Enable systick interrupt*\/\n\tSysTick-&gt;CTRL  |= CTRL_TICKINT;\n\n}\n\n\n\nuint64_t millis()\n\t{\n\t__disable_irq();\n\tuint64_t ml=mil;\n\t__enable_irq();\n\treturn ml;\n\t}\n\n\n\nvoid delay(uint32_t time)\n\t{\n\n\tuint64_t start=millis();\n\twhile((millis() - start) &lt; time);\n\t}\n\nvoid SysTick_Handler(void)\n{\n\tmil++;\n\n}\n<\/pre><\/div>\n\n\n\n<p>How to implement the systick interrupt, check <a href=\"https:\/\/blog.embeddedexpert.io\/?p=1644\" data-type=\"URL\" data-id=\"https:\/\/blog.embeddedexpert.io\/?p=1644\" target=\"_blank\" rel=\"noreferrer noopener\">this<\/a> guide.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Thats all for the delay part. Next, the LCD initialization.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. LCD Initializing:<\/h2>\n\n\n\n<p>Create new header file with name of ILI9341.h.<\/p>\n\n\n\n<p>Include the header guard as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#ifndef ILI9341_H_\n#define ILI9341_H_\n\n\n\n#endif<\/pre><\/div>\n\n\n\n<p>Within the header file, include the following header files:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\/\/List of includes\n#include &lt;stdbool.h&gt;\n#include &quot;delay.h&quot;\n#include &lt;stdint.h&gt;\n#include &lt;math.h&gt;<\/pre><\/div>\n\n\n\n<p>Now, we shall declare list of symbolics, we start off by the dimensions of the LCD as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\/\/LCD dimensions defines\n#define ILI9341_WIDTH       240\n#define ILI9341_HEIGHT      320<\/pre><\/div>\n\n\n\n<p>Total pixels:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#define ILI9341_PIXEL_COUNT\tILI9341_WIDTH * ILI9341_HEIGHT<\/pre><\/div>\n\n\n\n<p>List of LCD commands:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\/\/ILI9341 LCD commands\n#define ILI9341_RESET\t\t\t \t\t    0x01\n#define ILI9341_SLEEP_OUT\t\t  \t\t\t0x11\n#define ILI9341_GAMMA\t\t\t    \t\t0x26\n#define ILI9341_DISPLAY_OFF\t\t\t\t\t0x28\n#define ILI9341_DISPLAY_ON\t\t\t\t\t0x29\n#define ILI9341_COLUMN_ADDR\t\t\t\t\t0x2A\n#define ILI9341_PAGE_ADDR\t\t\t  \t\t0x2B\n#define ILI9341_GRAM\t\t\t\t    \t0x2C\n#define ILI9341_TEARING_OFF\t\t\t\t\t0x34\n#define ILI9341_TEARING_ON\t\t\t\t\t0x35\n#define ILI9341_DISPLAY_INVERSION\t\t\t0xb4\n#define ILI9341_MAC\t\t\t        \t\t0x36\n#define ILI9341_PIXEL_FORMAT    \t\t\t0x3A\n#define ILI9341_WDB\t\t\t    \t  \t\t0x51\n#define ILI9341_WCD\t\t\t\t      \t\t0x53\n#define ILI9341_RGB_INTERFACE   \t\t\t0xB0\n#define ILI9341_FRC\t\t\t\t\t    \t0xB1\n#define ILI9341_BPC\t\t\t\t\t    \t0xB5\n#define ILI9341_DFC\t\t\t\t \t    \t0xB6\n#define ILI9341_Entry_Mode_Set\t\t\t\t0xB7\n#define ILI9341_POWER1\t\t\t\t\t\t0xC0\n#define ILI9341_POWER2\t\t\t\t\t\t0xC1\n#define ILI9341_VCOM1\t\t\t\t\t\t0xC5\n#define ILI9341_VCOM2\t\t\t\t\t\t0xC7\n#define ILI9341_POWERA\t\t\t\t\t\t0xCB\n#define ILI9341_POWERB\t\t\t\t\t\t0xCF\n#define ILI9341_PGAMMA\t\t\t\t\t\t0xE0\n#define ILI9341_NGAMMA\t\t\t\t\t\t0xE1\n#define ILI9341_DTCA\t\t\t\t\t\t0xE8\n#define ILI9341_DTCB\t\t\t\t\t\t0xEA\n#define ILI9341_POWER_SEQ\t\t\t\t\t0xED\n#define ILI9341_3GAMMA_EN\t\t\t\t\t0xF2\n#define ILI9341_INTERFACE\t\t\t\t\t0xF6\n#define ILI9341_PRC\t\t\t\t   \t  \t\t0xF7\n#define ILI9341_VERTICAL_SCROLL \t\t\t0x33\n\n#define ILI9341_MEMCONTROL         \t0x36\n#define ILI9341_MADCTL_MY  \t\t\t0x80\n#define ILI9341_MADCTL_MX  \t\t\t0x40\n#define ILI9341_MADCTL_MV  \t\t\t0x20\n#define ILI9341_MADCTL_ML  \t\t\t0x10\n#define ILI9341_MADCTL_RGB \t\t\t0x00\n#define ILI9341_MADCTL_BGR \t\t\t0x08\n#define ILI9341_MADCTL_MH  \t\t\t0x04<\/pre><\/div>\n\n\n\n<p>List of colors:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\/\/List of colors\n#define COLOR_BLACK           0x0000  \n#define COLOR_NAVY            0x000F      \n#define COLOR_DGREEN          0x03E0     \n#define COLOR_DCYAN           0x03EF  \n#define COLOR_MAROON          0x7800 \n#define COLOR_PURPLE          0x780F\n#define COLOR_OLIVE           0x7BE0     \n#define COLOR_LGRAY           0xC618      \n#define COLOR_DGRAY           0x7BEF    \n#define COLOR_BLUE            0x001F    \n#define COLOR_BLUE2\t\t\t  0x051D\n#define COLOR_GREEN           0x07E0      \n#define COLOR_GREEN2\t\t  0xB723\n#define COLOR_GREEN3\t\t  0x8000\n#define COLOR_CYAN            0x07FF   \n#define COLOR_RED             0xF800    \n#define COLOR_MAGENTA         0xF81F    \n#define COLOR_YELLOW          0xFFE0   \n#define COLOR_WHITE           0xFFFF     \n#define COLOR_ORANGE          0xFD20     \n#define COLOR_GREENYELLOW     0xAFE5     \n#define COLOR_BROWN \t\t  0XBC40 \n#define COLOR_BRRED \t \t  0XFC07 <\/pre><\/div>\n\n\n\n<p>Required macros:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\/\/Functions defines Macros\n#define swap(a, b) { int16_t t = a; a = b; b = t; }\n#define min(a,b) (((a)&lt;(b))?(a):(b))<\/pre><\/div>\n\n\n\n<p>Font declarations:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">static \/\/Text simple font array (You can your own font)\nconst unsigned char Font[] = {\n\t0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x3E, 0x5B, 0x4F, 0x5B, 0x3E,\n\t0x3E, 0x6B, 0x4F, 0x6B, 0x3E,\n\t0x1C, 0x3E, 0x7C, 0x3E, 0x1C,\n\t0x18, 0x3C, 0x7E, 0x3C, 0x18,\n\t0x1C, 0x57, 0x7D, 0x57, 0x1C,\n\t0x1C, 0x5E, 0x7F, 0x5E, 0x1C,\n\t0x00, 0x18, 0x3C, 0x18, 0x00,\n\t0xFF, 0xE7, 0xC3, 0xE7, 0xFF,\n\t0x00, 0x18, 0x24, 0x18, 0x00,\n\t0xFF, 0xE7, 0xDB, 0xE7, 0xFF,\n\t0x30, 0x48, 0x3A, 0x06, 0x0E,\n\t0x26, 0x29, 0x79, 0x29, 0x26,\n\t0x40, 0x7F, 0x05, 0x05, 0x07,\n\t0x40, 0x7F, 0x05, 0x25, 0x3F,\n\t0x5A, 0x3C, 0xE7, 0x3C, 0x5A,\n\t0x7F, 0x3E, 0x1C, 0x1C, 0x08,\n\t0x08, 0x1C, 0x1C, 0x3E, 0x7F,\n\t0x14, 0x22, 0x7F, 0x22, 0x14,\n\t0x5F, 0x5F, 0x00, 0x5F, 0x5F,\n\t0x06, 0x09, 0x7F, 0x01, 0x7F,\n\t0x00, 0x66, 0x89, 0x95, 0x6A,\n\t0x60, 0x60, 0x60, 0x60, 0x60,\n\t0x94, 0xA2, 0xFF, 0xA2, 0x94,\n\t0x08, 0x04, 0x7E, 0x04, 0x08,\n\t0x10, 0x20, 0x7E, 0x20, 0x10,\n\t0x08, 0x08, 0x2A, 0x1C, 0x08,\n\t0x08, 0x1C, 0x2A, 0x08, 0x08,\n\t0x1E, 0x10, 0x10, 0x10, 0x10,\n\t0x0C, 0x1E, 0x0C, 0x1E, 0x0C,\n\t0x30, 0x38, 0x3E, 0x38, 0x30,\n\t0x06, 0x0E, 0x3E, 0x0E, 0x06,\n\t0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x5F, 0x00, 0x00,\n\t0x00, 0x07, 0x00, 0x07, 0x00,\n\t0x14, 0x7F, 0x14, 0x7F, 0x14,\n\t0x24, 0x2A, 0x7F, 0x2A, 0x12,\n\t0x23, 0x13, 0x08, 0x64, 0x62,\n\t0x36, 0x49, 0x56, 0x20, 0x50,\n\t0x00, 0x08, 0x07, 0x03, 0x00,\n\t0x00, 0x1C, 0x22, 0x41, 0x00,\n\t0x00, 0x41, 0x22, 0x1C, 0x00,\n\t0x2A, 0x1C, 0x7F, 0x1C, 0x2A,\n\t0x08, 0x08, 0x3E, 0x08, 0x08,\n\t0x00, 0x80, 0x70, 0x30, 0x00,\n\t0x08, 0x08, 0x08, 0x08, 0x08,\n\t0x00, 0x00, 0x60, 0x60, 0x00,\n\t0x20, 0x10, 0x08, 0x04, 0x02,\n\t0x3E, 0x51, 0x49, 0x45, 0x3E,\n\t0x00, 0x42, 0x7F, 0x40, 0x00,\n\t0x72, 0x49, 0x49, 0x49, 0x46,\n\t0x21, 0x41, 0x49, 0x4D, 0x33,\n\t0x18, 0x14, 0x12, 0x7F, 0x10,\n\t0x27, 0x45, 0x45, 0x45, 0x39,\n\t0x3C, 0x4A, 0x49, 0x49, 0x31,\n\t0x41, 0x21, 0x11, 0x09, 0x07,\n\t0x36, 0x49, 0x49, 0x49, 0x36,\n\t0x46, 0x49, 0x49, 0x29, 0x1E,\n\t0x00, 0x00, 0x14, 0x00, 0x00,\n\t0x00, 0x40, 0x34, 0x00, 0x00,\n\t0x00, 0x08, 0x14, 0x22, 0x41,\n\t0x14, 0x14, 0x14, 0x14, 0x14,\n\t0x00, 0x41, 0x22, 0x14, 0x08,\n\t0x02, 0x01, 0x59, 0x09, 0x06,\n\t0x3E, 0x41, 0x5D, 0x59, 0x4E,\n\t0x7C, 0x12, 0x11, 0x12, 0x7C,\n\t0x7F, 0x49, 0x49, 0x49, 0x36,\n\t0x3E, 0x41, 0x41, 0x41, 0x22,\n\t0x7F, 0x41, 0x41, 0x41, 0x3E,\n\t0x7F, 0x49, 0x49, 0x49, 0x41,\n\t0x7F, 0x09, 0x09, 0x09, 0x01,\n\t0x3E, 0x41, 0x41, 0x51, 0x73,\n\t0x7F, 0x08, 0x08, 0x08, 0x7F,\n\t0x00, 0x41, 0x7F, 0x41, 0x00,\n\t0x20, 0x40, 0x41, 0x3F, 0x01,\n\t0x7F, 0x08, 0x14, 0x22, 0x41,\n\t0x7F, 0x40, 0x40, 0x40, 0x40,\n\t0x7F, 0x02, 0x1C, 0x02, 0x7F,\n\t0x7F, 0x04, 0x08, 0x10, 0x7F,\n\t0x3E, 0x41, 0x41, 0x41, 0x3E,\n\t0x7F, 0x09, 0x09, 0x09, 0x06,\n\t0x3E, 0x41, 0x51, 0x21, 0x5E,\n\t0x7F, 0x09, 0x19, 0x29, 0x46,\n\t0x26, 0x49, 0x49, 0x49, 0x32,\n\t0x03, 0x01, 0x7F, 0x01, 0x03,\n\t0x3F, 0x40, 0x40, 0x40, 0x3F,\n\t0x1F, 0x20, 0x40, 0x20, 0x1F,\n\t0x3F, 0x40, 0x38, 0x40, 0x3F,\n\t0x63, 0x14, 0x08, 0x14, 0x63,\n\t0x03, 0x04, 0x78, 0x04, 0x03,\n\t0x61, 0x59, 0x49, 0x4D, 0x43,\n\t0x00, 0x7F, 0x41, 0x41, 0x41,\n\t0x02, 0x04, 0x08, 0x10, 0x20,\n\t0x00, 0x41, 0x41, 0x41, 0x7F,\n\t0x04, 0x02, 0x01, 0x02, 0x04,\n\t0x40, 0x40, 0x40, 0x40, 0x40,\n\t0x00, 0x03, 0x07, 0x08, 0x00,\n\t0x20, 0x54, 0x54, 0x78, 0x40,\n\t0x7F, 0x28, 0x44, 0x44, 0x38,\n\t0x38, 0x44, 0x44, 0x44, 0x28,\n\t0x38, 0x44, 0x44, 0x28, 0x7F,\n\t0x38, 0x54, 0x54, 0x54, 0x18,\n\t0x00, 0x08, 0x7E, 0x09, 0x02,\n\t0x18, 0xA4, 0xA4, 0x9C, 0x78,\n\t0x7F, 0x08, 0x04, 0x04, 0x78,\n\t0x00, 0x44, 0x7D, 0x40, 0x00,\n\t0x20, 0x40, 0x40, 0x3D, 0x00,\n\t0x7F, 0x10, 0x28, 0x44, 0x00,\n\t0x00, 0x41, 0x7F, 0x40, 0x00,\n\t0x7C, 0x04, 0x78, 0x04, 0x78,\n\t0x7C, 0x08, 0x04, 0x04, 0x78,\n\t0x38, 0x44, 0x44, 0x44, 0x38,\n\t0xFC, 0x18, 0x24, 0x24, 0x18,\n\t0x18, 0x24, 0x24, 0x18, 0xFC,\n\t0x7C, 0x08, 0x04, 0x04, 0x08,\n\t0x48, 0x54, 0x54, 0x54, 0x24,\n\t0x04, 0x04, 0x3F, 0x44, 0x24,\n\t0x3C, 0x40, 0x40, 0x20, 0x7C,\n\t0x1C, 0x20, 0x40, 0x20, 0x1C,\n\t0x3C, 0x40, 0x30, 0x40, 0x3C,\n\t0x44, 0x28, 0x10, 0x28, 0x44,\n\t0x4C, 0x90, 0x90, 0x90, 0x7C,\n\t0x44, 0x64, 0x54, 0x4C, 0x44,\n\t0x00, 0x08, 0x36, 0x41, 0x00,\n\t0x00, 0x00, 0x77, 0x00, 0x00,\n\t0x00, 0x41, 0x36, 0x08, 0x00,\n\t0x02, 0x01, 0x02, 0x04, 0x02,\n\t0x3C, 0x26, 0x23, 0x26, 0x3C,\n\t0x1E, 0xA1, 0xA1, 0x61, 0x12,\n\t0x3A, 0x40, 0x40, 0x20, 0x7A,\n\t0x38, 0x54, 0x54, 0x55, 0x59,\n\t0x21, 0x55, 0x55, 0x79, 0x41,\n\t0x22, 0x54, 0x54, 0x78, 0x42,\n\t0x21, 0x55, 0x54, 0x78, 0x40,\n\t0x20, 0x54, 0x55, 0x79, 0x40,\n\t0x0C, 0x1E, 0x52, 0x72, 0x12,\n\t0x39, 0x55, 0x55, 0x55, 0x59,\n\t0x39, 0x54, 0x54, 0x54, 0x59,\n\t0x39, 0x55, 0x54, 0x54, 0x58,\n\t0x00, 0x00, 0x45, 0x7C, 0x41,\n\t0x00, 0x02, 0x45, 0x7D, 0x42,\n\t0x00, 0x01, 0x45, 0x7C, 0x40,\n\t0x7D, 0x12, 0x11, 0x12, 0x7D,\n\t0xF0, 0x28, 0x25, 0x28, 0xF0,\n\t0x7C, 0x54, 0x55, 0x45, 0x00,\n\t0x20, 0x54, 0x54, 0x7C, 0x54,\n\t0x7C, 0x0A, 0x09, 0x7F, 0x49,\n\t0x32, 0x49, 0x49, 0x49, 0x32,\n\t0x3A, 0x44, 0x44, 0x44, 0x3A, \n\t0x32, 0x4A, 0x48, 0x48, 0x30,\n\t0x3A, 0x41, 0x41, 0x21, 0x7A,\n\t0x3A, 0x42, 0x40, 0x20, 0x78,\n\t0x00, 0x9D, 0xA0, 0xA0, 0x7D,\n\t0x3D, 0x42, 0x42, 0x42, 0x3D, \n\t0x3D, 0x40, 0x40, 0x40, 0x3D,\n\t0x3C, 0x24, 0xFF, 0x24, 0x24,\n\t0x48, 0x7E, 0x49, 0x43, 0x66,\n\t0x2B, 0x2F, 0xFC, 0x2F, 0x2B,\n\t0xFF, 0x09, 0x29, 0xF6, 0x20,\n\t0xC0, 0x88, 0x7E, 0x09, 0x03,\n\t0x20, 0x54, 0x54, 0x79, 0x41,\n\t0x00, 0x00, 0x44, 0x7D, 0x41,\n\t0x30, 0x48, 0x48, 0x4A, 0x32,\n\t0x38, 0x40, 0x40, 0x22, 0x7A,\n\t0x00, 0x7A, 0x0A, 0x0A, 0x72,\n\t0x7D, 0x0D, 0x19, 0x31, 0x7D,\n\t0x26, 0x29, 0x29, 0x2F, 0x28,\n\t0x26, 0x29, 0x29, 0x29, 0x26,\n\t0x30, 0x48, 0x4D, 0x40, 0x20,\n\t0x38, 0x08, 0x08, 0x08, 0x08,\n\t0x08, 0x08, 0x08, 0x08, 0x38,\n\t0x2F, 0x10, 0xC8, 0xAC, 0xBA,\n\t0x2F, 0x10, 0x28, 0x34, 0xFA,\n\t0x00, 0x00, 0x7B, 0x00, 0x00,\n\t0x08, 0x14, 0x2A, 0x14, 0x22,\n\t0x22, 0x14, 0x2A, 0x14, 0x08,\n\t0x55, 0x00, 0x55, 0x00, 0x55, \n\t0xAA, 0x55, 0xAA, 0x55, 0xAA, \n\t0xFF, 0x55, 0xFF, 0x55, 0xFF, \n\t0x00, 0x00, 0x00, 0xFF, 0x00,\n\t0x10, 0x10, 0x10, 0xFF, 0x00,\n\t0x14, 0x14, 0x14, 0xFF, 0x00,\n\t0x10, 0x10, 0xFF, 0x00, 0xFF,\n\t0x10, 0x10, 0xF0, 0x10, 0xF0,\n\t0x14, 0x14, 0x14, 0xFC, 0x00,\n\t0x14, 0x14, 0xF7, 0x00, 0xFF,\n\t0x00, 0x00, 0xFF, 0x00, 0xFF,\n\t0x14, 0x14, 0xF4, 0x04, 0xFC,\n\t0x14, 0x14, 0x17, 0x10, 0x1F,\n\t0x10, 0x10, 0x1F, 0x10, 0x1F,\n\t0x14, 0x14, 0x14, 0x1F, 0x00,\n\t0x10, 0x10, 0x10, 0xF0, 0x00,\n\t0x00, 0x00, 0x00, 0x1F, 0x10,\n\t0x10, 0x10, 0x10, 0x1F, 0x10,\n\t0x10, 0x10, 0x10, 0xF0, 0x10,\n\t0x00, 0x00, 0x00, 0xFF, 0x10,\n\t0x10, 0x10, 0x10, 0x10, 0x10,\n\t0x10, 0x10, 0x10, 0xFF, 0x10,\n\t0x00, 0x00, 0x00, 0xFF, 0x14,\n\t0x00, 0x00, 0xFF, 0x00, 0xFF,\n\t0x00, 0x00, 0x1F, 0x10, 0x17,\n\t0x00, 0x00, 0xFC, 0x04, 0xF4,\n\t0x14, 0x14, 0x17, 0x10, 0x17,\n\t0x14, 0x14, 0xF4, 0x04, 0xF4,\n\t0x00, 0x00, 0xFF, 0x00, 0xF7,\n\t0x14, 0x14, 0x14, 0x14, 0x14,\n\t0x14, 0x14, 0xF7, 0x00, 0xF7,\n\t0x14, 0x14, 0x14, 0x17, 0x14,\n\t0x10, 0x10, 0x1F, 0x10, 0x1F,\n\t0x14, 0x14, 0x14, 0xF4, 0x14,\n\t0x10, 0x10, 0xF0, 0x10, 0xF0,\n\t0x00, 0x00, 0x1F, 0x10, 0x1F,\n\t0x00, 0x00, 0x00, 0x1F, 0x14,\n\t0x00, 0x00, 0x00, 0xFC, 0x14,\n\t0x00, 0x00, 0xF0, 0x10, 0xF0,\n\t0x10, 0x10, 0xFF, 0x10, 0xFF,\n\t0x14, 0x14, 0x14, 0xFF, 0x14,\n\t0x10, 0x10, 0x10, 0x1F, 0x00,\n\t0x00, 0x00, 0x00, 0xF0, 0x10,\n\t0xFF, 0xFF, 0xFF, 0xFF, 0xFF,\n\t0xF0, 0xF0, 0xF0, 0xF0, 0xF0,\n\t0xFF, 0xFF, 0xFF, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0xFF, 0xFF,\n\t0x0F, 0x0F, 0x0F, 0x0F, 0x0F,\n\t0x38, 0x44, 0x44, 0x38, 0x44,\n\t0xFC, 0x4A, 0x4A, 0x4A, 0x34, \n\t0x7E, 0x02, 0x02, 0x06, 0x06,\n\t0x02, 0x7E, 0x02, 0x7E, 0x02,\n\t0x63, 0x55, 0x49, 0x41, 0x63,\n\t0x38, 0x44, 0x44, 0x3C, 0x04,\n\t0x40, 0x7E, 0x20, 0x1E, 0x20,\n\t0x06, 0x02, 0x7E, 0x02, 0x02,\n\t0x99, 0xA5, 0xE7, 0xA5, 0x99,\n\t0x1C, 0x2A, 0x49, 0x2A, 0x1C,\n\t0x4C, 0x72, 0x01, 0x72, 0x4C,\n\t0x30, 0x4A, 0x4D, 0x4D, 0x30,\n\t0x30, 0x48, 0x78, 0x48, 0x30,\n\t0xBC, 0x62, 0x5A, 0x46, 0x3D,\n\t0x3E, 0x49, 0x49, 0x49, 0x00,\n\t0x7E, 0x01, 0x01, 0x01, 0x7E,\n\t0x2A, 0x2A, 0x2A, 0x2A, 0x2A,\n\t0x44, 0x44, 0x5F, 0x44, 0x44,\n\t0x40, 0x51, 0x4A, 0x44, 0x40,\n\t0x40, 0x44, 0x4A, 0x51, 0x40,\n\t0x00, 0x00, 0xFF, 0x01, 0x03,\n\t0xE0, 0x80, 0xFF, 0x00, 0x00,\n\t0x08, 0x08, 0x6B, 0x6B, 0x08,\n\t0x36, 0x12, 0x36, 0x24, 0x36,\n\t0x06, 0x0F, 0x09, 0x0F, 0x06,\n\t0x00, 0x00, 0x18, 0x18, 0x00,\n\t0x00, 0x00, 0x10, 0x10, 0x00,\n\t0x30, 0x40, 0xFF, 0x01, 0x01,\n\t0x00, 0x1F, 0x01, 0x01, 0x1E,\n\t0x00, 0x19, 0x1D, 0x17, 0x12,\n\t0x00, 0x3C, 0x3C, 0x3C, 0x3C,\n\t0x00, 0x00, 0x00, 0x00, 0x00  \n};<\/pre><\/div>\n\n\n\n<p>Functions declarations:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\n\/\/***** Functions prototypes *****\/\/\n\/\/1. Write Command to LCD\nvoid ILI9341_SendCommand(uint8_t com);\n\/\/2. Write data to LCD\nvoid ILI9341_SendData(uint8_t data);\n\/\/2.2 Write multiple\/DMA\nvoid ILI9341_SendData_Multi(uint16_t Colordata, uint32_t size);\n\n\n\/\/3. Set cursor position\nvoid ILI9341_SetCursorPosition(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);\n\/\/4. Initialise function\nvoid ILI9341_Init();\n\/\/5. Write data to a single pixel\nvoid ILI9341_DrawPixel(uint16_t x, uint16_t y, uint16_t color); \/\/Draw single pixel to ILI9341\n\/\/6. Fill the entire screen with a background color\nvoid ILI9341_Fill(uint16_t color); \/\/Fill entire ILI9341 with color\n\/\/7. Rectangle drawing functions\nvoid ILI9341_Fill_Rect(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, uint16_t color);\n\/\/8. Circle drawing functions\nvoid ILI9341_drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);\nstatic void drawCircleHelper( int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color);\nstatic void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color);\nvoid ILI9341_fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);\n\/\/9. Line drawing functions\nvoid ILI9341_drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);\nvoid ILI9341_drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);\nvoid ILI9341_drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);\n\/\/10. Triangle drawing\nvoid ILI9341_drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);\nvoid ILI9341_fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);\n\/\/11. Text printing functions\n\/\/void ILI9341_drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size);\n\/\/void ILI9341_printText(char text[], int16_t x, int16_t y, uint16_t color, uint16_t bg, uint8_t size);\n\/\/12. Image print (RGB 565, 2 bytes per pixel)\nvoid ILI9341_printImage(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint8_t *data, uint32_t size);\n\/\/13. Set screen rotation\nvoid ILI9341_setRotation(uint8_t rotate);\n\/\/14. Get screen rotation\nuint8_t ILI9341_getRotation(void);\n\/\/draw a single character \nvoid ILI9341_DrawChar(int16_t x, int16_t y, char c, int16_t textColor, int16_t bgColor, uint8_t size);\n\/\/sensd 16-bit color data\nuint16_t ILI9341_Color565(uint8_t r, uint8_t g, uint8_t b);\n\/\/write a string to the lcd \nuint32_t ILI9341_DrawString(uint16_t x, uint16_t y, char *pt, int16_t textColor,int16_t BG,uint16_t size);<\/pre><\/div>\n\n\n\n<p>Hence, the entire header file as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#ifndef ILI9341_H_\n#define ILI9341_H_\n\n\/\/List of includes\n#include &lt;stdbool.h&gt;\n#include &quot;delay.h&quot;\n#include &lt;stdint.h&gt;\n#include &lt;math.h&gt;\n\n\n\/\/LCD dimensions defines\n#define ILI9341_WIDTH       240\n#define ILI9341_HEIGHT      320\n\n\n#define ILI9341_PIXEL_COUNT\tILI9341_WIDTH * ILI9341_HEIGHT\n\n\n\/\/ILI9341 LCD commands\n#define ILI9341_RESET\t\t\t \t\t    0x01\n#define ILI9341_SLEEP_OUT\t\t  \t\t\t0x11\n#define ILI9341_GAMMA\t\t\t    \t\t0x26\n#define ILI9341_DISPLAY_OFF\t\t\t\t\t0x28\n#define ILI9341_DISPLAY_ON\t\t\t\t\t0x29\n#define ILI9341_COLUMN_ADDR\t\t\t\t\t0x2A\n#define ILI9341_PAGE_ADDR\t\t\t  \t\t0x2B\n#define ILI9341_GRAM\t\t\t\t    \t0x2C\n#define ILI9341_TEARING_OFF\t\t\t\t\t0x34\n#define ILI9341_TEARING_ON\t\t\t\t\t0x35\n#define ILI9341_DISPLAY_INVERSION\t\t\t0xb4\n#define ILI9341_MAC\t\t\t        \t\t0x36\n#define ILI9341_PIXEL_FORMAT    \t\t\t0x3A\n#define ILI9341_WDB\t\t\t    \t  \t\t0x51\n#define ILI9341_WCD\t\t\t\t      \t\t0x53\n#define ILI9341_RGB_INTERFACE   \t\t\t0xB0\n#define ILI9341_FRC\t\t\t\t\t    \t0xB1\n#define ILI9341_BPC\t\t\t\t\t    \t0xB5\n#define ILI9341_DFC\t\t\t\t \t    \t0xB6\n#define ILI9341_Entry_Mode_Set\t\t\t\t0xB7\n#define ILI9341_POWER1\t\t\t\t\t\t0xC0\n#define ILI9341_POWER2\t\t\t\t\t\t0xC1\n#define ILI9341_VCOM1\t\t\t\t\t\t0xC5\n#define ILI9341_VCOM2\t\t\t\t\t\t0xC7\n#define ILI9341_POWERA\t\t\t\t\t\t0xCB\n#define ILI9341_POWERB\t\t\t\t\t\t0xCF\n#define ILI9341_PGAMMA\t\t\t\t\t\t0xE0\n#define ILI9341_NGAMMA\t\t\t\t\t\t0xE1\n#define ILI9341_DTCA\t\t\t\t\t\t0xE8\n#define ILI9341_DTCB\t\t\t\t\t\t0xEA\n#define ILI9341_POWER_SEQ\t\t\t\t\t0xED\n#define ILI9341_3GAMMA_EN\t\t\t\t\t0xF2\n#define ILI9341_INTERFACE\t\t\t\t\t0xF6\n#define ILI9341_PRC\t\t\t\t   \t  \t\t0xF7\n#define ILI9341_VERTICAL_SCROLL \t\t\t0x33\n\n#define ILI9341_MEMCONTROL         \t0x36\n#define ILI9341_MADCTL_MY  \t\t\t0x80\n#define ILI9341_MADCTL_MX  \t\t\t0x40\n#define ILI9341_MADCTL_MV  \t\t\t0x20\n#define ILI9341_MADCTL_ML  \t\t\t0x10\n#define ILI9341_MADCTL_RGB \t\t\t0x00\n#define ILI9341_MADCTL_BGR \t\t\t0x08\n#define ILI9341_MADCTL_MH  \t\t\t0x04\n\n\/\/List of colors\n#define COLOR_BLACK           0x0000  \n#define COLOR_NAVY            0x000F      \n#define COLOR_DGREEN          0x03E0     \n#define COLOR_DCYAN           0x03EF  \n#define COLOR_MAROON          0x7800 \n#define COLOR_PURPLE          0x780F\n#define COLOR_OLIVE           0x7BE0     \n#define COLOR_LGRAY           0xC618      \n#define COLOR_DGRAY           0x7BEF    \n#define COLOR_BLUE            0x001F    \n#define COLOR_BLUE2\t\t\t  0x051D\n#define COLOR_GREEN           0x07E0      \n#define COLOR_GREEN2\t\t  0xB723\n#define COLOR_GREEN3\t\t  0x8000\n#define COLOR_CYAN            0x07FF   \n#define COLOR_RED             0xF800    \n#define COLOR_MAGENTA         0xF81F    \n#define COLOR_YELLOW          0xFFE0   \n#define COLOR_WHITE           0xFFFF     \n#define COLOR_ORANGE          0xFD20     \n#define COLOR_GREENYELLOW     0xAFE5     \n#define COLOR_BROWN \t\t  0XBC40\n#define COLOR_BRRED \t \t  0XFC07\n\n\/\/Functions defines Macros\n#define swap(a, b) { int16_t t = a; a = b; b = t; }\n#define min(a,b) (((a)&lt;(b))?(a):(b))\n\n\/\/font\n\nstatic \/\/Text simple font array (You can your own font)\nconst unsigned char Font[] = {\n\t0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x3E, 0x5B, 0x4F, 0x5B, 0x3E,\n\t0x3E, 0x6B, 0x4F, 0x6B, 0x3E,\n\t0x1C, 0x3E, 0x7C, 0x3E, 0x1C,\n\t0x18, 0x3C, 0x7E, 0x3C, 0x18,\n\t0x1C, 0x57, 0x7D, 0x57, 0x1C,\n\t0x1C, 0x5E, 0x7F, 0x5E, 0x1C,\n\t0x00, 0x18, 0x3C, 0x18, 0x00,\n\t0xFF, 0xE7, 0xC3, 0xE7, 0xFF,\n\t0x00, 0x18, 0x24, 0x18, 0x00,\n\t0xFF, 0xE7, 0xDB, 0xE7, 0xFF,\n\t0x30, 0x48, 0x3A, 0x06, 0x0E,\n\t0x26, 0x29, 0x79, 0x29, 0x26,\n\t0x40, 0x7F, 0x05, 0x05, 0x07,\n\t0x40, 0x7F, 0x05, 0x25, 0x3F,\n\t0x5A, 0x3C, 0xE7, 0x3C, 0x5A,\n\t0x7F, 0x3E, 0x1C, 0x1C, 0x08,\n\t0x08, 0x1C, 0x1C, 0x3E, 0x7F,\n\t0x14, 0x22, 0x7F, 0x22, 0x14,\n\t0x5F, 0x5F, 0x00, 0x5F, 0x5F,\n\t0x06, 0x09, 0x7F, 0x01, 0x7F,\n\t0x00, 0x66, 0x89, 0x95, 0x6A,\n\t0x60, 0x60, 0x60, 0x60, 0x60,\n\t0x94, 0xA2, 0xFF, 0xA2, 0x94,\n\t0x08, 0x04, 0x7E, 0x04, 0x08,\n\t0x10, 0x20, 0x7E, 0x20, 0x10,\n\t0x08, 0x08, 0x2A, 0x1C, 0x08,\n\t0x08, 0x1C, 0x2A, 0x08, 0x08,\n\t0x1E, 0x10, 0x10, 0x10, 0x10,\n\t0x0C, 0x1E, 0x0C, 0x1E, 0x0C,\n\t0x30, 0x38, 0x3E, 0x38, 0x30,\n\t0x06, 0x0E, 0x3E, 0x0E, 0x06,\n\t0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x5F, 0x00, 0x00,\n\t0x00, 0x07, 0x00, 0x07, 0x00,\n\t0x14, 0x7F, 0x14, 0x7F, 0x14,\n\t0x24, 0x2A, 0x7F, 0x2A, 0x12,\n\t0x23, 0x13, 0x08, 0x64, 0x62,\n\t0x36, 0x49, 0x56, 0x20, 0x50,\n\t0x00, 0x08, 0x07, 0x03, 0x00,\n\t0x00, 0x1C, 0x22, 0x41, 0x00,\n\t0x00, 0x41, 0x22, 0x1C, 0x00,\n\t0x2A, 0x1C, 0x7F, 0x1C, 0x2A,\n\t0x08, 0x08, 0x3E, 0x08, 0x08,\n\t0x00, 0x80, 0x70, 0x30, 0x00,\n\t0x08, 0x08, 0x08, 0x08, 0x08,\n\t0x00, 0x00, 0x60, 0x60, 0x00,\n\t0x20, 0x10, 0x08, 0x04, 0x02,\n\t0x3E, 0x51, 0x49, 0x45, 0x3E,\n\t0x00, 0x42, 0x7F, 0x40, 0x00,\n\t0x72, 0x49, 0x49, 0x49, 0x46,\n\t0x21, 0x41, 0x49, 0x4D, 0x33,\n\t0x18, 0x14, 0x12, 0x7F, 0x10,\n\t0x27, 0x45, 0x45, 0x45, 0x39,\n\t0x3C, 0x4A, 0x49, 0x49, 0x31,\n\t0x41, 0x21, 0x11, 0x09, 0x07,\n\t0x36, 0x49, 0x49, 0x49, 0x36,\n\t0x46, 0x49, 0x49, 0x29, 0x1E,\n\t0x00, 0x00, 0x14, 0x00, 0x00,\n\t0x00, 0x40, 0x34, 0x00, 0x00,\n\t0x00, 0x08, 0x14, 0x22, 0x41,\n\t0x14, 0x14, 0x14, 0x14, 0x14,\n\t0x00, 0x41, 0x22, 0x14, 0x08,\n\t0x02, 0x01, 0x59, 0x09, 0x06,\n\t0x3E, 0x41, 0x5D, 0x59, 0x4E,\n\t0x7C, 0x12, 0x11, 0x12, 0x7C,\n\t0x7F, 0x49, 0x49, 0x49, 0x36,\n\t0x3E, 0x41, 0x41, 0x41, 0x22,\n\t0x7F, 0x41, 0x41, 0x41, 0x3E,\n\t0x7F, 0x49, 0x49, 0x49, 0x41,\n\t0x7F, 0x09, 0x09, 0x09, 0x01,\n\t0x3E, 0x41, 0x41, 0x51, 0x73,\n\t0x7F, 0x08, 0x08, 0x08, 0x7F,\n\t0x00, 0x41, 0x7F, 0x41, 0x00,\n\t0x20, 0x40, 0x41, 0x3F, 0x01,\n\t0x7F, 0x08, 0x14, 0x22, 0x41,\n\t0x7F, 0x40, 0x40, 0x40, 0x40,\n\t0x7F, 0x02, 0x1C, 0x02, 0x7F,\n\t0x7F, 0x04, 0x08, 0x10, 0x7F,\n\t0x3E, 0x41, 0x41, 0x41, 0x3E,\n\t0x7F, 0x09, 0x09, 0x09, 0x06,\n\t0x3E, 0x41, 0x51, 0x21, 0x5E,\n\t0x7F, 0x09, 0x19, 0x29, 0x46,\n\t0x26, 0x49, 0x49, 0x49, 0x32,\n\t0x03, 0x01, 0x7F, 0x01, 0x03,\n\t0x3F, 0x40, 0x40, 0x40, 0x3F,\n\t0x1F, 0x20, 0x40, 0x20, 0x1F,\n\t0x3F, 0x40, 0x38, 0x40, 0x3F,\n\t0x63, 0x14, 0x08, 0x14, 0x63,\n\t0x03, 0x04, 0x78, 0x04, 0x03,\n\t0x61, 0x59, 0x49, 0x4D, 0x43,\n\t0x00, 0x7F, 0x41, 0x41, 0x41,\n\t0x02, 0x04, 0x08, 0x10, 0x20,\n\t0x00, 0x41, 0x41, 0x41, 0x7F,\n\t0x04, 0x02, 0x01, 0x02, 0x04,\n\t0x40, 0x40, 0x40, 0x40, 0x40,\n\t0x00, 0x03, 0x07, 0x08, 0x00,\n\t0x20, 0x54, 0x54, 0x78, 0x40,\n\t0x7F, 0x28, 0x44, 0x44, 0x38,\n\t0x38, 0x44, 0x44, 0x44, 0x28,\n\t0x38, 0x44, 0x44, 0x28, 0x7F,\n\t0x38, 0x54, 0x54, 0x54, 0x18,\n\t0x00, 0x08, 0x7E, 0x09, 0x02,\n\t0x18, 0xA4, 0xA4, 0x9C, 0x78,\n\t0x7F, 0x08, 0x04, 0x04, 0x78,\n\t0x00, 0x44, 0x7D, 0x40, 0x00,\n\t0x20, 0x40, 0x40, 0x3D, 0x00,\n\t0x7F, 0x10, 0x28, 0x44, 0x00,\n\t0x00, 0x41, 0x7F, 0x40, 0x00,\n\t0x7C, 0x04, 0x78, 0x04, 0x78,\n\t0x7C, 0x08, 0x04, 0x04, 0x78,\n\t0x38, 0x44, 0x44, 0x44, 0x38,\n\t0xFC, 0x18, 0x24, 0x24, 0x18,\n\t0x18, 0x24, 0x24, 0x18, 0xFC,\n\t0x7C, 0x08, 0x04, 0x04, 0x08,\n\t0x48, 0x54, 0x54, 0x54, 0x24,\n\t0x04, 0x04, 0x3F, 0x44, 0x24,\n\t0x3C, 0x40, 0x40, 0x20, 0x7C,\n\t0x1C, 0x20, 0x40, 0x20, 0x1C,\n\t0x3C, 0x40, 0x30, 0x40, 0x3C,\n\t0x44, 0x28, 0x10, 0x28, 0x44,\n\t0x4C, 0x90, 0x90, 0x90, 0x7C,\n\t0x44, 0x64, 0x54, 0x4C, 0x44,\n\t0x00, 0x08, 0x36, 0x41, 0x00,\n\t0x00, 0x00, 0x77, 0x00, 0x00,\n\t0x00, 0x41, 0x36, 0x08, 0x00,\n\t0x02, 0x01, 0x02, 0x04, 0x02,\n\t0x3C, 0x26, 0x23, 0x26, 0x3C,\n\t0x1E, 0xA1, 0xA1, 0x61, 0x12,\n\t0x3A, 0x40, 0x40, 0x20, 0x7A,\n\t0x38, 0x54, 0x54, 0x55, 0x59,\n\t0x21, 0x55, 0x55, 0x79, 0x41,\n\t0x22, 0x54, 0x54, 0x78, 0x42,\n\t0x21, 0x55, 0x54, 0x78, 0x40,\n\t0x20, 0x54, 0x55, 0x79, 0x40,\n\t0x0C, 0x1E, 0x52, 0x72, 0x12,\n\t0x39, 0x55, 0x55, 0x55, 0x59,\n\t0x39, 0x54, 0x54, 0x54, 0x59,\n\t0x39, 0x55, 0x54, 0x54, 0x58,\n\t0x00, 0x00, 0x45, 0x7C, 0x41,\n\t0x00, 0x02, 0x45, 0x7D, 0x42,\n\t0x00, 0x01, 0x45, 0x7C, 0x40,\n\t0x7D, 0x12, 0x11, 0x12, 0x7D,\n\t0xF0, 0x28, 0x25, 0x28, 0xF0,\n\t0x7C, 0x54, 0x55, 0x45, 0x00,\n\t0x20, 0x54, 0x54, 0x7C, 0x54,\n\t0x7C, 0x0A, 0x09, 0x7F, 0x49,\n\t0x32, 0x49, 0x49, 0x49, 0x32,\n\t0x3A, 0x44, 0x44, 0x44, 0x3A, \n\t0x32, 0x4A, 0x48, 0x48, 0x30,\n\t0x3A, 0x41, 0x41, 0x21, 0x7A,\n\t0x3A, 0x42, 0x40, 0x20, 0x78,\n\t0x00, 0x9D, 0xA0, 0xA0, 0x7D,\n\t0x3D, 0x42, 0x42, 0x42, 0x3D, \n\t0x3D, 0x40, 0x40, 0x40, 0x3D,\n\t0x3C, 0x24, 0xFF, 0x24, 0x24,\n\t0x48, 0x7E, 0x49, 0x43, 0x66,\n\t0x2B, 0x2F, 0xFC, 0x2F, 0x2B,\n\t0xFF, 0x09, 0x29, 0xF6, 0x20,\n\t0xC0, 0x88, 0x7E, 0x09, 0x03,\n\t0x20, 0x54, 0x54, 0x79, 0x41,\n\t0x00, 0x00, 0x44, 0x7D, 0x41,\n\t0x30, 0x48, 0x48, 0x4A, 0x32,\n\t0x38, 0x40, 0x40, 0x22, 0x7A,\n\t0x00, 0x7A, 0x0A, 0x0A, 0x72,\n\t0x7D, 0x0D, 0x19, 0x31, 0x7D,\n\t0x26, 0x29, 0x29, 0x2F, 0x28,\n\t0x26, 0x29, 0x29, 0x29, 0x26,\n\t0x30, 0x48, 0x4D, 0x40, 0x20,\n\t0x38, 0x08, 0x08, 0x08, 0x08,\n\t0x08, 0x08, 0x08, 0x08, 0x38,\n\t0x2F, 0x10, 0xC8, 0xAC, 0xBA,\n\t0x2F, 0x10, 0x28, 0x34, 0xFA,\n\t0x00, 0x00, 0x7B, 0x00, 0x00,\n\t0x08, 0x14, 0x2A, 0x14, 0x22,\n\t0x22, 0x14, 0x2A, 0x14, 0x08,\n\t0x55, 0x00, 0x55, 0x00, 0x55, \n\t0xAA, 0x55, 0xAA, 0x55, 0xAA, \n\t0xFF, 0x55, 0xFF, 0x55, 0xFF, \n\t0x00, 0x00, 0x00, 0xFF, 0x00,\n\t0x10, 0x10, 0x10, 0xFF, 0x00,\n\t0x14, 0x14, 0x14, 0xFF, 0x00,\n\t0x10, 0x10, 0xFF, 0x00, 0xFF,\n\t0x10, 0x10, 0xF0, 0x10, 0xF0,\n\t0x14, 0x14, 0x14, 0xFC, 0x00,\n\t0x14, 0x14, 0xF7, 0x00, 0xFF,\n\t0x00, 0x00, 0xFF, 0x00, 0xFF,\n\t0x14, 0x14, 0xF4, 0x04, 0xFC,\n\t0x14, 0x14, 0x17, 0x10, 0x1F,\n\t0x10, 0x10, 0x1F, 0x10, 0x1F,\n\t0x14, 0x14, 0x14, 0x1F, 0x00,\n\t0x10, 0x10, 0x10, 0xF0, 0x00,\n\t0x00, 0x00, 0x00, 0x1F, 0x10,\n\t0x10, 0x10, 0x10, 0x1F, 0x10,\n\t0x10, 0x10, 0x10, 0xF0, 0x10,\n\t0x00, 0x00, 0x00, 0xFF, 0x10,\n\t0x10, 0x10, 0x10, 0x10, 0x10,\n\t0x10, 0x10, 0x10, 0xFF, 0x10,\n\t0x00, 0x00, 0x00, 0xFF, 0x14,\n\t0x00, 0x00, 0xFF, 0x00, 0xFF,\n\t0x00, 0x00, 0x1F, 0x10, 0x17,\n\t0x00, 0x00, 0xFC, 0x04, 0xF4,\n\t0x14, 0x14, 0x17, 0x10, 0x17,\n\t0x14, 0x14, 0xF4, 0x04, 0xF4,\n\t0x00, 0x00, 0xFF, 0x00, 0xF7,\n\t0x14, 0x14, 0x14, 0x14, 0x14,\n\t0x14, 0x14, 0xF7, 0x00, 0xF7,\n\t0x14, 0x14, 0x14, 0x17, 0x14,\n\t0x10, 0x10, 0x1F, 0x10, 0x1F,\n\t0x14, 0x14, 0x14, 0xF4, 0x14,\n\t0x10, 0x10, 0xF0, 0x10, 0xF0,\n\t0x00, 0x00, 0x1F, 0x10, 0x1F,\n\t0x00, 0x00, 0x00, 0x1F, 0x14,\n\t0x00, 0x00, 0x00, 0xFC, 0x14,\n\t0x00, 0x00, 0xF0, 0x10, 0xF0,\n\t0x10, 0x10, 0xFF, 0x10, 0xFF,\n\t0x14, 0x14, 0x14, 0xFF, 0x14,\n\t0x10, 0x10, 0x10, 0x1F, 0x00,\n\t0x00, 0x00, 0x00, 0xF0, 0x10,\n\t0xFF, 0xFF, 0xFF, 0xFF, 0xFF,\n\t0xF0, 0xF0, 0xF0, 0xF0, 0xF0,\n\t0xFF, 0xFF, 0xFF, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0xFF, 0xFF,\n\t0x0F, 0x0F, 0x0F, 0x0F, 0x0F,\n\t0x38, 0x44, 0x44, 0x38, 0x44,\n\t0xFC, 0x4A, 0x4A, 0x4A, 0x34, \n\t0x7E, 0x02, 0x02, 0x06, 0x06,\n\t0x02, 0x7E, 0x02, 0x7E, 0x02,\n\t0x63, 0x55, 0x49, 0x41, 0x63,\n\t0x38, 0x44, 0x44, 0x3C, 0x04,\n\t0x40, 0x7E, 0x20, 0x1E, 0x20,\n\t0x06, 0x02, 0x7E, 0x02, 0x02,\n\t0x99, 0xA5, 0xE7, 0xA5, 0x99,\n\t0x1C, 0x2A, 0x49, 0x2A, 0x1C,\n\t0x4C, 0x72, 0x01, 0x72, 0x4C,\n\t0x30, 0x4A, 0x4D, 0x4D, 0x30,\n\t0x30, 0x48, 0x78, 0x48, 0x30,\n\t0xBC, 0x62, 0x5A, 0x46, 0x3D,\n\t0x3E, 0x49, 0x49, 0x49, 0x00,\n\t0x7E, 0x01, 0x01, 0x01, 0x7E,\n\t0x2A, 0x2A, 0x2A, 0x2A, 0x2A,\n\t0x44, 0x44, 0x5F, 0x44, 0x44,\n\t0x40, 0x51, 0x4A, 0x44, 0x40,\n\t0x40, 0x44, 0x4A, 0x51, 0x40,\n\t0x00, 0x00, 0xFF, 0x01, 0x03,\n\t0xE0, 0x80, 0xFF, 0x00, 0x00,\n\t0x08, 0x08, 0x6B, 0x6B, 0x08,\n\t0x36, 0x12, 0x36, 0x24, 0x36,\n\t0x06, 0x0F, 0x09, 0x0F, 0x06,\n\t0x00, 0x00, 0x18, 0x18, 0x00,\n\t0x00, 0x00, 0x10, 0x10, 0x00,\n\t0x30, 0x40, 0xFF, 0x01, 0x01,\n\t0x00, 0x1F, 0x01, 0x01, 0x1E,\n\t0x00, 0x19, 0x1D, 0x17, 0x12,\n\t0x00, 0x3C, 0x3C, 0x3C, 0x3C,\n\t0x00, 0x00, 0x00, 0x00, 0x00  \n};\n\n\n\n\/\/***** Functions prototypes *****\/\/\n\/\/1. Write Command to LCD\nvoid ILI9341_SendCommand(uint8_t com);\n\/\/2. Write data to LCD\nvoid ILI9341_SendData(uint8_t data);\n\/\/2.2 Write multiple\/DMA\nvoid ILI9341_SendData_Multi(uint16_t Colordata, uint32_t size);\n\n\n\/\/3. Set cursor position\nvoid ILI9341_SetCursorPosition(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);\n\/\/4. Initialise function\nvoid ILI9341_Init();\n\/\/5. Write data to a single pixel\nvoid ILI9341_DrawPixel(uint16_t x, uint16_t y, uint16_t color); \/\/Draw single pixel to ILI9341\n\/\/6. Fill the entire screen with a background color\nvoid ILI9341_Fill(uint16_t color); \/\/Fill entire ILI9341 with color\n\/\/7. Rectangle drawing functions\nvoid ILI9341_Fill_Rect(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, uint16_t color);\n\/\/8. Circle drawing functions\nvoid ILI9341_drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);\nstatic void drawCircleHelper( int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color);\nstatic void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color);\nvoid ILI9341_fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);\n\/\/9. Line drawing functions\nvoid ILI9341_drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);\nvoid ILI9341_drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);\nvoid ILI9341_drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);\n\/\/10. Triangle drawing\nvoid ILI9341_drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);\nvoid ILI9341_fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);\n\/\/11. Text printing functions\n\/\/void ILI9341_drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size);\n\/\/void ILI9341_printText(char text[], int16_t x, int16_t y, uint16_t color, uint16_t bg, uint8_t size);\n\/\/12. Image print (RGB 565, 2 bytes per pixel)\nvoid ILI9341_printImage(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint8_t *data, uint32_t size);\n\/\/13. Set screen rotation\nvoid ILI9341_setRotation(uint8_t rotate);\n\/\/14. Get screen rotation\nuint8_t ILI9341_getRotation(void);\n\/\/draw a single character \nvoid ILI9341_DrawChar(int16_t x, int16_t y, char c, int16_t textColor, int16_t bgColor, uint8_t size);\n\/\/sensd 16-bit color data\nuint16_t ILI9341_Color565(uint8_t r, uint8_t g, uint8_t b);\n\/\/write a string to the lcd \nuint32_t ILI9341_DrawString(uint16_t x, uint16_t y, char *pt, int16_t textColor,int16_t BG,uint16_t size);\n\n#endif\n<\/pre><\/div>\n\n\n\n<p>Now, create new source file with name of ILI9341.c.<\/p>\n\n\n\n<p>Within the source file, include the following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\/\/most of the functions has been documented in the interface file (ILI9341.h)\n#include &quot;ILI9341.h&quot;\n#include &quot;LCD_Pins.h&quot;<\/pre><\/div>\n\n\n\n<p>Variables needed for calculations:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">static uint8_t rotationNum=1;\nstatic uint8_t ColStart, RowStart;<\/pre><\/div>\n\n\n\n<p>For the initialization function:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\/\/initialize the tft\nvoid ILI9341_Init(void)\n{\n\n\n\tLCD_Write_Cmd (ILI9341_DISPLAY_OFF); \/\/ display off\n\t\/\/------------power control------------------------------\n\tLCD_Write_Cmd (ILI9341_POWER1); \/\/ power control\n\tLCD_Write_Data   (0x26); \/\/ GVDD = 4.75v\n\tLCD_Write_Cmd (ILI9341_POWER2); \/\/ power control\n\tLCD_Write_Data   (0x11); \/\/ AVDD=VCIx2, VGH=VCIx7, VGL=-VCIx3\n\t\/\/--------------VCOM-------------------------------------\n\tLCD_Write_Cmd (ILI9341_VCOM1); \/\/ vcom control\n\tLCD_Write_Data   (0x35); \/\/ Set the VCOMH voltage (0x35 = 4.025v)\n\tLCD_Write_Data   (0x3e); \/\/ Set the VCOML voltage (0x3E = -0.950v)\n\tLCD_Write_Cmd (ILI9341_VCOM2); \/\/ vcom control\n\tLCD_Write_Data   (0xbe);\n\n\t\/\/------------memory access control------------------------\n\tLCD_Write_Cmd (ILI9341_MAC); \/\/ memory access control\n\tLCD_Write_Data(0x48);\n\n\tLCD_Write_Cmd (ILI9341_PIXEL_FORMAT); \/\/ pixel format set\n\tLCD_Write_Data   (0x55); \/\/ 16bit \/pixel\n\n\tLCD_Write_Cmd(ILI9341_FRC);\n\tLCD_Write_Data(0);\n\tLCD_Write_Data(0x1F);\n\t\/\/-------------ddram ----------------------------\n\tLCD_Write_Cmd (ILI9341_COLUMN_ADDR); \/\/ column set\n\tLCD_Write_Data   (0x00); \/\/ x0_HIGH---0\n\tLCD_Write_Data   (0x00); \/\/ x0_LOW----0\n\tLCD_Write_Data   (0x00); \/\/ x1_HIGH---240\n\tLCD_Write_Data   (0x1D); \/\/ x1_LOW----240\n\tLCD_Write_Cmd (ILI9341_PAGE_ADDR); \/\/ page address set\n\tLCD_Write_Data   (0x00); \/\/ y0_HIGH---0\n\tLCD_Write_Data   (0x00); \/\/ y0_LOW----0\n\tLCD_Write_Data   (0x00); \/\/ y1_HIGH---320\n\tLCD_Write_Data   (0x27); \/\/ y1_LOW----320\n\n\tLCD_Write_Cmd (ILI9341_TEARING_OFF); \/\/ tearing effect off\n\t\/\/LCD_write_cmd(ILI9341_TEARING_ON); \/\/ tearing effect on\n\t\/\/LCD_write_cmd(ILI9341_DISPLAY_INVERSION); \/\/ display inversion\n\tLCD_Write_Cmd (ILI9341_Entry_Mode_Set); \/\/ entry mode set\n\t\/\/ Deep Standby Mode: OFF\n\t\/\/ Set the output level of gate driver G1-G320: Normal display\n\t\/\/ Low voltage detection: Disable\n\tLCD_Write_Data   (0x07);\n\t\/\/-----------------display------------------------\n\tLCD_Write_Cmd (ILI9341_DFC); \/\/ display function control\n\t\/\/Set the scan mode in non-display area\n\t\/\/Determine source\/VCOM output in a non-display area in the partial display mode\n\tLCD_Write_Data   (0x0a);\n\t\/\/Select whether the liquid crystal type is normally white type or normally black type\n\t\/\/Sets the direction of scan by the gate driver in the range determined by SCN and NL\n\t\/\/Select the shift direction of outputs from the source driver\n\t\/\/Sets the gate driver pin arrangement in combination with the GS bit to select the optimal scan mode for the module\n\t\/\/Specify the scan cycle interval of gate driver in non-display area when PTG to select interval scan\n\tLCD_Write_Data   (0x82);\n\t\/\/ Sets the number of lines to drive the LCD at an interval of 8 lines\n\tLCD_Write_Data   (0x27);\n\tLCD_Write_Data   (0x00); \/\/ clock divisor\n\n\tLCD_Write_Cmd (ILI9341_SLEEP_OUT); \/\/ sleep out\n\tdelay(100);\n\tLCD_Write_Cmd (ILI9341_DISPLAY_ON); \/\/ display on\n\tdelay(100);\n\tLCD_Write_Cmd (ILI9341_GRAM); \/\/ memory write\n\tdelay(5);\n\n}<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">3. Supporting functions:<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\n\/\/set the address of the pixel in the memory \nvoid static setAddrWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1)\n{\n\n\tLCD_Write_Cmd(0x2A); \/\/ Column addr set\n\tLCD_Write_Data(0x00);\n\tLCD_Write_Data(x0+ColStart);     \/\/ XSTART\n\tLCD_Write_Data(0x00);\n\tLCD_Write_Data(x1+ColStart);     \/\/ XEND\n\n\tLCD_Write_Cmd(0x2B); \/\/ Row addr set\n\tLCD_Write_Data(0x00);\n\tLCD_Write_Data(y0+RowStart);     \/\/ YSTART\n\tLCD_Write_Data(0x00);\n\tLCD_Write_Data(y1+RowStart);     \/\/ YEND\n\n\tLCD_Write_Cmd(0x2C); \/\/ write to RAM\n}\n\n\/\/internally needed function to push 16-bit color as 2 8-bit data\nvoid static pushColor(uint16_t color)\n{\n\tLCD_Write_Data((uint8_t)(color &gt;&gt; 8));\n\tLCD_Write_Data((uint8_t)color);\n}\n\n\/\/set cursor function\nvoid ILI9341_SetCursorPosition(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)\n{\n\tLCD_Write_Cmd (ILI9341_COLUMN_ADDR);\n\tLCD_Write_Data(x1&gt;&gt;8);\n\tLCD_Write_Data(x1 &amp; 0xFF);\n\tLCD_Write_Data(x2&gt;&gt;8);\n\tLCD_Write_Data(x2 &amp; 0xFF);\n\tLCD_Write_Cmd (ILI9341_PAGE_ADDR);\n\tLCD_Write_Data(y1&gt;&gt;8);\n\tLCD_Write_Data(y1 &amp; 0xFF);\n\tLCD_Write_Data(y2&gt;&gt;8);\n\tLCD_Write_Data(y2 &amp; 0xFF);\n\tLCD_Write_Cmd (ILI9341_GRAM);\n}\n\nvoid ILI9341_DrawPixel(uint16_t x, uint16_t y, uint16_t color)\n{\n\tILI9341_SetCursorPosition(x, y, x, y);\n\tLCD_Write_Data(color&gt;&gt;8);\n\tLCD_Write_Data(color&amp;0xFF);\n}\n\nvoid ILI9341_Fill(uint16_t color)\n{\n\tuint32_t n = ILI9341_PIXEL_COUNT;\n\tuint16_t myColor = 0xFF;\n\t\n\tif(rotationNum==1 || rotationNum==3)\n\t{\n\t\tILI9341_SetCursorPosition(0, 0,   ILI9341_WIDTH -1, ILI9341_HEIGHT -1);\n\t}\n\telse if(rotationNum==2 || rotationNum==4)\n\t{\n\t\tILI9341_SetCursorPosition(0, 0, ILI9341_HEIGHT -1, ILI9341_WIDTH -1);\n\t}\n\t\n\t\n\twhile (n)\n\t{\n\t\tn--;\n\t\tLCD_Write_Data(color&gt;&gt;8);\n\t\tLCD_Write_Data(color&amp;0xff);\n\t}\n}\n\n\n\nvoid ILI9341_Fill_Rect(unsigned int x0,unsigned int y0, unsigned int x1,unsigned int y1, uint16_t color) { \n\tuint32_t n = ((x1+1)-x0)*((y1+1)-y0);\n\tif (n&gt;ILI9341_PIXEL_COUNT) n=ILI9341_PIXEL_COUNT;\n\tILI9341_SetCursorPosition(x0, y0, x1, y1);\n\twhile (n)\n\t{\n\t\tn--;\n\t\tLCD_Write_Data(color&gt;&gt;8);\n\t\tLCD_Write_Data(color&amp;0xff);\n\t}\n}\n\nvoid ILI9341_drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)\n{\n\tint16_t f = 1 - r;\n\tint16_t ddF_x = 1;\n\tint16_t ddF_y = -2 * r;\n\tint16_t x = 0;\n\tint16_t y = r;\n\n\tILI9341_DrawPixel(x0  , y0+r, color);\n\tILI9341_DrawPixel(x0  , y0-r, color);\n\tILI9341_DrawPixel(x0+r, y0  , color);\n\tILI9341_DrawPixel(x0-r, y0  , color);\n\n\twhile (x&lt;y)\n\t{\n\t\tif (f &gt;= 0)\n\t\t{\n\t\t\ty--;\n\t\t\tddF_y += 2;\n\t\t\tf += ddF_y;\n\t\t}\n\t\tx++;\n\t\tddF_x += 2;\n\t\tf += ddF_x;\n\n\t\tILI9341_DrawPixel(x0 + x, y0 + y, color);\n\t\tILI9341_DrawPixel(x0 - x, y0 + y, color);\n\t\tILI9341_DrawPixel(x0 + x, y0 - y, color);\n\t\tILI9341_DrawPixel(x0 - x, y0 - y, color);\n\t\tILI9341_DrawPixel(x0 + y, y0 + x, color);\n\t\tILI9341_DrawPixel(x0 - y, y0 + x, color);\n\t\tILI9341_DrawPixel(x0 + y, y0 - x, color);\n\t\tILI9341_DrawPixel(x0 - y, y0 - x, color);\n\t}\n}\nstatic void drawCircleHelper( int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color)\n{\n\tint16_t f     = 1 - r;\n\tint16_t ddF_x = 1;\n\tint16_t ddF_y = -2 * r;\n\tint16_t x     = 0;\n\tint16_t y     = r;\n\n\twhile (x&lt;y)\n\t{\n\t\tif (f &gt;= 0)\n\t\t{\n\t\t\ty--;\n\t\t\tddF_y += 2;\n\t\t\tf += ddF_y;\n\t\t}\n\t\tx++;\n\t\tddF_x += 2;\n\t\tf+= ddF_x;\n\t\tif (cornername &amp; 0x4)\n\t\t{\n\t\t\tILI9341_DrawPixel(x0 + x, y0 + y, color);\n\t\t\tILI9341_DrawPixel(x0 + y, y0 + x, color);\n\t\t}\n\t\tif (cornername &amp; 0x2) {\n\t\t\t\tILI9341_DrawPixel(x0 + x, y0 - y, color);\n\t\t\t\tILI9341_DrawPixel(x0 + y, y0 - x, color);\n\t\t}\n\t\tif (cornername &amp; 0x8) {\n\t\t\tILI9341_DrawPixel(x0 - y, y0 + x, color);\n\t\t\tILI9341_DrawPixel(x0 - x, y0 + y, color);\n\t\t}\n\t\tif (cornername &amp; 0x1)\n\t\t{\n\t\t\tILI9341_DrawPixel(x0 - y, y0 - x, color);\n\t\t\tILI9341_DrawPixel(x0 - x, y0 - y, color);\n\t\t}\n\t}\n}\nstatic void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color)\n{\n\tint16_t f     = 1 - r;\n\tint16_t ddF_x = 1;\n\tint16_t ddF_y = -2 * r;\n\tint16_t x     = 0;\n\tint16_t y     = r;\n\n\twhile (x&lt;y)\n\t{\n\t\tif (f &gt;= 0)\n\t\t{\n\t\t\ty--;\n\t\t\tddF_y += 2;\n\t\t\tf+= ddF_y;\n\t\t}\n\t\tx++;\n\t\tddF_x += 2;\n\t\tf += ddF_x;\n\n\t\tif (cornername &amp; 0x1)\n\t\t{\n\t\t\tILI9341_drawFastVLine(x0+x, y0-y, 2*y+1+delta, color);\n\t\t\tILI9341_drawFastVLine(x0+y, y0-x, 2*x+1+delta, color);\n\t\t}\n\t\tif (cornername &amp; 0x2)\n\t\t{\n\t\t\tILI9341_drawFastVLine(x0-x, y0-y, 2*y+1+delta, color);\n\t\t\tILI9341_drawFastVLine(x0-y, y0-x, 2*x+1+delta, color);\n\t\t}\n\t}\n}\nvoid ILI9341_fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)\n{\n\tILI9341_drawFastVLine(x0, y0-r, 2*r+1, color);\n\tfillCircleHelper(x0, y0, r, 3, 0, color);\n}\nvoid ILI9341_drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)\n{\n\tint16_t steep = abs(y1 - y0) &gt; abs(x1 - x0);\n\tif (steep)\n\t{\n\t\tswap(x0, y0);\n\t\tswap(x1, y1);\n\t}\n\n\tif (x0 &gt; x1)\n\t{\n\t\tswap(x0, x1);\n\t\tswap(y0, y1);\n\t}\n\n\tint16_t dx, dy;\n\tdx = x1 - x0;\n\tdy = abs(y1 - y0);\n\n\tint16_t err = dx \/ 2;\n\tint16_t ystep;\n\n\tif (y0 &lt; y1)\n\t{\n\t\tystep = 1;\n\t}\n\telse\n\t{\n\t\tystep = -1;\n\t}\n\n\tfor (; x0&lt;=x1; x0++)\n\t{\n\t\tif (steep)\n\t\t{\n\t\t\tILI9341_DrawPixel(y0, x0, color);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tILI9341_DrawPixel(x0, y0, color);\n\t\t}\n\t\terr -= dy;\n\t\tif (err &lt; 0)\n\t\t{\n\t\t\ty0 += ystep;\n\t\t\terr += dx;\n\t\t}\n\t}\n}\t\n\nvoid ILI9341_drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)\n{\n\tILI9341_drawLine(x, y, x+w-1, y, color);\n}\n\nvoid ILI9341_drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)\n{\n\tILI9341_drawLine(x, y, x, y+h-1, color);\n}\n\/\/10. Triangle drawing\nvoid ILI9341_drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)\n{\n\tILI9341_drawLine(x0, y0, x1, y1, color);\n\tILI9341_drawLine(x1, y1, x2, y2, color);\n\tILI9341_drawLine(x2, y2, x0, y0, color);\n}\nvoid ILI9341_fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)\n{\n\tint16_t a, b, y, last;\n\n\t\/\/ Sort coordinates by Y order (y2 &gt;= y1 &gt;= y0)\n\tif (y0 &gt; y1) {\n\tswap(y0, y1); swap(x0, x1);\n\t}\n\tif (y1 &gt; y2) {\n\tswap(y2, y1); swap(x2, x1);\n\t}\n\tif (y0 &gt; y1) {\n\tswap(y0, y1); swap(x0, x1);\n\t}\n\n\tif(y0 == y2) { \/\/ Handle awkward all-on-same-line case as its own thing\n\ta = b = x0;\n\tif(x1 &lt; a)      a = x1;\n\telse if(x1 &gt; b) b = x1;\n\tif(x2 &lt; a)      a = x2;\n\telse if(x2 &gt; b) b = x2;\n\tILI9341_drawFastHLine(a, y0, b-a+1, color);\n\treturn;\n\t}\n\n\tint16_t\n\tdx01 = x1 - x0,\n\tdy01 = y1 - y0,\n\tdx02 = x2 - x0,\n\tdy02 = y2 - y0,\n\tdx12 = x2 - x1,\n\tdy12 = y2 - y1,\n\tsa   = 0,\n\tsb   = 0;\n\n\t\/\/ For upper part of triangle, find scanline crossings for segments\n\t\/\/ 0-1 and 0-2.  If y1=y2 (flat-bottomed triangle), the scanline y1\n\t\/\/ is included here (and second loop will be skipped, avoiding a \/0\n\t\/\/ error there), otherwise scanline y1 is skipped here and handled\n\t\/\/ in the second loop...which also avoids a \/0 error here if y0=y1\n\t\/\/ (flat-topped triangle).\n\tif(y1 == y2) last = y1;   \/\/ Include y1 scanline\n\telse         last = y1-1; \/\/ Skip it\n\n\tfor(y=y0; y&lt;=last; y++) {\n\ta   = x0 + sa \/ dy01;\n\tb   = x0 + sb \/ dy02;\n\tsa += dx01;\n\tsb += dx02;\n\n\tif(a &gt; b) swap(a,b);\n\tILI9341_drawFastHLine(a, y, b-a+1, color);\n\t}\n\n\t\/\/ For lower part of triangle, find scanline crossings for segments\n\t\/\/ 0-2 and 1-2.  This loop is skipped if y1=y2.\n\tsa = dx12 * (y - y1);\n\tsb = dx02 * (y - y0);\n\tfor(; y&lt;=y2; y++) {\n\ta   = x1 + sa \/ dy12;\n\tb   = x0 + sb \/ dy02;\n\tsa += dx12;\n\tsb += dx02;\n\n\tif(a &gt; b) swap(a,b);\n\tILI9341_drawFastHLine(a, y, b-a+1, color);\n\t}\n}\n\nvoid ILI9341_setRotation(uint8_t rotate)\n{\n\tswitch(rotate)\n\t{\n\tcase 1:\n\trotationNum = 1;\n\tLCD_Write_Cmd(ILI9341_MEMCONTROL);\n\tLCD_Write_Data(ILI9341_MADCTL_MY | ILI9341_MADCTL_BGR);\n\tbreak;\n\tcase 2:\n\trotationNum = 2;\n\tLCD_Write_Cmd(ILI9341_MEMCONTROL);\n\tLCD_Write_Data(ILI9341_MADCTL_MV | ILI9341_MADCTL_BGR);\n\tbreak;\n\tcase 3:\n\trotationNum = 3;\n\tLCD_Write_Cmd(ILI9341_MEMCONTROL);\n\tLCD_Write_Data(ILI9341_MADCTL_MX | ILI9341_MADCTL_BGR);\n\tbreak;\n\tcase 4:\n\trotationNum = 4;\n\tLCD_Write_Cmd(ILI9341_MEMCONTROL);\n\tLCD_Write_Data(ILI9341_MADCTL_MX | ILI9341_MADCTL_MY | ILI9341_MADCTL_MV | ILI9341_MADCTL_BGR);\n\tbreak;\n\tdefault:\n\trotationNum = 1;\n\tLCD_Write_Cmd(ILI9341_MEMCONTROL);\n\tLCD_Write_Data(ILI9341_MADCTL_MY | ILI9341_MADCTL_BGR);\n\tbreak;\n\t}\n}\n\nvoid ILI9341_DrawChar(int16_t x, int16_t y, char c, int16_t textColor, int16_t bgColor, uint8_t size){\n\tuint8_t line; \/\/ horizontal row of pixels of character\n\tint32_t col, row, i, j;\/\/ loop indices\n\tif(((x + 5*size - 1) &gt;= ILI9341_WIDTH)  || \/\/ Clip right\n\t((y + 8*size - 1) &gt;= ILI9341_HEIGHT) || \/\/ Clip bottom\n\t((x + 5*size - 1) &lt; 0)        || \/\/ Clip left\n\t((y + 8*size - 1) &lt; 0)){         \/\/ Clip top\n\treturn;\n\t}\n\n\tsetAddrWindow(x, y, x+6*size-1, y+8*size-1);\n\n\tline = 0x01;        \/\/ print the top row first\n\t\/\/ print the rows, starting at the top\n\tfor(row=0; row&lt;8; row=row+1){\n\tfor(i=0; i&lt;size; i=i+1){\n\t\/\/ print the columns, starting on the left\n\tfor(col=0; col&lt;5; col=col+1){\n\tif(Font[(c*5)+col]&amp;line){\n\t\/\/ bit is set in Font, print pixel(s) in text color\n\tfor(j=0; j&lt;size; j=j+1){\n\tpushColor(textColor);\n\t}\n\t} else{\n\t\/\/ bit is cleared in Font, print pixel(s) in background color\n\tfor(j=0; j&lt;size; j=j+1){\n\tpushColor(bgColor);\n\t}\n\t}\n\t}\n\t\/\/ print blank column(s) to the right of character\n\tfor(j=0; j&lt;size; j=j+1){\n\tpushColor(bgColor);\n\t}\n\t}\n\tline = line&lt;&lt;1;   \/\/ move up to the next row\n\t}\n}\nuint16_t ILI9341_Color565(uint8_t r, uint8_t g, uint8_t b) {\n\treturn ((b &amp; 0xF8) &lt;&lt; 8) | ((g &amp; 0xFC) &lt;&lt; 3) | (r &gt;&gt; 3);\n}\n\nuint32_t ILI9341_DrawString(uint16_t x, uint16_t y, char *pt, int16_t textColor, int16_t BG,uint16_t size){\n\tuint32_t count = 0;\n\n\twhile(*pt!='\\0')\n\t{\n\n\t\tILI9341_DrawChar(x*6*size, y*10*size, *pt, textColor, BG, size);\n\t\tpt++;\n\t\tx = x+1;\n\t\tcount++;\n\t}\n\treturn count;  \/\/ number of characters printed\n}\n\n<\/pre><\/div>\n\n\n\n<p>Hence, the entire source code as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\/\/most of the functions has been documented in the interface file (ILI9341.h)\n#include &quot;ILI9341.h&quot;\n#include &quot;LCD_Pins.h&quot;\n\n\nstatic uint8_t rotationNum=1;\nstatic uint8_t ColStart, RowStart;\n\n\n\/\/initialize the tft\nvoid ILI9341_Init(void)\n{\n\n\n\tLCD_Write_Cmd (ILI9341_DISPLAY_OFF); \/\/ display off\n\t\/\/------------power control------------------------------\n\tLCD_Write_Cmd (ILI9341_POWER1); \/\/ power control\n\tLCD_Write_Data   (0x26); \/\/ GVDD = 4.75v\n\tLCD_Write_Cmd (ILI9341_POWER2); \/\/ power control\n\tLCD_Write_Data   (0x11); \/\/ AVDD=VCIx2, VGH=VCIx7, VGL=-VCIx3\n\t\/\/--------------VCOM-------------------------------------\n\tLCD_Write_Cmd (ILI9341_VCOM1); \/\/ vcom control\n\tLCD_Write_Data   (0x35); \/\/ Set the VCOMH voltage (0x35 = 4.025v)\n\tLCD_Write_Data   (0x3e); \/\/ Set the VCOML voltage (0x3E = -0.950v)\n\tLCD_Write_Cmd (ILI9341_VCOM2); \/\/ vcom control\n\tLCD_Write_Data   (0xbe);\n\n\t\/\/------------memory access control------------------------\n\tLCD_Write_Cmd (ILI9341_MAC); \/\/ memory access control\n\tLCD_Write_Data(0x48);\n\n\tLCD_Write_Cmd (ILI9341_PIXEL_FORMAT); \/\/ pixel format set\n\tLCD_Write_Data   (0x55); \/\/ 16bit \/pixel\n\n\tLCD_Write_Cmd(ILI9341_FRC);\n\tLCD_Write_Data(0);\n\tLCD_Write_Data(0x1F);\n\t\/\/-------------ddram ----------------------------\n\tLCD_Write_Cmd (ILI9341_COLUMN_ADDR); \/\/ column set\n\tLCD_Write_Data   (0x00); \/\/ x0_HIGH---0\n\tLCD_Write_Data   (0x00); \/\/ x0_LOW----0\n\tLCD_Write_Data   (0x00); \/\/ x1_HIGH---240\n\tLCD_Write_Data   (0x1D); \/\/ x1_LOW----240\n\tLCD_Write_Cmd (ILI9341_PAGE_ADDR); \/\/ page address set\n\tLCD_Write_Data   (0x00); \/\/ y0_HIGH---0\n\tLCD_Write_Data   (0x00); \/\/ y0_LOW----0\n\tLCD_Write_Data   (0x00); \/\/ y1_HIGH---320\n\tLCD_Write_Data   (0x27); \/\/ y1_LOW----320\n\n\tLCD_Write_Cmd (ILI9341_TEARING_OFF); \/\/ tearing effect off\n\t\/\/LCD_write_cmd(ILI9341_TEARING_ON); \/\/ tearing effect on\n\t\/\/LCD_write_cmd(ILI9341_DISPLAY_INVERSION); \/\/ display inversion\n\tLCD_Write_Cmd (ILI9341_Entry_Mode_Set); \/\/ entry mode set\n\t\/\/ Deep Standby Mode: OFF\n\t\/\/ Set the output level of gate driver G1-G320: Normal display\n\t\/\/ Low voltage detection: Disable\n\tLCD_Write_Data   (0x07);\n\t\/\/-----------------display------------------------\n\tLCD_Write_Cmd (ILI9341_DFC); \/\/ display function control\n\t\/\/Set the scan mode in non-display area\n\t\/\/Determine source\/VCOM output in a non-display area in the partial display mode\n\tLCD_Write_Data   (0x0a);\n\t\/\/Select whether the liquid crystal type is normally white type or normally black type\n\t\/\/Sets the direction of scan by the gate driver in the range determined by SCN and NL\n\t\/\/Select the shift direction of outputs from the source driver\n\t\/\/Sets the gate driver pin arrangement in combination with the GS bit to select the optimal scan mode for the module\n\t\/\/Specify the scan cycle interval of gate driver in non-display area when PTG to select interval scan\n\tLCD_Write_Data   (0x82);\n\t\/\/ Sets the number of lines to drive the LCD at an interval of 8 lines\n\tLCD_Write_Data   (0x27);\n\tLCD_Write_Data   (0x00); \/\/ clock divisor\n\n\tLCD_Write_Cmd (ILI9341_SLEEP_OUT); \/\/ sleep out\n\tdelay(100);\n\tLCD_Write_Cmd (ILI9341_DISPLAY_ON); \/\/ display on\n\tdelay(100);\n\tLCD_Write_Cmd (ILI9341_GRAM); \/\/ memory write\n\tdelay(5);\n\n}\n\n\/\/set the address of the pixel in the memory \nvoid static setAddrWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1)\n{\n\n\tLCD_Write_Cmd(0x2A); \/\/ Column addr set\n\tLCD_Write_Data(0x00);\n\tLCD_Write_Data(x0+ColStart);     \/\/ XSTART\n\tLCD_Write_Data(0x00);\n\tLCD_Write_Data(x1+ColStart);     \/\/ XEND\n\n\tLCD_Write_Cmd(0x2B); \/\/ Row addr set\n\tLCD_Write_Data(0x00);\n\tLCD_Write_Data(y0+RowStart);     \/\/ YSTART\n\tLCD_Write_Data(0x00);\n\tLCD_Write_Data(y1+RowStart);     \/\/ YEND\n\n\tLCD_Write_Cmd(0x2C); \/\/ write to RAM\n}\n\n\/\/internally needed function to push 16-bit color as 2 8-bit data\nvoid static pushColor(uint16_t color)\n{\n\tLCD_Write_Data((uint8_t)(color &gt;&gt; 8));\n\tLCD_Write_Data((uint8_t)color);\n}\n\n\/\/set cursor function\nvoid ILI9341_SetCursorPosition(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)\n{\n\tLCD_Write_Cmd (ILI9341_COLUMN_ADDR);\n\tLCD_Write_Data(x1&gt;&gt;8);\n\tLCD_Write_Data(x1 &amp; 0xFF);\n\tLCD_Write_Data(x2&gt;&gt;8);\n\tLCD_Write_Data(x2 &amp; 0xFF);\n\tLCD_Write_Cmd (ILI9341_PAGE_ADDR);\n\tLCD_Write_Data(y1&gt;&gt;8);\n\tLCD_Write_Data(y1 &amp; 0xFF);\n\tLCD_Write_Data(y2&gt;&gt;8);\n\tLCD_Write_Data(y2 &amp; 0xFF);\n\tLCD_Write_Cmd (ILI9341_GRAM);\n}\n\nvoid ILI9341_DrawPixel(uint16_t x, uint16_t y, uint16_t color)\n{\n\tILI9341_SetCursorPosition(x, y, x, y);\n\tLCD_Write_Data(color&gt;&gt;8);\n\tLCD_Write_Data(color&amp;0xFF);\n}\n\nvoid ILI9341_Fill(uint16_t color)\n{\n\tuint32_t n = ILI9341_PIXEL_COUNT;\n\tuint16_t myColor = 0xFF;\n\t\n\tif(rotationNum==1 || rotationNum==3)\n\t{\n\t\tILI9341_SetCursorPosition(0, 0,   ILI9341_WIDTH -1, ILI9341_HEIGHT -1);\n\t}\n\telse if(rotationNum==2 || rotationNum==4)\n\t{\n\t\tILI9341_SetCursorPosition(0, 0, ILI9341_HEIGHT -1, ILI9341_WIDTH -1);\n\t}\n\t\n\t\n\twhile (n)\n\t{\n\t\tn--;\n\t\tLCD_Write_Data(color&gt;&gt;8);\n\t\tLCD_Write_Data(color&amp;0xff);\n\t}\n}\n\n\n\nvoid ILI9341_Fill_Rect(unsigned int x0,unsigned int y0, unsigned int x1,unsigned int y1, uint16_t color) { \n\tuint32_t n = ((x1+1)-x0)*((y1+1)-y0);\n\tif (n&gt;ILI9341_PIXEL_COUNT) n=ILI9341_PIXEL_COUNT;\n\tILI9341_SetCursorPosition(x0, y0, x1, y1);\n\twhile (n)\n\t{\n\t\tn--;\n\t\tLCD_Write_Data(color&gt;&gt;8);\n\t\tLCD_Write_Data(color&amp;0xff);\n\t}\n}\n\nvoid ILI9341_drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)\n{\n\tint16_t f = 1 - r;\n\tint16_t ddF_x = 1;\n\tint16_t ddF_y = -2 * r;\n\tint16_t x = 0;\n\tint16_t y = r;\n\n\tILI9341_DrawPixel(x0  , y0+r, color);\n\tILI9341_DrawPixel(x0  , y0-r, color);\n\tILI9341_DrawPixel(x0+r, y0  , color);\n\tILI9341_DrawPixel(x0-r, y0  , color);\n\n\twhile (x&lt;y)\n\t{\n\t\tif (f &gt;= 0)\n\t\t{\n\t\t\ty--;\n\t\t\tddF_y += 2;\n\t\t\tf += ddF_y;\n\t\t}\n\t\tx++;\n\t\tddF_x += 2;\n\t\tf += ddF_x;\n\n\t\tILI9341_DrawPixel(x0 + x, y0 + y, color);\n\t\tILI9341_DrawPixel(x0 - x, y0 + y, color);\n\t\tILI9341_DrawPixel(x0 + x, y0 - y, color);\n\t\tILI9341_DrawPixel(x0 - x, y0 - y, color);\n\t\tILI9341_DrawPixel(x0 + y, y0 + x, color);\n\t\tILI9341_DrawPixel(x0 - y, y0 + x, color);\n\t\tILI9341_DrawPixel(x0 + y, y0 - x, color);\n\t\tILI9341_DrawPixel(x0 - y, y0 - x, color);\n\t}\n}\nstatic void drawCircleHelper( int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color)\n{\n\tint16_t f     = 1 - r;\n\tint16_t ddF_x = 1;\n\tint16_t ddF_y = -2 * r;\n\tint16_t x     = 0;\n\tint16_t y     = r;\n\n\twhile (x&lt;y)\n\t{\n\t\tif (f &gt;= 0)\n\t\t{\n\t\t\ty--;\n\t\t\tddF_y += 2;\n\t\t\tf += ddF_y;\n\t\t}\n\t\tx++;\n\t\tddF_x += 2;\n\t\tf+= ddF_x;\n\t\tif (cornername &amp; 0x4)\n\t\t{\n\t\t\tILI9341_DrawPixel(x0 + x, y0 + y, color);\n\t\t\tILI9341_DrawPixel(x0 + y, y0 + x, color);\n\t\t}\n\t\tif (cornername &amp; 0x2) {\n\t\t\t\tILI9341_DrawPixel(x0 + x, y0 - y, color);\n\t\t\t\tILI9341_DrawPixel(x0 + y, y0 - x, color);\n\t\t}\n\t\tif (cornername &amp; 0x8) {\n\t\t\tILI9341_DrawPixel(x0 - y, y0 + x, color);\n\t\t\tILI9341_DrawPixel(x0 - x, y0 + y, color);\n\t\t}\n\t\tif (cornername &amp; 0x1)\n\t\t{\n\t\t\tILI9341_DrawPixel(x0 - y, y0 - x, color);\n\t\t\tILI9341_DrawPixel(x0 - x, y0 - y, color);\n\t\t}\n\t}\n}\nstatic void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color)\n{\n\tint16_t f     = 1 - r;\n\tint16_t ddF_x = 1;\n\tint16_t ddF_y = -2 * r;\n\tint16_t x     = 0;\n\tint16_t y     = r;\n\n\twhile (x&lt;y)\n\t{\n\t\tif (f &gt;= 0)\n\t\t{\n\t\t\ty--;\n\t\t\tddF_y += 2;\n\t\t\tf+= ddF_y;\n\t\t}\n\t\tx++;\n\t\tddF_x += 2;\n\t\tf += ddF_x;\n\n\t\tif (cornername &amp; 0x1)\n\t\t{\n\t\t\tILI9341_drawFastVLine(x0+x, y0-y, 2*y+1+delta, color);\n\t\t\tILI9341_drawFastVLine(x0+y, y0-x, 2*x+1+delta, color);\n\t\t}\n\t\tif (cornername &amp; 0x2)\n\t\t{\n\t\t\tILI9341_drawFastVLine(x0-x, y0-y, 2*y+1+delta, color);\n\t\t\tILI9341_drawFastVLine(x0-y, y0-x, 2*x+1+delta, color);\n\t\t}\n\t}\n}\nvoid ILI9341_fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)\n{\n\tILI9341_drawFastVLine(x0, y0-r, 2*r+1, color);\n\tfillCircleHelper(x0, y0, r, 3, 0, color);\n}\nvoid ILI9341_drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)\n{\n\tint16_t steep = abs(y1 - y0) &gt; abs(x1 - x0);\n\tif (steep)\n\t{\n\t\tswap(x0, y0);\n\t\tswap(x1, y1);\n\t}\n\n\tif (x0 &gt; x1)\n\t{\n\t\tswap(x0, x1);\n\t\tswap(y0, y1);\n\t}\n\n\tint16_t dx, dy;\n\tdx = x1 - x0;\n\tdy = abs(y1 - y0);\n\n\tint16_t err = dx \/ 2;\n\tint16_t ystep;\n\n\tif (y0 &lt; y1)\n\t{\n\t\tystep = 1;\n\t}\n\telse\n\t{\n\t\tystep = -1;\n\t}\n\n\tfor (; x0&lt;=x1; x0++)\n\t{\n\t\tif (steep)\n\t\t{\n\t\t\tILI9341_DrawPixel(y0, x0, color);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tILI9341_DrawPixel(x0, y0, color);\n\t\t}\n\t\terr -= dy;\n\t\tif (err &lt; 0)\n\t\t{\n\t\t\ty0 += ystep;\n\t\t\terr += dx;\n\t\t}\n\t}\n}\t\n\nvoid ILI9341_drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)\n{\n\tILI9341_drawLine(x, y, x+w-1, y, color);\n}\n\nvoid ILI9341_drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)\n{\n\tILI9341_drawLine(x, y, x, y+h-1, color);\n}\n\/\/10. Triangle drawing\nvoid ILI9341_drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)\n{\n\tILI9341_drawLine(x0, y0, x1, y1, color);\n\tILI9341_drawLine(x1, y1, x2, y2, color);\n\tILI9341_drawLine(x2, y2, x0, y0, color);\n}\nvoid ILI9341_fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)\n{\n\tint16_t a, b, y, last;\n\n\t\/\/ Sort coordinates by Y order (y2 &gt;= y1 &gt;= y0)\n\tif (y0 &gt; y1) {\n\tswap(y0, y1); swap(x0, x1);\n\t}\n\tif (y1 &gt; y2) {\n\tswap(y2, y1); swap(x2, x1);\n\t}\n\tif (y0 &gt; y1) {\n\tswap(y0, y1); swap(x0, x1);\n\t}\n\n\tif(y0 == y2) { \/\/ Handle awkward all-on-same-line case as its own thing\n\ta = b = x0;\n\tif(x1 &lt; a)      a = x1;\n\telse if(x1 &gt; b) b = x1;\n\tif(x2 &lt; a)      a = x2;\n\telse if(x2 &gt; b) b = x2;\n\tILI9341_drawFastHLine(a, y0, b-a+1, color);\n\treturn;\n\t}\n\n\tint16_t\n\tdx01 = x1 - x0,\n\tdy01 = y1 - y0,\n\tdx02 = x2 - x0,\n\tdy02 = y2 - y0,\n\tdx12 = x2 - x1,\n\tdy12 = y2 - y1,\n\tsa   = 0,\n\tsb   = 0;\n\n\t\/\/ For upper part of triangle, find scanline crossings for segments\n\t\/\/ 0-1 and 0-2.  If y1=y2 (flat-bottomed triangle), the scanline y1\n\t\/\/ is included here (and second loop will be skipped, avoiding a \/0\n\t\/\/ error there), otherwise scanline y1 is skipped here and handled\n\t\/\/ in the second loop...which also avoids a \/0 error here if y0=y1\n\t\/\/ (flat-topped triangle).\n\tif(y1 == y2) last = y1;   \/\/ Include y1 scanline\n\telse         last = y1-1; \/\/ Skip it\n\n\tfor(y=y0; y&lt;=last; y++) {\n\ta   = x0 + sa \/ dy01;\n\tb   = x0 + sb \/ dy02;\n\tsa += dx01;\n\tsb += dx02;\n\n\tif(a &gt; b) swap(a,b);\n\tILI9341_drawFastHLine(a, y, b-a+1, color);\n\t}\n\n\t\/\/ For lower part of triangle, find scanline crossings for segments\n\t\/\/ 0-2 and 1-2.  This loop is skipped if y1=y2.\n\tsa = dx12 * (y - y1);\n\tsb = dx02 * (y - y0);\n\tfor(; y&lt;=y2; y++) {\n\ta   = x1 + sa \/ dy12;\n\tb   = x0 + sb \/ dy02;\n\tsa += dx12;\n\tsb += dx02;\n\n\tif(a &gt; b) swap(a,b);\n\tILI9341_drawFastHLine(a, y, b-a+1, color);\n\t}\n}\n\nvoid ILI9341_setRotation(uint8_t rotate)\n{\n\tswitch(rotate)\n\t{\n\tcase 1:\n\trotationNum = 1;\n\tLCD_Write_Cmd(ILI9341_MEMCONTROL);\n\tLCD_Write_Data(ILI9341_MADCTL_MY | ILI9341_MADCTL_BGR);\n\tbreak;\n\tcase 2:\n\trotationNum = 2;\n\tLCD_Write_Cmd(ILI9341_MEMCONTROL);\n\tLCD_Write_Data(ILI9341_MADCTL_MV | ILI9341_MADCTL_BGR);\n\tbreak;\n\tcase 3:\n\trotationNum = 3;\n\tLCD_Write_Cmd(ILI9341_MEMCONTROL);\n\tLCD_Write_Data(ILI9341_MADCTL_MX | ILI9341_MADCTL_BGR);\n\tbreak;\n\tcase 4:\n\trotationNum = 4;\n\tLCD_Write_Cmd(ILI9341_MEMCONTROL);\n\tLCD_Write_Data(ILI9341_MADCTL_MX | ILI9341_MADCTL_MY | ILI9341_MADCTL_MV | ILI9341_MADCTL_BGR);\n\tbreak;\n\tdefault:\n\trotationNum = 1;\n\tLCD_Write_Cmd(ILI9341_MEMCONTROL);\n\tLCD_Write_Data(ILI9341_MADCTL_MY | ILI9341_MADCTL_BGR);\n\tbreak;\n\t}\n}\n\nvoid ILI9341_DrawChar(int16_t x, int16_t y, char c, int16_t textColor, int16_t bgColor, uint8_t size){\n\tuint8_t line; \/\/ horizontal row of pixels of character\n\tint32_t col, row, i, j;\/\/ loop indices\n\tif(((x + 5*size - 1) &gt;= ILI9341_WIDTH)  || \/\/ Clip right\n\t((y + 8*size - 1) &gt;= ILI9341_HEIGHT) || \/\/ Clip bottom\n\t((x + 5*size - 1) &lt; 0)        || \/\/ Clip left\n\t((y + 8*size - 1) &lt; 0)){         \/\/ Clip top\n\treturn;\n\t}\n\n\tsetAddrWindow(x, y, x+6*size-1, y+8*size-1);\n\n\tline = 0x01;        \/\/ print the top row first\n\t\/\/ print the rows, starting at the top\n\tfor(row=0; row&lt;8; row=row+1){\n\tfor(i=0; i&lt;size; i=i+1){\n\t\/\/ print the columns, starting on the left\n\tfor(col=0; col&lt;5; col=col+1){\n\tif(Font[(c*5)+col]&amp;line){\n\t\/\/ bit is set in Font, print pixel(s) in text color\n\tfor(j=0; j&lt;size; j=j+1){\n\tpushColor(textColor);\n\t}\n\t} else{\n\t\/\/ bit is cleared in Font, print pixel(s) in background color\n\tfor(j=0; j&lt;size; j=j+1){\n\tpushColor(bgColor);\n\t}\n\t}\n\t}\n\t\/\/ print blank column(s) to the right of character\n\tfor(j=0; j&lt;size; j=j+1){\n\tpushColor(bgColor);\n\t}\n\t}\n\tline = line&lt;&lt;1;   \/\/ move up to the next row\n\t}\n}\nuint16_t ILI9341_Color565(uint8_t r, uint8_t g, uint8_t b) {\n\treturn ((b &amp; 0xF8) &lt;&lt; 8) | ((g &amp; 0xFC) &lt;&lt; 3) | (r &gt;&gt; 3);\n}\n\nuint32_t ILI9341_DrawString(uint16_t x, uint16_t y, char *pt, int16_t textColor, int16_t BG,uint16_t size){\n\tuint32_t count = 0;\n\n\twhile(*pt!='\\0')\n\t{\n\n\t\tILI9341_DrawChar(x*6*size, y*10*size, *pt, textColor, BG, size);\n\t\tpt++;\n\t\tx = x+1;\n\t\tcount++;\n\t}\n\treturn count;  \/\/ number of characters printed\n}\n\n<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">4. Code:<\/h2>\n\n\n\n<p>You may download the source code from here:<\/p>\n\n\n\n<div class=\"wp-block-file\"><a href=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/10\/ILI9341.zip\">ILI9341<\/a><a href=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/10\/ILI9341.zip\" class=\"wp-block-file__button\" download>Download<\/a><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. Demo:<\/h2>\n\n\n\n<p>In main.c:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#include &quot;LCD_Pins.h&quot;\n#include &quot;ILI9341.h&quot;\n\n\nint main(void)\n{\n\tdelay_init(180000000);\n\tLCD_Pin_Init();\n\tLCD_SPI_Init();\n\tILI9341_Init();\n\tILI9341_setRotation(2);\n\tILI9341_Fill(COLOR_RED);\n\n\twhile(1)\n\t{\n\t\tILI9341_Fill(COLOR_YELLOW);\n\t\tILI9341_Fill(COLOR_PURPLE);\n\n\t}\n}<\/pre><\/div>\n\n\n\n<p>Upload the code and you should get the following:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Bare Metal LCD Driver for STM32F429-Discovery\" width=\"1170\" height=\"658\" src=\"https:\/\/www.youtube.com\/embed\/aLjiPnoRwkc?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, touch interface.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Happy coding \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the previous guide (here), we took a look at STM32F429 Discovery and it&#8217;s features and the environment has been setup. In this guide, we shall cover the following: Delay initializing. LCD initializing. Support functions. Code Results. 1. Delay initializing: We start off by creating new header file with name of delay.h. Within the header [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,19,11,12],"tags":[],"class_list":["post-2081","post","type-post","status-publish","format-standard","hentry","category-embedded-systems","category-lcd","category-peripheral-drivers","category-stm32"],"_links":{"self":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/2081"}],"collection":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2081"}],"version-history":[{"count":1,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/2081\/revisions"}],"predecessor-version":[{"id":2084,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/2081\/revisions\/2084"}],"wp:attachment":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2081"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2081"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2081"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}