ILI9341 display driver (with SPI DMA) for STM32F4 targets. Fork of https://os.mbed.com/users/beaglescout007/code/Nucleo_Ex06_EMU/file/3dac1f1bc9e0/TFT/. Added support for STM32F407 (Seeed Arch Max).
Dependents: STM32F407VET6_Pong
tft.h
00001 /*===================================================================*/ 00002 /* */ 00003 /* tft.h : TFT(ILI9341) function header */ 00004 /* */ 00005 /* 2016/1/20 Racoon */ 00006 /* */ 00007 /*===================================================================*/ 00008 00009 #ifndef TFT_H 00010 #define TFT_H 00011 00012 #include "stm32f4xx_hal.h" 00013 #include "spidma.h" 00014 00015 #define TFT_WIDTH 320 00016 #define TFT_HEIGHT 240 00017 00018 #define TFT_WHITE 0xFFFF 00019 #define TFT_WHITESMOKE 0xBFFF 00020 #define TFT_GHOSTWHITE 0xDFFF 00021 #define TFT_ALICEBLUE 0xDFF7 00022 #define TFT_LAVENDAR 0x5FEF 00023 #define TFT_AZURE 0xFFF7 00024 #define TFT_LIGHTCYAN 0xFFE7 00025 #define TFT_MINTCREAM 0xFFFF 00026 #define TFT_HONEYDEW 0xFEF7 00027 #define TFT_IVORY 0xFEFF 00028 #define TFT_BEIGE 0xBCFF 00029 #define TFT_LIGHTYELLOW 0xFCFF 00030 #define TFT_LIGHTGOLDENRODYELLOW 0xFAFF 00031 #define TFT_LEMONCHIFFON 0xFAFF 00032 #define TFT_FLORALWHITE 0xFEFF 00033 #define TFT_OLDLACE 0xBDFF 00034 #define TFT_CORNSILK 0xDCFF 00035 #define TFT_PAPAYAWHITE 0x9BFF 00036 #define TFT_BLANCHEDALMOND 0x7AFF 00037 #define TFT_BISQUE 0x39FF 00038 #define TFT_SNOW 0xFFFF 00039 #define TFT_LINEN 0x9DFF 00040 #define TFT_ANTIQUEWHITE 0x7BFF 00041 #define TFT_SEASHELL 0xBEFF 00042 #define TFT_LAVENDERBLUSH 0x9FFF 00043 #define TFT_MISTYROSE 0x3CFF 00044 #define TFT_GAINSBORO 0xFCE6 00045 #define TFT_LIGHTGRAY 0xBAD6 00046 #define TFT_LIGHTSTEELBLUE 0x3CB6 00047 #define TFT_LIGHTBLUE 0xDDB6 00048 #define TFT_LIGHTSKYBLUE 0x9F8E 00049 #define TFT_POWDERBLUE 0x1DB7 00050 #define TFT_PALETURQUOISE 0x9EB7 00051 #define TFT_SKYBLUE 0x9D8E 00052 #define TFT_MEDIUMAQUAMARINE 0x756E 00053 #define TFT_AQUAMARINE 0xFB87 00054 #define TFT_PALEGREEN 0xF39F 00055 #define TFT_LIGHTGREEN 0x9297 00056 #define TFT_KHAKI 0x52F7 00057 #define TFT_PALEGOLDENROD 0x55F7 00058 #define TFT_MOCCASIN 0x37FF 00059 #define TFT_NAVAJOWHITE 0x16FF 00060 #define TFT_PEACHPUFF 0xF7FE 00061 #define TFT_WHEAT 0x16FF 00062 #define TFT_PINK 0x19FE 00063 #define TFT_LIGHTPINK 0xD8FD 00064 #define TFT_THISTLE 0x1BDE 00065 #define TFT_PLUM 0x1CE5 00066 #define TFT_SILVER 0x18C6 00067 #define TFT_DARKGRAY 0x55AD 00068 #define TFT_LIGHTSLATEGRAY 0x537C 00069 #define TFT_SLATEGRAY 0x1274 00070 #define TFT_SLATEBLUE 0xFA6A 00071 #define TFT_STEELBLUE 0x374C 00072 #define TFT_MEDIUMSLATEBLUE 0x5E7B 00073 #define TFT_ROYALBLUE 0x5C43 00074 #define TFT_BLUE 0x1F00 00075 #define TFT_DODGERBLUE 0x9F24 00076 #define TFT_CORNFLOWERBLUE 0xBE6C 00077 #define TFT_DEEPSKYBLUE 0x1F06 00078 #define TFT_CYAN 0xFF07 00079 #define TFT_AQUA 0xFF07 00080 #define TFT_TURQUOISE 0x1A47 00081 #define TFT_MEDIUMTURQUOISE 0x9A4E 00082 #define TFT_DARKTURQUOISE 0x9A06 00083 #define TFT_LIGHTSEAGREEN 0xB525 00084 #define TFT_MEDIUMSPRINGGREEN 0xF307 00085 #define TFT_SPRINGGREEN 0xF007 00086 #define TFT_LIME 0xE007 00087 #define TFT_LIMEGREEN 0x6636 00088 #define TFT_YELLOWGREEN 0x669E 00089 #define TFT_LAWNGREEN 0xE087 00090 #define TFT_CHARTREUSE 0xE087 00091 #define TFT_GREENYELLOW 0xE6B7 00092 #define TFT_YELLOW 0xE0FF 00093 #define TFT_GOLD 0xC0FE 00094 #define TFT_ORANGE 0x20FD 00095 #define TFT_DARKORANGE 0x60FC 00096 #define TFT_GOLDENROD 0x24DD 00097 #define TFT_BURLYWOOD 0xD1E5 00098 #define TFT_TAN 0xB2D5 00099 #define TFT_SANDYBROWN 0x2CFD 00100 #define TFT_DARKSALMON 0xCFEC 00101 #define TFT_LIGHTCORAL 0x10F4 00102 #define TFT_SALMON 0xEFC 00103 #define TFT_LIGHTSALMON 0xFFD 00104 #define TFT_CORAL 0xAFC 00105 #define TFT_TOMATO 0x29FB 00106 #define TFT_ORANGERED 0x20FA 00107 #define TFT_RED 0xF8 00108 #define TFT_DEEPPINK 0xB2F8 00109 #define TFT_HOTPINK 0x57FB 00110 #define TFT_PALEVIOLETRED 0x92DB 00111 #define TFT_VIOLET 0x3EF4 00112 #define TFT_ORCHID 0x9BDB 00113 #define TFT_MAGENTA 0x1FF8 00114 #define TFT_FUCHSIA 0x1FF8 00115 #define TFT_MEDIUMORCHID 0xBABA 00116 #define TFT_DARKORCHID 0xBA99 00117 #define TFT_DARKVIOLET 0x1A98 00118 #define TFT_BLUEVIOLET 0x7C89 00119 #define TFT_MEDIUMPURPLE 0x9B93 00120 #define TFT_GRAY 0x1084 00121 #define TFT_MEDIUMBLUE 0x1A00 00122 #define TFT_DARKCYAN 0x7104 00123 #define TFT_CADETBLUE 0x1465 00124 #define TFT_DARKSEAGREEN 0xF295 00125 #define TFT_MEDIUMSEAGREEN 0xAE45 00126 #define TFT_TEAL 0x1004 00127 #define TFT_FORESTGREEN 0x6424 00128 #define TFT_SEAGREEN 0x6B34 00129 #define TFT_DARKKHAKI 0xCDC5 00130 #define TFT_PERU 0x28D4 00131 #define TFT_CRIMSON 0xA8E0 00132 #define TFT_INDIANRED 0xECD2 00133 #define TFT_ROSYBROWN 0x92C4 00134 #define TFT_MEDIUMVIOLETRED 0xB1C8 00135 #define TFT_DIMGRAY 0x4D6B 00136 #define TFT_BLACK 0x0 00137 #define TFT_MIDNIGHTBLUE 0xCE18 00138 #define TFT_DARKSLATEBLUE 0xF149 00139 #define TFT_DARKBLUE 0x1100 00140 #define TFT_NAVY 0x1000 00141 #define TFT_DARKSLATEGRAY 0x8A32 00142 #define TFT_GREEN 0x4 00143 #define TFT_DARKGREEN 0x2003 00144 #define TFT_DARKOLIVEGREEN 0x665B 00145 #define TFT_OLIVEDRAB 0x846C 00146 #define TFT_OLIVE 0x84 00147 #define TFT_DARKGOLDENROD 0x41BC 00148 #define TFT_CHOCOLATE 0x44D3 00149 #define TFT_SIENNA 0xA6A2 00150 #define TFT_SADDLEBROWN 0x228A 00151 #define TFT_FIREBRICK 0x24B1 00152 #define TFT_BROWN 0x65A9 00153 #define TFT_MAROON 0x80 00154 #define TFT_DARKRED 0x88 00155 #define TFT_DARKMAGENTA 0x1188 00156 #define TFT_PURPLE 0x1080 00157 #define TFT_INDIGO 0x1048 00158 00159 const unsigned char chrimg[][7] = 00160 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 20h SP 00161 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, // 21h ! 00162 0x00, 0x28, 0x28, 0x00, 0x00, 0x00, 0x00, // 22h " 00163 0x00, 0x28, 0x7c, 0x28, 0x7c, 0x28, 0x00, // 23h # 00164 0x10, 0x3c, 0x50, 0x38, 0x14, 0x78, 0x10, // 24h $ 00165 0x00, 0x32, 0x54, 0x68, 0x16, 0x2a, 0x4c, // 25h % 00166 0x18, 0x24, 0x14, 0x38, 0x4e, 0x44, 0x3a, // 26h & 00167 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, // 27h ' 00168 0x04, 0x08, 0x10, 0x10, 0x10, 0x08, 0x04, // 28h ( 00169 0x40, 0x20, 0x10, 0x10, 0x10, 0x20, 0x40, // 29h ) 00170 0x10, 0x54, 0x38, 0xfe, 0x38, 0x54, 0x10, // 2Ah * 00171 0x10, 0x10, 0x10, 0xfe, 0x10, 0x10, 0x10, // 2Bh + 00172 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, // 2Ch , 00173 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, // 2Dh - 00174 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, // 2Eh . 00175 0x00, 0x08, 0x08, 0x10, 0x20, 0x20, 0x00, // 2Fh / 00176 00177 0x38, 0x44, 0x4c, 0x54, 0x64, 0x44, 0x38, // 30h 0 00178 0x10, 0x30, 0x10, 0x10, 0x10, 0x10, 0x38, // 31h 1 00179 0x38, 0x44, 0x04, 0x18, 0x20, 0x40, 0x7c, // 32h 2 00180 0x38, 0x44, 0x04, 0x18, 0x04, 0x44, 0x38, // 33h 3 00181 0x08, 0x18, 0x28, 0x48, 0x7c, 0x08, 0x08, // 34h 4 00182 0x7c, 0x40, 0x78, 0x04, 0x04, 0x44, 0x38, // 35h 5 00183 0x38, 0x44, 0x40, 0x78, 0x44, 0x44, 0x38, // 36h 6 00184 0x7c, 0x44, 0x04, 0x08, 0x08, 0x10, 0x10, // 37h 7 00185 0x38, 0x44, 0x44, 0x38, 0x44, 0x44, 0x38, // 38h 8 00186 0x38, 0x44, 0x44, 0x3c, 0x04, 0x44, 0x38, // 39h 9 00187 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, // 3Ah : 00188 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x20, // 3Bh ; 00189 0x08, 0x10, 0x20, 0x40, 0x20, 0x10, 0x08, // 3Ch < 00190 0x00, 0x00, 0x7c, 0x00, 0x7c, 0x00, 0x00, // 3Dh = 00191 0x20, 0x10, 0x08, 0x04, 0x08, 0x10, 0x20, // 3Eh > 00192 0x38, 0x44, 0x44, 0x08, 0x10, 0x00, 0x10, // 3Fh > 00193 00194 0x7c, 0x82, 0xba, 0xa6, 0xbc, 0x80, 0x7c, // 40h @ 00195 0x38, 0x44, 0x44, 0x44, 0x7c, 0x44, 0x44, // 41h A 00196 0x78, 0x44, 0x44, 0x78, 0x44, 0x44, 0x78, // 42h B 00197 0x38, 0x44, 0x40, 0x40, 0x40, 0x44, 0x38, // 43h C 00198 0x70, 0x48, 0x44, 0x44, 0x44, 0x48, 0x70, // 44h D 00199 0x7c, 0x40, 0x40, 0x78, 0x40, 0x40, 0x7c, // 45h E 00200 0x7c, 0x40, 0x40, 0x78, 0x40, 0x40, 0x40, // 46h F 00201 0x38, 0x44, 0x40, 0x4c, 0x44, 0x44, 0x38, // 47h G 00202 0x44, 0x44, 0x44, 0x7c, 0x44, 0x44, 0x44, // 48h H 00203 0x38, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38, // 49h I 00204 0x3c, 0x08, 0x08, 0x08, 0x08, 0x48, 0x30, // 4Ah J 00205 0x44, 0x48, 0x50, 0x60, 0x50, 0x48, 0x44, // 4Bh K 00206 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7c, // 4CH L 00207 0x44, 0x6c, 0x54, 0x54, 0x44, 0x44, 0x44, // 4DH M 00208 0x44, 0x64, 0x54, 0x54, 0x4c, 0x44, 0x44, // 4EH N 00209 0x38, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, // 4FH O 00210 00211 0x78, 0x44, 0x44, 0x78, 0x40, 0x40, 0x40, // 50h P 00212 0x38, 0x44, 0x44, 0x44, 0x54, 0x48, 0x34, // 51h Q 00213 0x78, 0x44, 0x44, 0x78, 0x44, 0x44, 0x44, // 52h R 00214 0x38, 0x44, 0x40, 0x38, 0x04, 0x44, 0x38, // 53h S 00215 0x7c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, // 54h T 00216 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, // 55h U 00217 0x44, 0x44, 0x44, 0x44, 0x28, 0x28, 0x10, // 56h V 00218 0x44, 0x44, 0x54, 0x54, 0x54, 0x54, 0x28, // 57h W 00219 0x44, 0x44, 0x28, 0x10, 0x28, 0x44, 0x44, // 58h X 00220 0x44, 0x44, 0x28, 0x10, 0x10, 0x10, 0x10, // 59h Y 00221 0x7c, 0x04, 0x08, 0x10, 0x20, 0x40, 0x7c, // 5Ah Z 00222 0x1c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1c, // 5Bh [ 00223 0x00, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, // 5Ch back slash 00224 0x70, 0x10, 0x10, 0x10, 0x10, 0x10, 0x70, // 5Dh ] 00225 0x00, 0x10, 0x28, 0x00, 0x00, 0x00, 0x00, // 5Eh ^ 00226 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c // 5Fh _ 00227 }; 00228 00229 #pragma pack(2) 00230 typedef struct tagBITMAPFILEHEADER { 00231 unsigned short bfType; 00232 unsigned long bfSize; 00233 unsigned short bfReserved1; 00234 unsigned short bfReserved2; 00235 unsigned long bfOffBits; 00236 } BITMAPFILEHEADER; 00237 00238 typedef struct tagBITMAPINFOHEADER{ 00239 unsigned long biSize; 00240 long biWidth; 00241 long biHeight; 00242 unsigned short biPlanes; 00243 unsigned short biBitCount; 00244 unsigned long biCompression; 00245 unsigned long biSizeImage; 00246 long biXPixPerMeter; 00247 long biYPixPerMeter; 00248 unsigned long biClrUsed; 00249 unsigned long biClrImporant; 00250 } BITMAPINFOHEADER; 00251 #pragma pack() 00252 00253 #pragma pack(1) 00254 typedef struct tagBMP24{ 00255 unsigned char B; 00256 unsigned char G; 00257 unsigned char R; 00258 } BMP24; 00259 #pragma pack() 00260 00261 void tft_init(); 00262 void tft_set_window(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1); 00263 void tft_clear(uint16_t color); 00264 void tft_put_char(int x, int y, char chr, uint16_t color, uint16_t bgcolor); 00265 void tft_text(int x, int y, char *text, uint16_t color, uint16_t bgcolor); 00266 void tft_hline(int x1, int y, int x2, uint16_t color); 00267 void tft_vline(int x, int y1, int y2, uint16_t color); 00268 void tft_box(int x1, int y1, int x2, int y2, uint16_t color); 00269 void tft_boxfill(int x1, int y1, int x2, int y2, uint16_t color); 00270 bool draw_bmp_4bpp(const unsigned char *imgdata, int x, int y); 00271 00272 #endif 00273
Generated on Sat Jul 16 2022 06:08:34 by 1.7.2