ESP8266 ILI9341 display support code with printf sources, wire-frame viewer and custom fonts  1.0
ESP8266ILI9341DisplayProject
ili9341_adafruit.h
Go to the documentation of this file.
1 
41 #ifndef _ILI9341_ADAFRUIT_H_
42 #define _ILI9341_ADAFRUIT_H_
43 
44 #include "font.h"
45 #include "ili9341.h"
46 #include "ili9341_adafruit.h"
47 
48 // Named address space
49 #ifndef MEMSPACE
50 #define MEMSPACE
51 #endif
52 
53 // Weak attribute
54 #ifndef WEAK_ATR
55 #define WEAK_ATR __attribute__((weak))
56 #endif
57 
58 typedef union
59 {
60  struct
61  {
62  uint8_t b0 :8;
63  uint8_t b1 :8;
64  uint8_t b2 :8;
65  uint8_t b3 :8;
66  } bytes;
67 
70 
71 // ==========================================================
72 
73 #define MIN_TFT_Y 0
74 #define MAX_TFT_Y 319
75 #define MIN_TFT_X 0
76 #define MAX_TFT_X 239
77 // ==========================================================
78 
79 #define MADCTL_MY 0x80
80 #define MADCTL_MX 0x40
81 #define MADCTL_MV 0x20
82 #define MADCTL_ML 0x10
83 #define MADCTL_BGR 0x08
84 #define MADCTL_RGB 0x00
85 #define MADCTL_MH 0x04
86 
87 #define ILI9341_NOP 0x00
88 #define ILI9341_SWRESET 0x01
89 #define ILI9341_RDDID 0x04
90 #define ILI9341_RDDST 0x09
91 
92 #define ILI9341_SLPIN 0x10
93 #define ILI9341_SLPOUT 0x11
94 #define ILI9341_PTLON 0x12
95 #define ILI9341_NORON 0x13
96 
97 #define ILI9341_RDMODE 0x0A
98 #define ILI9341_RDMADCTL 0x0B
99 #define ILI9341_RDPIXFMT 0x0C
100 #define ILI9341_RDIMGFMT 0x0A
101 #define ILI9341_RDSELFDIAG 0x0F
102 
103 #define ILI9341_INVOFF 0x20
104 #define ILI9341_INVON 0x21
105 #define ILI9341_GAMMASET 0x26
106 #define ILI9341_DISPOFF 0x28
107 #define ILI9341_DISPON 0x29
108 
109 #define ILI9341_CASET 0x2A
110 #define ILI9341_PASET 0x2B
111 #define ILI9341_RAMWR 0x2C
112 #define ILI9341_RAMRD 0x2E
113 
114 #define ILI9341_PTLAR 0x30
115 #define ILI9341_MADCTL 0x36
116 #define ILI9341_PIXFMT 0x3A
117 
118 #define ILI9341_FRMCTR1 0xB1
119 #define ILI9341_FRMCTR2 0xB2
120 #define ILI9341_FRMCTR3 0xB3
121 #define ILI9341_INVCTR 0xB4
122 #define ILI9341_DFUNCTR 0xB6
123 
124 #define ILI9341_PWCTR1 0xC0
125 #define ILI9341_PWCTR2 0xC1
126 #define ILI9341_PWCTR3 0xC2
127 #define ILI9341_PWCTR4 0xC3
128 #define ILI9341_PWCTR5 0xC4
129 #define ILI9341_VMCTR1 0xC5
130 #define ILI9341_VMCTR2 0xC7
131 
132 #define ILI9341_RDID1 0xDA
133 #define ILI9341_RDID2 0xDB
134 #define ILI9341_RDID3 0xDC
135 #define ILI9341_RDID4 0xDD
136 
137 #define ILI9341_GMCTRP1 0xE0
138 #define ILI9341_GMCTRN1 0xE1
139 /*
140 #define ILI9341_PWCTR6 0xFC
141 
142 // ========================================================================
143 */
144 
145 // Color definitions
146 #define ILI9341_BLACK 0x0000 /, 0, 0 */
147 #define ILI9341_NAVY 0x000F /* 0, 0, 128 */
148 #define ILI9341_DARKGREEN 0x03E0 /* 0, 128, 0 */
149 #define ILI9341_DARKCYAN 0x03EF /* 0, 128, 128 */
150 #define ILI9341_MAROON 0x7800 /* 128, 0, 0 */
151 #define ILI9341_PURPLE 0x780F /* 128, 0, 128 */
152 #define ILI9341_OLIVE 0x7BE0 /* 128, 128, 0 */
153 #define ILI9341_LIGHTGREY 0xC618 /* 192, 192, 192 */
154 #define ILI9341_DARKGREY 0x7BEF /* 128, 128, 128 */
155 #define ILI9341_BLUE 0x001F /* 0, 0, 255 */
156 #define ILI9341_GREEN 0x07E0 /* 0, 255, 0 */
157 #define ILI9341_CYAN 0x07FF /* 0, 255, 255 */
158 #define ILI9341_RED 0xF800 /* 255, 0, 0 */
159 #define ILI9341_MAGENTA 0xF81F /* 255, 0, 255 */
160 #define ILI9341_YELLOW 0xFFE0 /* 255, 255, 0 */
161 #define ILI9341_WHITE 0xFFFF /* 255, 255, 255 */
162 #define ILI9341_ORANGE 0xFD20 /* 255, 165, 0 */
163 #define ILI9341_GREENYELLOW 0xAFE5 /* 173, 255, 47 */
164 #define ILI9341_PINK 0xF81F
165 
166 #endif // _ILI9341_ADAFRUIT_H_
167 // ============================================================
168 
169 /* ili9341_adafruit.c */
170 MEMSPACE void tft_configRegister ( void );
171 MEMSPACE void tft_drawBitmap ( window *win , int16_t x , int16_t y , const uint16_t *bitmap , int16_t w , int16_t h );
172 MEMSPACE void tft_drawCircle ( window *win , int16_t x0 , int16_t y0 , int16_t r , uint16_t color );
173 MEMSPACE void tft_drawCircleHelper ( window *win , int16_t x0 , int16_t y0 , int16_t r , uint8_t cornername , uint16_t color );
174 MEMSPACE void tft_fillCircleHelper ( window *win , int16_t x0 , int16_t y0 , int16_t r , uint8_t cornername , int16_t delta , uint16_t color );
175 MEMSPACE void tft_fillCircle ( window *win , int16_t x0 , int16_t y0 , int16_t r , uint16_t color );
176 MEMSPACE void tft_drawRect ( window *win , int16_t x , int16_t y , int16_t w , int16_t h , uint16_t color );
177 MEMSPACE void tft_drawRoundRect ( window *win , int16_t x , int16_t y , int16_t w , int16_t h , int16_t r , uint16_t color );
178 MEMSPACE void tft_fillRoundRect ( window *win , int16_t x , int16_t y , int16_t w , int16_t h , int16_t r , uint16_t color );
179 MEMSPACE void tft_drawTriangle ( window *win , int16_t x0 , int16_t y0 , int16_t x1 , int16_t y1 , int16_t x2 , int16_t y2 , uint16_t color );
180 MEMSPACE void tft_fillTriangle ( window *win , int16_t x0 , int16_t y0 , int16_t x1 , int16_t y1 , int16_t x2 , int16_t y2 , uint16_t color );
MEMSPACE void tft_drawRect(window *win, int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
Draw a rectangle.
unsigned short uint16_t
Definition: send.c:18
MEMSPACE void tft_drawBitmap(window *win, int16_t x, int16_t y, const uint16_t *bitmap, int16_t w, int16_t h)
Draw bitmap Replaced by tft_writeRect()
MEMSPACE void tft_fillCircle(window *win, int16_t x0, int16_t y0, int16_t r, uint16_t color)
Fill circle.
int16_t y[XYSTACK+2]
Definition: ili9341.c:372
unsigned int uint32_t
Definition: send.c:19
MEMSPACE void tft_fillTriangle(window *win, int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
Fill a triangle.
MEMSPACE void tft_drawCircle(window *win, int16_t x0, int16_t y0, int16_t r, uint16_t color)
Draw a circle outline.
MEMSPACE void tft_fillRoundRect(window *win, int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint16_t color)
Fill a rounded rectangle.
int16_t x[XYSTACK+2]
Definition: ili9341.c:371
#define MEMSPACE
MEMSPACE void tft_drawTriangle(window *win, int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
Draw a triangle.
MEMSPACE void tft_drawCircleHelper(window *win, int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color)
Draw a circle helper.
Definition: ili9341.h:34
MEMSPACE void tft_fillCircleHelper(window *win, int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color)
Fill circle helper.
MEMSPACE void tft_drawRoundRect(window *win, int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint16_t color)
Draw a rounded rectangle.
ili9341 driver inspired by Adafruit ili9341 code All code in this file has been rewritten by Mike Gor...
unsigned char uint8_t
Definition: send.c:17
MEMSPACE void tft_configRegister(void)
Initialize ILI9341 display.