[51单片机] TFT2.4彩屏2 [32*32文字显示]

 

 

>_<:同理如果想显示其他形式的字体,就要建立相应的库啦,如这里还有一个gb3232的汉字库:GB3232.h

 1 // ------------------  汉字字模的数据结构定义 ------------------------ //
 2 struct  typFNT_GB32                 // 汉字字模数据结构 
 3 {
 4        unsigned char  Index[3];               // 汉字内码索引    
 5        unsigned char   Msk[128];                        // 点阵码数据 
 6 };
 7 
 8 /////////////////////////////////////////////////////////////////////////
 9 // 汉字字模表                                                          //
10 // 汉字库: 宋体32.dot,横向取模左高位,数据排列:从左到右从上到下         //
11 /////////////////////////////////////////////////////////////////////////
12  code struct  typFNT_GB32 codeGB_32[] =          // 数据表 
13 {
14 /*--  文字:  我  --*/
15 /*--  宋体22;  此字体下对应的点阵为:宽x高=29x29   --*/
16 /*--  宽度不是8的倍数,现调整为:宽度x高度=32x29  --*/
17 "",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0xC0,0x00,0x00,0x7D,0xF8,0x00,
18 0x03,0xFD,0xCE,0x00,0x3F,0xC1,0xC7,0x00,0x00,0xC1,0xC7,0x00,0x00,0xC1,0xC3,0x00,
19 0x00,0xC1,0xC3,0x00,0x00,0xC1,0xC0,0xC0,0x3F,0xFF,0xFF,0xE0,0x20,0xC0,0xC0,0x00,
20 0x00,0xC0,0xC2,0x00,0x00,0xC0,0xC7,0x80,0x00,0xC2,0xC7,0x80,0x00,0xDE,0xCF,0x00,
21 0x00,0xF8,0xCE,0x00,0x0F,0xE0,0xFC,0x00,0x7F,0xC0,0xF8,0x00,0x3C,0xC0,0x78,0x00,
22 0x30,0xC0,0x70,0x20,0x00,0xC1,0xF8,0x20,0x00,0xC3,0xB8,0x20,0x00,0xC7,0x1E,0x20,
23 0x00,0xDC,0x0F,0x60,0x0F,0xF0,0x07,0xE0,0x03,0xC0,0x03,0xF0,0x01,0x80,0x00,0x70,
24 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
25 
26 /*--  文字:  爱  --*/
27 /*--  宋体22;  此字体下对应的点阵为:宽x高=29x29   --*/
28 /*--  宽度不是8的倍数,现调整为:宽度x高度=32x29  --*/
29 "",0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x3F,0x80,0x00,0x3F,0xFF,0x80,
30 0x0F,0xFF,0x06,0x00,0x01,0x86,0x0F,0x00,0x00,0xC3,0x0E,0x00,0x00,0xE3,0x9C,0x00,
31 0x08,0x63,0x98,0x00,0x08,0x41,0x10,0xC0,0x0F,0xFF,0xFF,0xE0,0x18,0x18,0x01,0xC0,
32 0x38,0x1C,0x01,0x80,0x38,0x1C,0x03,0x00,0x0F,0xFF,0xFF,0x00,0x0F,0xFF,0xFF,0x00,
33 0x00,0x38,0x00,0x00,0x00,0x3F,0xFC,0x00,0x00,0x3F,0xFE,0x00,0x00,0x7C,0x1C,0x00,
34 0x00,0x6C,0x38,0x00,0x00,0xC6,0x70,0x00,0x01,0xC3,0xE0,0x00,0x03,0x81,0xC0,0x00,
35 0x07,0x07,0xFC,0x00,0x0C,0x1E,0x3F,0xF0,0x38,0xF8,0x0F,0xE0,0x03,0xC0,0x00,0xC0,
36 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
37 
38 /*--  文字:  单  --*/
39 /*--  宋体22;  此字体下对应的点阵为:宽x高=29x29   --*/
40 /*--  宽度不是8的倍数,现调整为:宽度x高度=32x29  --*/
41 "",0x00,0x00,0x00,0x00,0x00,0x80,0x30,0x00,0x00,0xE0,0x38,0x00,0x00,0x70,0x38,0x00,
42 0x00,0x38,0x60,0x00,0x00,0x38,0x60,0x00,0x06,0x10,0xC6,0x00,0x07,0xFF,0xFF,0x00,
43 0x07,0x06,0x06,0x00,0x07,0x06,0x06,0x00,0x07,0x06,0x06,0x00,0x07,0xFF,0xFE,0x00,
44 0x07,0xFF,0xFE,0x00,0x07,0x06,0x06,0x00,0x07,0x06,0x06,0x00,0x07,0x06,0x06,0x00,
45 0x07,0xFF,0xFE,0x00,0x07,0x06,0x06,0x00,0x06,0x06,0x00,0x00,0x00,0x06,0x00,0xE0,
46 0x7F,0xFF,0xFF,0xF0,0x20,0x06,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x06,0x00,0x00,
47 0x00,0x06,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x06,0x00,0x00,
48 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
49 
50 /*--  文字:  片  --*/
51 /*--  宋体22;  此字体下对应的点阵为:宽x高=29x29   --*/
52 /*--  宽度不是8的倍数,现调整为:宽度x高度=32x29  --*/
53 "",0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x01,0x00,0xF0,0x00,0x01,0xC0,0xE0,0x00,
54 0x01,0xC0,0xE0,0x00,0x01,0x80,0xE0,0x00,0x01,0x80,0xE0,0x00,0x01,0x80,0xE0,0x00,
55 0x01,0x80,0xE0,0x80,0x01,0x80,0xE1,0xC0,0x01,0xFF,0xFF,0xE0,0x01,0x80,0x00,0x00,
56 0x01,0x80,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x30,0x00,0x01,0xFF,0xF8,0x00,
57 0x01,0xFF,0xF8,0x00,0x01,0x80,0x30,0x00,0x03,0x80,0x30,0x00,0x03,0x80,0x30,0x00,
58 0x03,0x00,0x30,0x00,0x07,0x00,0x30,0x00,0x06,0x00,0x30,0x00,0x0E,0x00,0x30,0x00,
59 0x0C,0x00,0x30,0x00,0x18,0x00,0x30,0x00,0x30,0x00,0x38,0x00,0x20,0x00,0x30,0x00,
60 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
61 
62 /*--  文字:  机  --*/
63 /*--  宋体22;  此字体下对应的点阵为:宽x高=29x29   --*/
64 /*--  宽度不是8的倍数,现调整为:宽度x高度=32x29  --*/
65 "",0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x03,0x06,0x06,0x00,
66 0x03,0x07,0xFF,0x00,0x03,0x07,0x0F,0x00,0x03,0x07,0x0E,0x00,0x03,0x37,0x0E,0x00,
67 0x7F,0xF7,0x0E,0x00,0x3F,0xFF,0x0E,0x00,0x03,0x07,0x0E,0x00,0x07,0x07,0x0E,0x00,
68 0x07,0x87,0x0E,0x00,0x07,0xE7,0x0E,0x00,0x0F,0x77,0x0E,0x00,0x0F,0x3F,0x0E,0x00,
69 0x0F,0x17,0x0E,0x00,0x1B,0x07,0x0E,0x00,0x1B,0x06,0x0E,0x00,0x33,0x06,0x0E,0x00,
70 0x33,0x06,0x0E,0x20,0x63,0x0E,0x0E,0x60,0x43,0x0C,0x0E,0x60,0x03,0x1C,0x0E,0x60,
71 0x03,0x18,0x0E,0x70,0x03,0x30,0x07,0xF0,0x03,0x60,0x07,0xE0,0x03,0x40,0x00,0x00,
72 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
73 
74 };

 

>_<:则模仿上一个博客里彩屏模版里的的GB1616的代码有:

 1 #include "GB3232.h"    //32*32汉字字模
 2 
 3 void PutGB3232(unsigned short x, unsigned short  y, unsigned char c[2], unsigned int fColor,unsigned int bColor){
 4     unsigned int i,j,k;
 5     
 6     LCD_SetPos(x,  x+32-1,y, y+32-1);
 7     
 8     for (k=0;k<5;k++) { //5标示自建汉字库中的个数,循环查询内码
 9         if ((codeGB_32[k].Index[0]==c[0])&&(codeGB_32[k].Index[1]==c[1])){ 
10             for(i=0;i<128;i++) {
11                 unsigned short m=codeGB_32[k].Msk[i];
12                 for(j=0;j<8;j++) {
13                     if((m&0x80)==0x80) {
14                         Write_Data_U16(fColor);
15                     }
16                     else {
17                         Write_Data_U16(bColor);
18                     }
19                     m<<=1;
20                 } 
21             }
22         }  
23     }    
24 }

 

posted @ 2014-04-04 21:16  beautifulzzzz  阅读(1775)  评论(0编辑  收藏  举报