打开/关闭菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

【教程】中英文显示取模设置

来自LCD wiki
Lin留言 | 贡献2019年7月19日 (五) 16:37的版本 →‎英文字符取模

取模软件配置

测试示例所用的字体取模软件为PCtoLCD2002,关于它的详细使用说明见如下文档:

PCtoLCD2002使用说明

PCtoLCD2002软件具体设置如下:

  • 字体和尺寸选择
模式需要选择字符模式
字体可以根据需求选择,比如选择宋体
字宽和字高可以根据需求选择,中英文常用的字体尺寸如下:
中文(字宽x字高):16x16、24x24、32x32
英文(字库x字高):6x8、6x12、8x16、12x24、16x32(对应的字体尺寸需要分别设置为12x8、12x12、16x16、24x24、32x32)
修改点阵大小可以根据需求设置,一般设置为0
  • 字模选项设置
字模选项设置有多种情况,不同的设置,代码处理方法不一样。这里就选取下面的设置为例,后续的函数代码都是基于此设置编写。
点阵格式选择阴码
取模方式选择逐行式
取模走向选择顺向(高位在前)
输出数制选择十六进制数
自定义格式选择C51格式

底层支撑函数

  • LCD_SetWindows
该函数实现因驱动IC而异(不同的驱动IC设置坐标值命令和原理有差异),但是原理基本一样,都是设置起始坐标和结束坐标,设置一块显示区域
举例如下(ILI9341为例)
void LCD_SetWindows(u16 xStar, u16 yStar,u16 xEnd,u16 yEnd)
{	
	LCD_WR_REG(lcddev.setxcmd);	
	LCD_WR_DATA(xStar>>8);
	LCD_WR_DATA(0x00FF&xStar);		
	LCD_WR_DATA(xEnd>>8);
	LCD_WR_DATA(0x00FF&xEnd);

	LCD_WR_REG(lcddev.setycmd);	
	LCD_WR_DATA(yStar>>8);
	LCD_WR_DATA(0x00FF&yStar);		
	LCD_WR_DATA(yEnd>>8);
	LCD_WR_DATA(0x00FF&yEnd);

	LCD_WriteRAM_Prepare();	//开始写入GRAM		
}
  • Lcd_WriteData_16Bit
该函数就是往GRAM里面设置像素颜色值,然后显示出来
举例如下(ILI9341为例)
void Lcd_WriteData_16Bit(u16 Data)
{	
      LCD_CS_CLR;
      LCD_RS_SET;  
      SPI_WriteByte(SPI2,Data>>8);
      SPI_WriteByte(SPI2,Data);
      LCD_CS_SET;
}
  • LCD_DrawPoint
其实就是利用LCD_SetWindows函数和Lcd_WriteData_16Bit函数显示一个像素点
举例如下(ILI9341为例)
void LCD_DrawPoint(u16 x,u16 y)
{
	LCD_SetCursor(x,y);//设置光标位置 
	Lcd_WriteData_16Bit(POINT_COLOR); 
}

英文字符取模

  • 重要说明
因为在程序里是按照ASCII码偏移量搜索需要显示的英文字符的,所以需要将整套ASCII字符都取模。
ASCII码字符如下所示(最前面的空格也要包含):
ASCII字符: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
  • 6x8英文字体取模说明
尺寸设置如下图所示:
取模如下:
const unsigned char asc2_0806[95][8]={
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/
{0x00,0x20,0x20,0x20,0x20,0x00,0x20,0x00},/*"!",1*/
{0x00,0x28,0x50,0x00,0x00,0x00,0x00,0x00},/*""",2*/
{0x00,0x00,0x28,0xFC,0x70,0xFC,0x50,0x00},/*"#",3*/
{0x00,0x20,0xF8,0xA0,0x70,0xA8,0xF8,0x20},/*"$",4*/
{0x00,0x00,0x48,0xB0,0x58,0x34,0x48,0x00},/*"%",5*/
{0x00,0x00,0x70,0x58,0x68,0xB0,0xEC,0x00},/*"&",6*/
{0x00,0x40,0x80,0x00,0x00,0x00,0x00,0x00},/*"'",7*/
{0x00,0x04,0x08,0x10,0x10,0x10,0x08,0x04},/*"(",8*/
{0x00,0x40,0x20,0x10,0x10,0x10,0x20,0x40},/*")",9*/
{0x00,0x00,0x20,0xF8,0xF8,0x20,0x00,0x00},/*"*",10*/
{0x00,0x20,0x20,0xF8,0x20,0x20,0x00,0x00},/*"+",11*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x80},/*",",12*/
{0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00},/*"-",13*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00},/*".",14*/
{0x00,0x08,0x10,0x10,0x20,0x40,0x40,0x80},/*"/",15*/
{0x00,0x00,0x70,0x88,0x88,0x88,0x70,0x00},/*"0",16*/
{0x00,0x00,0x20,0x60,0x20,0x20,0x70,0x00},/*"1",17*/
{0x00,0x00,0x78,0x88,0x10,0x60,0xF8,0x00},/*"2",18*/
{0x00,0x00,0x78,0xB0,0x08,0x88,0x70,0x00},/*"3",19*/
{0x00,0x00,0x30,0x50,0x90,0x78,0x10,0x00},/*"4",20*/
{0x00,0x00,0xF8,0x80,0xF8,0x88,0x70,0x00},/*"5",21*/
{0x00,0x00,0x70,0x80,0xF8,0x88,0x70,0x00},/*"6",22*/
{0x00,0x00,0xF8,0x90,0x20,0x20,0x20,0x00},/*"7",23*/
{0x00,0x00,0xF8,0x88,0x70,0x88,0x78,0x00},/*"8",24*/
{0x00,0x00,0x70,0x88,0xF8,0x08,0x70,0x00},/*"9",25*/
{0x00,0x00,0x00,0x20,0x00,0x00,0x20,0x00},/*":",26*/
{0x00,0x00,0x00,0x20,0x00,0x00,0x20,0x20},/*";",27*/
{0x00,0x00,0x08,0x10,0x60,0x10,0x08,0x00},/*"<",28*/
{0x00,0x00,0x00,0xF8,0x00,0xF8,0x00,0x00},/*"=",29*/
{0x00,0x00,0x40,0x30,0x0C,0x10,0x60,0x00},/*">",30*/
{0x00,0x70,0x88,0x10,0x20,0x00,0x20,0x00},/*"?",31*/
{0x00,0x00,0x70,0x98,0xA8,0xB8,0x70,0x00},/*"@",32*/
{0x00,0x00,0x20,0x30,0x50,0x78,0xCC,0x00},/*"A",33*/
{0x00,0x00,0xF8,0x70,0x48,0x48,0xF0,0x00},/*"B",34*/
{0x00,0x00,0x78,0x80,0x80,0x88,0x70,0x00},/*"C",35*/
{0x00,0x00,0xF0,0x48,0x48,0x48,0xF0,0x00},/*"D",36*/
{0x00,0x00,0xF8,0x70,0x50,0x40,0xF8,0x00},/*"E",37*/
{0x00,0x00,0xF8,0x70,0x50,0x40,0xE0,0x00},/*"F",38*/
{0x00,0x00,0x78,0x80,0x80,0x9C,0x70,0x00},/*"G",39*/
{0x00,0x00,0xCC,0x48,0x78,0x48,0xCC,0x00},/*"H",40*/
{0x00,0x00,0xF8,0x20,0x20,0x20,0xF8,0x00},/*"I",41*/
{0x00,0x00,0x7C,0x10,0x10,0x10,0x10,0xF0},/*"J",42*/
{0x00,0x00,0xEC,0x70,0x70,0x58,0xFC,0x00},/*"K",43*/
{0x00,0x00,0xE0,0x40,0x40,0x40,0xFC,0x00},/*"L",44*/
{0x00,0x00,0xD8,0xD8,0xE8,0xA8,0xA8,0x00},/*"M",45*/
{0x00,0x00,0xDC,0x68,0x68,0x58,0xE8,0x00},/*"N",46*/
{0x00,0x00,0x70,0x88,0x88,0x88,0x70,0x00},/*"O",47*/
{0x00,0x00,0xF8,0x48,0x78,0x40,0xE0,0x00},/*"P",48*/
{0x00,0x00,0x70,0x88,0x88,0xE8,0x70,0x18},/*"Q",49*/
{0x00,0x00,0xF8,0x78,0x50,0x48,0xEC,0x00},/*"R",50*/
{0x00,0x00,0xF8,0x80,0x70,0x88,0xF8,0x00},/*"S",51*/
{0x00,0x00,0xF8,0x20,0x20,0x20,0x70,0x00},/*"T",52*/
{0x00,0x00,0xCC,0x48,0x48,0x48,0x78,0x00},/*"U",53*/
{0x00,0x00,0xDC,0x48,0x50,0x30,0x20,0x00},/*"V",54*/
{0x00,0x00,0xA8,0xA8,0x50,0x50,0x50,0x00},/*"W",55*/
{0x00,0x00,0xF8,0x50,0x20,0x50,0xF8,0x00},/*"X",56*/
{0x00,0x00,0xF8,0x50,0x20,0x20,0x70,0x00},/*"Y",57*/
{0x00,0x00,0xF8,0x10,0x20,0x60,0xF8,0x00},/*"Z",58*/
{0x00,0x38,0x20,0x20,0x20,0x20,0x20,0x38},/*"[",59*/
{0x00,0x40,0x40,0x20,0x20,0x10,0x08,0x00},/*"\",60*/
{0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x70},/*"]",61*/
{0x00,0x20,0x50,0x00,0x00,0x00,0x00,0x00},/*"^",62*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC},/*"_",63*/
{0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00},/*"`",64*/
{0x00,0x00,0x00,0x78,0x38,0x48,0x7C,0x00},/*"a",65*/
{0x00,0x00,0xC0,0x70,0x48,0x48,0x70,0x00},/*"b",66*/
{0x00,0x00,0x00,0x38,0x40,0x40,0x38,0x00},/*"c",67*/
{0x00,0x00,0x18,0x38,0x48,0x48,0x3C,0x00},/*"d",68*/
{0x00,0x00,0x00,0x30,0x78,0x40,0x38,0x00},/*"e",69*/
{0x00,0x00,0x3C,0x78,0x20,0x20,0x78,0x00},/*"f",70*/
{0x00,0x00,0x00,0x7C,0x78,0x40,0x7C,0x7C},/*"g",71*/
{0x00,0x00,0xC0,0x78,0x48,0x48,0xEC,0x00},/*"h",72*/
{0x00,0x00,0x20,0x60,0x20,0x20,0x70,0x00},/*"i",73*/
{0x00,0x00,0x10,0x30,0x10,0x10,0x10,0xE0},/*"j",74*/
{0x00,0x00,0xC0,0x5C,0x50,0x70,0xEC,0x00},/*"k",75*/
{0x00,0x20,0xE0,0x20,0x20,0x20,0xF8,0x00},/*"l",76*/
{0x00,0x00,0x00,0xF8,0xA8,0xA8,0xA8,0x00},/*"m",77*/
{0x00,0x00,0x00,0xF8,0x48,0x48,0xEC,0x00},/*"n",78*/
{0x00,0x00,0x00,0x30,0x48,0x48,0x30,0x00},/*"o",79*/
{0x00,0x00,0x00,0xF8,0x48,0x48,0x70,0xE0},/*"p",80*/
{0x00,0x00,0x00,0x38,0x48,0x48,0x38,0x1C},/*"q",81*/
{0x00,0x00,0x00,0xD8,0x60,0x40,0xE0,0x00},/*"r",82*/
{0x00,0x00,0x00,0x78,0x40,0x38,0x78,0x00},/*"s",83*/
{0x00,0x00,0x20,0x70,0x20,0x20,0x38,0x00},/*"t",84*/
{0x00,0x00,0x00,0xD8,0x48,0x48,0x7C,0x00},/*"u",85*/
{0x00,0x00,0x00,0xEC,0x48,0x30,0x20,0x00},/*"v",86*/
{0x00,0x00,0x00,0xA8,0xB8,0x50,0x50,0x00},/*"w",87*/
{0x00,0x00,0x00,0xD8,0x70,0x70,0xD8,0x00},/*"x",88*/
{0x00,0x00,0x00,0xEC,0x58,0x30,0x20,0xC0},/*"y",89*/
{0x00,0x00,0x00,0x78,0x10,0x20,0x78,0x00},/*"z",90*/
{0x00,0x18,0x10,0x10,0x30,0x10,0x10,0x18},/*"{",91*/
{0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10},/*"",92*/
{0x00,0x60,0x20,0x20,0x30,0x20,0x20,0x60},/*"}",93*/
{0x64,0x98,0x00,0x00,0x00,0x00,0x00,0x00}/*"~",94*/
}
函数定义如下:
static void LCD_Show_0806_char(u16 x,u16 y,u16 fc, u16 bc, u8 num,u8 mode)
{
    u8 temp;
    u8 pos,t;
    u16 colortemp=POINT_COLOR;      		   
    num=num-' ';//得到偏移后的值
    LCD_SetWindows(x,y,x+6-1,y+8-1);//设置单个文字显示窗口
    if(!mode) //非叠加方式:字体带有背景色,显示时会将原来显示的内容覆盖掉
    {		
        for(pos=0;pos<8;pos++)
	{
	    temp = asc2_0806[num][pos];//调用0806字体,需要自己取模定义
	    for(t=0;t<6;t++)
            {                 
	        if(temp&0x80)
	        {
		    Lcd_WriteData_16Bit(fc);
		}
		else 
		{
		    Lcd_WriteData_16Bit(bc); 
		}
		temp<<=1;
	    }
			
	}	
    }
    else//叠加方式:字体不带背景色,直接叠加显示到原来显示的内容上
    {
	for(pos=0;pos<8;pos++)
	{
	    temp = asc2_0806[num][pos];//调用0806字体,需要自己取模定义
	    for(t=0;t<6;t++)
            {   
		POINT_COLOR=fc;              
		if(temp&0x80)
		{
		    LCD_DrawPoint(x+t,y+pos);//画一个点    
		}
		temp<<=1;
	    }
	}
    }
    POINT_COLOR=colortemp;	
    LCD_SetWindows(0,0,lcddev.width-1,lcddev.height-1);//恢复窗口为全屏     	   
}
  • 6x12英文字体取模说明
尺寸设置如下图所示:
取模如下:
const unsigned char asc2_1206[95][12]={
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/
{0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00,0x00},/*"!",1*/
{0x00,0x28,0x50,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*""",2*/
{0x00,0x00,0x28,0x28,0xFC,0x28,0x50,0xFC,0x50,0x50,0x00,0x00},/*"#",3*/
{0x00,0x20,0x78,0xA8,0xA0,0x60,0x30,0x28,0xA8,0xF0,0x20,0x00},/*"$",4*/
{0x00,0x00,0x48,0xA8,0xB0,0x50,0x28,0x34,0x54,0x48,0x00,0x00},/*"%",5*/
{0x00,0x00,0x20,0x50,0x50,0x78,0xA8,0xA8,0x90,0x6C,0x00,0x00},/*"&",6*/
{0x00,0x40,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"'",7*/
{0x00,0x04,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x08,0x04,0x00},/*"(",8*/
{0x00,0x40,0x20,0x10,0x10,0x10,0x10,0x10,0x10,0x20,0x40,0x00},/*")",9*/
{0x00,0x00,0x00,0x20,0xA8,0x70,0x70,0xA8,0x20,0x00,0x00,0x00},/*"*",10*/
{0x00,0x00,0x20,0x20,0x20,0xF8,0x20,0x20,0x20,0x00,0x00,0x00},/*"+",11*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x80},/*",",12*/
{0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00},/*"-",13*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00},/*".",14*/
{0x00,0x08,0x10,0x10,0x10,0x20,0x20,0x40,0x40,0x40,0x80,0x00},/*"/",15*/
{0x00,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x00},/*"0",16*/
{0x00,0x00,0x20,0x60,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00},/*"1",17*/
{0x00,0x00,0x70,0x88,0x88,0x10,0x20,0x40,0x80,0xF8,0x00,0x00},/*"2",18*/
{0x00,0x00,0x70,0x88,0x08,0x30,0x08,0x08,0x88,0x70,0x00,0x00},/*"3",19*/
{0x00,0x00,0x10,0x30,0x50,0x50,0x90,0x78,0x10,0x18,0x00,0x00},/*"4",20*/
{0x00,0x00,0xF8,0x80,0x80,0xF0,0x08,0x08,0x88,0x70,0x00,0x00},/*"5",21*/
{0x00,0x00,0x70,0x90,0x80,0xF0,0x88,0x88,0x88,0x70,0x00,0x00},/*"6",22*/
{0x00,0x00,0xF8,0x90,0x10,0x20,0x20,0x20,0x20,0x20,0x00,0x00},/*"7",23*/
{0x00,0x00,0x70,0x88,0x88,0x70,0x88,0x88,0x88,0x70,0x00,0x00},/*"8",24*/
{0x00,0x00,0x70,0x88,0x88,0x88,0x78,0x08,0x48,0x70,0x00,0x00},/*"9",25*/
{0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x20,0x00,0x00},/*":",26*/
{0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x20,0x20,0x00},/*";",27*/
{0x00,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x00,0x00},/*"<",28*/
{0x00,0x00,0x00,0x00,0xF8,0x00,0x00,0xF8,0x00,0x00,0x00,0x00},/*"=",29*/
{0x00,0x40,0x20,0x10,0x08,0x04,0x08,0x10,0x20,0x40,0x00,0x00},/*">",30*/
{0x00,0x00,0x70,0x88,0x88,0x10,0x20,0x20,0x00,0x20,0x00,0x00},/*"?",31*/
{0x00,0x00,0x70,0x88,0x98,0xA8,0xA8,0xB8,0x80,0x78,0x00,0x00},/*"@",32*/
{0x00,0x00,0x20,0x20,0x30,0x50,0x50,0x78,0x48,0xCC,0x00,0x00},/*"A",33*/
{0x00,0x00,0xF0,0x48,0x48,0x70,0x48,0x48,0x48,0xF0,0x00,0x00},/*"B",34*/
{0x00,0x00,0x78,0x88,0x80,0x80,0x80,0x80,0x88,0x70,0x00,0x00},/*"C",35*/
{0x00,0x00,0xF0,0x48,0x48,0x48,0x48,0x48,0x48,0xF0,0x00,0x00},/*"D",36*/
{0x00,0x00,0xF8,0x48,0x50,0x70,0x50,0x40,0x48,0xF8,0x00,0x00},/*"E",37*/
{0x00,0x00,0xF8,0x48,0x50,0x70,0x50,0x40,0x40,0xE0,0x00,0x00},/*"F",38*/
{0x00,0x00,0x38,0x48,0x80,0x80,0x9C,0x88,0x48,0x30,0x00,0x00},/*"G",39*/
{0x00,0x00,0xCC,0x48,0x48,0x78,0x48,0x48,0x48,0xCC,0x00,0x00},/*"H",40*/
{0x00,0x00,0xF8,0x20,0x20,0x20,0x20,0x20,0x20,0xF8,0x00,0x00},/*"I",41*/
{0x00,0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x90,0xE0,0x00},/*"J",42*/
{0x00,0x00,0xEC,0x48,0x50,0x60,0x50,0x50,0x48,0xEC,0x00,0x00},/*"K",43*/
{0x00,0x00,0xE0,0x40,0x40,0x40,0x40,0x40,0x44,0xFC,0x00,0x00},/*"L",44*/
{0x00,0x00,0xD8,0xD8,0xD8,0xD8,0xA8,0xA8,0xA8,0xA8,0x00,0x00},/*"M",45*/
{0x00,0x00,0xDC,0x48,0x68,0x68,0x58,0x58,0x48,0xE8,0x00,0x00},/*"N",46*/
{0x00,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x00},/*"O",47*/
{0x00,0x00,0xF0,0x48,0x48,0x70,0x40,0x40,0x40,0xE0,0x00,0x00},/*"P",48*/
{0x00,0x00,0x70,0x88,0x88,0x88,0x88,0xE8,0x98,0x70,0x18,0x00},/*"Q",49*/
{0x00,0x00,0xF0,0x48,0x48,0x70,0x50,0x48,0x48,0xEC,0x00,0x00},/*"R",50*/
{0x00,0x00,0x78,0x88,0x80,0x60,0x10,0x08,0x88,0xF0,0x00,0x00},/*"S",51*/
{0x00,0x00,0xF8,0xA8,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00},/*"T",52*/
{0x00,0x00,0xCC,0x48,0x48,0x48,0x48,0x48,0x48,0x30,0x00,0x00},/*"U",53*/
{0x00,0x00,0xCC,0x48,0x48,0x50,0x50,0x30,0x20,0x20,0x00,0x00},/*"V",54*/
{0x00,0x00,0xA8,0xA8,0xA8,0x70,0x50,0x50,0x50,0x50,0x00,0x00},/*"W",55*/
{0x00,0x00,0xD8,0x50,0x50,0x20,0x20,0x50,0x50,0xD8,0x00,0x00},/*"X",56*/
{0x00,0x00,0xD8,0x50,0x50,0x20,0x20,0x20,0x20,0x70,0x00,0x00},/*"Y",57*/
{0x00,0x00,0xF8,0x90,0x10,0x20,0x20,0x40,0x48,0xF8,0x00,0x00},/*"Z",58*/
{0x00,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x38,0x00},/*"[",59*/
{0x00,0x40,0x40,0x40,0x20,0x20,0x10,0x10,0x10,0x08,0x00,0x00},/*"\",60*/
{0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x70,0x00},/*"]",61*/
{0x00,0x20,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"^",62*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC},/*"_",63*/
{0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"`",64*/
{0x00,0x00,0x00,0x00,0x00,0x30,0x48,0x38,0x48,0x3C,0x00,0x00},/*"a",65*/
{0x00,0x00,0xC0,0x40,0x40,0x70,0x48,0x48,0x48,0x70,0x00,0x00},/*"b",66*/
{0x00,0x00,0x00,0x00,0x00,0x38,0x48,0x40,0x40,0x38,0x00,0x00},/*"c",67*/
{0x00,0x00,0x18,0x08,0x08,0x38,0x48,0x48,0x48,0x3C,0x00,0x00},/*"d",68*/
{0x00,0x00,0x00,0x00,0x00,0x30,0x48,0x78,0x40,0x38,0x00,0x00},/*"e",69*/
{0x00,0x00,0x1C,0x20,0x20,0x78,0x20,0x20,0x20,0x78,0x00,0x00},/*"f",70*/
{0x00,0x00,0x00,0x00,0x00,0x3C,0x48,0x30,0x40,0x78,0x44,0x38},/*"g",71*/
{0x00,0x00,0xC0,0x40,0x40,0x70,0x48,0x48,0x48,0xEC,0x00,0x00},/*"h",72*/
{0x00,0x00,0x20,0x00,0x00,0x60,0x20,0x20,0x20,0x70,0x00,0x00},/*"i",73*/
{0x00,0x00,0x10,0x00,0x00,0x30,0x10,0x10,0x10,0x10,0x10,0xE0},/*"j",74*/
{0x00,0x00,0xC0,0x40,0x40,0x5C,0x50,0x70,0x48,0xEC,0x00,0x00},/*"k",75*/
{0x00,0x00,0xE0,0x20,0x20,0x20,0x20,0x20,0x20,0xF8,0x00,0x00},/*"l",76*/
{0x00,0x00,0x00,0x00,0x00,0xF0,0xA8,0xA8,0xA8,0xA8,0x00,0x00},/*"m",77*/
{0x00,0x00,0x00,0x00,0x00,0xF0,0x48,0x48,0x48,0xEC,0x00,0x00},/*"n",78*/
{0x00,0x00,0x00,0x00,0x00,0x30,0x48,0x48,0x48,0x30,0x00,0x00},/*"o",79*/
{0x00,0x00,0x00,0x00,0x00,0xF0,0x48,0x48,0x48,0x70,0x40,0xE0},/*"p",80*/
{0x00,0x00,0x00,0x00,0x00,0x38,0x48,0x48,0x48,0x38,0x08,0x1C},/*"q",81*/
{0x00,0x00,0x00,0x00,0x00,0xD8,0x60,0x40,0x40,0xE0,0x00,0x00},/*"r",82*/
{0x00,0x00,0x00,0x00,0x00,0x78,0x40,0x30,0x08,0x78,0x00,0x00},/*"s",83*/
{0x00,0x00,0x00,0x20,0x20,0x70,0x20,0x20,0x20,0x18,0x00,0x00},/*"t",84*/
{0x00,0x00,0x00,0x00,0x00,0xD8,0x48,0x48,0x48,0x3C,0x00,0x00},/*"u",85*/
{0x00,0x00,0x00,0x00,0x00,0xEC,0x48,0x50,0x30,0x20,0x00,0x00},/*"v",86*/
{0x00,0x00,0x00,0x00,0x00,0xA8,0xA8,0x70,0x50,0x50,0x00,0x00},/*"w",87*/
{0x00,0x00,0x00,0x00,0x00,0xD8,0x50,0x20,0x50,0xD8,0x00,0x00},/*"x",88*/
{0x00,0x00,0x00,0x00,0x00,0xEC,0x48,0x50,0x30,0x20,0x20,0xC0},/*"y",89*/
{0x00,0x00,0x00,0x00,0x00,0x78,0x10,0x20,0x20,0x78,0x00,0x00},/*"z",90*/
{0x00,0x18,0x10,0x10,0x10,0x20,0x10,0x10,0x10,0x10,0x18,0x00},/*"{",91*/
{0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10},/*"",92*/
{0x00,0x60,0x20,0x20,0x20,0x10,0x20,0x20,0x20,0x20,0x60,0x00},/*"}",93*/
{0x40,0xA4,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} /*"~",94*/
}
函数定义如下:
static void LCD_Show_1206_char(u16 x,u16 y,u16 fc, u16 bc, u8 num,u8 mode)
{
    u8 temp;
    u8 pos,t;
    u16 colortemp=POINT_COLOR;      		   
    num=num-' ';//得到偏移后的值
    LCD_SetWindows(x,y,x+6-1,y+12-1);//设置单个文字显示窗口
    if(!mode) //非叠加方式:字体带有背景色,显示时会将原来显示的内容覆盖掉
    {		
        for(pos=0;pos<12;pos++)
	{
	    temp = asc2_1206[num][pos];//调用1206字体,需要自己取模定义
	    for(t=0;t<6;t++)
            {                 
		if(temp&0x80)
		{
		    Lcd_WriteData_16Bit(fc);
		}
		else 
		{
		    Lcd_WriteData_16Bit(bc); 
		}
		temp<<=1;
	    }
			
	}	
    }
    else//叠加方式:字体不带背景色,直接叠加显示到原来显示的内容上
    {
	for(pos=0;pos<12;pos++)
	{
	    temp = asc2_1206[num][pos];//调用1206字体,需要自己取模定义
	    for(t=0;t<6;t++)
	    {   
		POINT_COLOR=fc;              
		if(temp&0x80)
		{
		    LCD_DrawPoint(x+t,y+pos);//画一个点    
		}
		temp<<=1;
	    }
	}
    }
    POINT_COLOR=colortemp;	
    LCD_SetWindows(0,0,lcddev.width-1,lcddev.height-1);//恢复窗口为全屏         	   
}
  • 8x16英文字体取模说明
尺寸设置如下图所示:
函数定义如下:
static void LCD_Show_1608_char(u16 x,u16 y,u16 fc, u16 bc, u8 num,u8 mode)
{
    u8 temp;
    u8 pos,t;
    u16 colortemp=POINT_COLOR;      		   
    num=num-' ';//得到偏移后的值
    LCD_SetWindows(x,y,x+8-1,y+16-1);//设置单个文字显示窗口
    if(!mode) //非叠加方式:字体带有背景色,显示时会将原来显示的内容覆盖掉
    {		
	for(pos=0;pos<16;pos++)
	{
	    temp = asc2_1608[num][pos];//调用1608字体,需要自己取模定义
	    for(t=0;t<8;t++)
            {                 
		if(temp&0x80)
	        {
		    Lcd_WriteData_16Bit(fc);
		}
		else 
		{
		    Lcd_WriteData_16Bit(bc); 
		}
		temp<<=1;
	    }
	}	
    }
    else//叠加方式:字体不带背景色,直接叠加显示到原来显示的内容上
    {
	for(pos=0;pos<16;pos++)
	{
	    temp = asc2_1608[num][pos];//调用1608字体,需要自己取模定义
	    for(t=0;t<8;t++)
	    {   
		POINT_COLOR=fc;              
		if(temp&0x80)
		{
		    LCD_DrawPoint(x+t,y+pos);//画一个点    
		}
		temp<<=1;
	    }
	}
    }
    POINT_COLOR=colortemp;	
    LCD_SetWindows(0,0,lcddev.width-1,lcddev.height-1);//恢复窗口为全屏         	   
}
  • 12x24英文字体取模说明
尺寸设置如下图所示:
函数定义如下:
static void LCD_Show_2412_char(u16 x,u16 y,u16 fc, u16 bc, u8 num,u8 mode)
{
    u16 temp;
    u8 pos,t;
    u16 colortemp=POINT_COLOR;      		   
    num=num-' ';//得到偏移后的值
    LCD_SetWindows(x,y,x+12-1,y+24-1);//设置单个文字显示窗口
    if(!mode) //非叠加方式:字体带有背景色,显示时会将原来显示的内容覆盖掉
    {		
	for(pos=0;pos<24;pos++)
	{
	    temp = (asc2_2412[num][pos*2]<<8)|asc2_2412[num][pos*2+1];//调用2412字体,需要自己取模定义
	    for(t=0;t<12;t++)
	    {                 
	        if(temp&0x8000)
		{
		    Lcd_WriteData_16Bit(fc);
		}
		else 
		{
		    Lcd_WriteData_16Bit(bc); 
		}
		temp<<=1;
	    }
	}	
    }
    else//叠加方式:字体不带背景色,直接叠加显示到原来显示的内容上
    {
	for(pos=0;pos<24;pos++)
        {
	    temp = (asc2_2412[num][pos*2]<<8)|asc2_2412[num][pos*2+1];//调用2412字体,需要自己取模定义
	    for(t=0;t<12;t++)
	    {   
		POINT_COLOR=fc;              
		if(temp&0x8000)
		{
		    LCD_DrawPoint(x+t,y+pos);//画一个点    
		}
		temp<<=1;
	    }
        }
    }
    POINT_COLOR=colortemp;	
    LCD_SetWindows(0,0,lcddev.width-1,lcddev.height-1);//恢复窗口为全屏       	   
}
  • 16x32英文字体取模说明
尺寸设置如下图所示:
函数定义如下:
static void LCD_Show_3216_char(u16 x,u16 y,u16 fc, u16 bc, u8 num,u8 mode)
{
    u16 temp;
    u8 pos,t;
    u16 colortemp=POINT_COLOR;      		   
    num=num-' ';//得到偏移后的值
    LCD_SetWindows(x,y,x+16-1,y+32-1);//设置单个文字显示窗口
    if(!mode) //非叠加方式:字体带有背景色,显示时会将原来显示的内容覆盖掉
    {		
	for(pos=0;pos<32;pos++)
	{
	    temp = (asc2_3216[num][pos*2]<<8)|asc2_3216[num][pos*2+1];//调用3216字体,需要自己取模定义
	    for(t=0;t<16;t++)
	    {                 
		if(temp&0x8000)
		{
		    Lcd_WriteData_16Bit(fc);
		}
		else 
		{
		    Lcd_WriteData_16Bit(bc); 
		}
		temp<<=1;
	    }
			
	}	
    }
    else//叠加方式:字体不带背景色,直接叠加显示到原来显示的内容上
    {
        for(pos=0;pos<32;pos++)
	{
	    temp = (asc2_3216[num][pos*2]<<8)|asc2_3216[num][pos*2+1];//调用3216字体,需要自己取模定义
	    for(t=0;t<16;t++)
	    {   
		POINT_COLOR=fc;              
		if(temp&(0x8000))
		{
		    LCD_DrawPoint(x+t,y+pos);//画一个点    
		}
		temp<<=1;
	    }
	}
    }
    POINT_COLOR=colortemp;	
    LCD_SetWindows(0,0,lcddev.width-1,lcddev.height-1);//恢复窗口为全屏      	   
}

中文汉字取模

  • 16x16中文字体取模说明
尺寸设置如下图所示:
函数定义如下:
void GUI_DrawFont16(u16 x, u16 y, u16 fc, u16 bc, u8 *s,u8 mode)
{
   u8 i,j;
   u16 k;
   u16 HZnum;
   u16 x0=x;
   HZnum=sizeof(tfont16)/sizeof(typFNT_GB16);	//自动统计汉字数目
   for (k=0;k<HZnum;k++) 
   {
       if((tfont16[k].Index[0]==*(s))&&(tfont16[k].Index[1]==*(s+1)))
       { 	
           LCD_SetWindows(x,y,x+16-1,y+16-1);
	   for(i=0;i<16*2;i++)
           {
		for(j=0;j<8;j++)
		{	
		     if(!mode) //非叠加模式:字体带有背景色,显示时会将原来显示的内容覆盖掉
		     {
			  if(tfont16[k].Msk[i]&(0x80>>j))
                          {	
                               Lcd_WriteData_16Bit(fc);
                          }			  
                          else 
                          {
                               Lcd_WriteData_16Bit(bc);
			  }
		     }
		     else //叠加模式:字体不带背景色,直接叠加显示到原来显示的内容上
		     {
			  POINT_COLOR=fc;
			  if(tfont16[k].Msk[i]&(0x80>>j))						
                          {
                               LCD_DrawPoint(x,y);//画一个点
			  }
			  x++;
			  if((x-x0)==16)
			  {
			       x=x0;
			       y++;
			       break;
			  }
		     }
	        }
	    }
	 }				  	
	 continue;  //找到对应点阵字库立即退出,防止多个汉字重复取模带来影响
    }
    LCD_SetWindows(0,0,lcddev.width-1,lcddev.height-1);//恢复窗口为全屏 
}
  • 24x24中文字体取模说明
尺寸设置如下图所示:
函数定义如下:
void GUI_DrawFont24(u16 x, u16 y, u16 fc, u16 bc, u8 *s,u8 mode)
{
    u8 i,j;
    u16 k;
    u16 HZnum;
    u16 x0=x;
    HZnum=sizeof(tfont24)/sizeof(typFNT_GB24);	//自动统计汉字数目
    for (k=0;k<HZnum;k++) 
    {
        if((tfont24[k].Index[0]==*(s))&&(tfont24[k].Index[1]==*(s+1)))
        { 	
             LCD_SetWindows(x,y,x+24-1,y+24-1);
	     for(i=0;i<24*3;i++)
	     {
		  for(j=0;j<8;j++)
		  {
			if(!mode) //非叠加模式:字体带有背景色,显示时会将原来显示的内容覆盖掉
			{
                              if(tfont24[k].Msk[i]&(0x80>>j))
                              {	 
                                   Lcd_WriteData_16Bit(fc);
			      }						
                              else 
                              {
                                   Lcd_WriteData_16Bit(bc);
			      }					
                        }
		        else //叠加模式:字体不带背景色,直接叠加显示到原来显示的内容上
		        {
			      POINT_COLOR=fc;
			      if(tfont24[k].Msk[i]&(0x80>>j))
                              { 
                                   LCD_DrawPoint(x,y);// 画一个点
			      }					
                              x++;
			      if((x-x0)==24)
			      {
				   x=x0;
				   y++;
				   break;
			      }
		         }
		   }
	      }
	 }				  	
	 continue;  //找到对应点阵字库立即退出,防止多个汉字重复取模带来影响
    }
    LCD_SetWindows(0,0,lcddev.width-1,lcddev.height-1);// 恢复窗口为全屏
}
  • 32x32中文字体取模说明
尺寸设置如下图所示:
函数定义如下:
void GUI_DrawFont32(u16 x, u16 y, u16 fc, u16 bc, u8 *s,u8 mode)
{
    u8 i,j;
    u16 k;
    u16 HZnum;
    u16 x0=x;
    HZnum=sizeof(tfont32)/sizeof(typFNT_GB32);	//自动统计汉字数目
    for (k=0;k<HZnum;k++) 
    {
	 if ((tfont32[k].Index[0]==*(s))&&(tfont32[k].Index[1]==*(s+1)))
	 { 	
               LCD_SetWindows(x,y,x+32-1,y+32-1);
	       for(i=0;i<32*4;i++)
	       {
		     for(j=0;j<8;j++)
	             {
			   if(!mode) //非叠加模式:字体带有背景色,显示时会将原来显示的内容覆盖掉
			   {
				if(tfont32[k].Msk[i]&(0x80>>j))
                                {
				      Lcd_WriteData_16Bit(fc);
                                }				
				else 
                                {
                                      Lcd_WriteData_16Bit(bc);
				}			
                           }
			   else //叠加模式:字体不带背景色,直接叠加显示到原来显示的内容上
			   {
				POINT_COLOR=fc;
			        if(tfont32[k].Msk[i]&(0x80>>j))
                                {
                                      LCD_DrawPoint(x,y);// 画一个点
				}		
		                x++;
				if((x-x0)==32)
				{
				      x=x0;
				      y++;
				      break;
				}
			   }
		      }
		}
	  }				  	
	  continue;  //找到对应点阵字库立即退出,防止多个汉字重复取模带来影响
     }
     LCD_SetWindows(0,0,lcddev.width-1,lcddev.height-1);// 恢复窗口为全屏
}

BACK TO TOP