#include "sys.h" #include "fontupd.h" #include "w25qxx.h" #include "ili93xx.h" #include "mytext.h" #include "string.h" #include "usart.h" ////////////////////////////////////////////////////////////////////////////////// //本程序只供学习使用,未经作者许可,不得用于其它任何用途 //ALIENTEK STM32F407开发板 //汉字显示 驱动代码 //正点原子@ALIENTEK //技术论坛:www.openedv.com //创建日期:2014/5/15 //版本:V1.0 //版权所有,盗版必究。 //Copyright(C) 广州市星翼电子科技有限公司 2014-2024 //All rights reserved ////////////////////////////////////////////////////////////////////////////////// //code 字符指针开始 //从字库中查找出字模 //code 字符串的开始地址,GBK码 //mat 数据存放地址 (size/8+((size%8)?1:0))*(size) bytes大小 //size:字体大小 void Get_HzMat(unsigned char *code,unsigned char *mat,u8 size) { unsigned char qh,ql; unsigned char i; unsigned long foffset; u8 csize=(size/8+((size%8)?1:0))*(size);//得到字体一个字符对应点阵集所占的字节数 qh=*code; ql=*(++code); if(qh<0x81||ql<0x40||ql==0xff||qh==0xff)//非 常用汉字 { for(i=0;i0x80)bHz=1;//中文 else //字符 { if(x>(x0+width-size/2))//换行 { y+=size; x=x0; } if(y>(y0+height-size))break;//越界返回 if(*str==13)//换行符号 { y+=size; x=x0; str++; } else LCD_ShowChar(x,y,*str,size,mode);//有效部分写入 str++; x+=size/2; //字符,为全字的一半 } }else//中文 { bHz=0;//有汉字库 if(x>(x0+width-size))//换行 { y+=size; x=x0; } if(y>(y0+height-size))break;//越界返回 Show_Font(x,y,str,size,mode); //显示这个汉字,空心显示 str+=2; x+=size;//下一个汉字偏移 } } } //在指定宽度的中间显示字符串 //如果字符长度超过了len,则用Show_Str显示 //len:指定要显示的宽度 void Show_Str_Mid(u16 x,u16 y,u8*str,u8 size,u8 len) { u16 strlenth=0; strlenth=strlen((const char*)str); strlenth*=size/2; if(strlenth>len)Show_Str(x,y,lcddev.width,lcddev.height,str,size,1); else { strlenth=(len-strlenth)/2; Show_Str(strlenth+x,y,lcddev.width,lcddev.height,str,size,1); } }