欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
可移植的嵌入式系統漢字顯示代碼
[打印本頁]
作者:
xiaos
時間:
2015-4-10 17:10
標題:
可移植的嵌入式系統漢字顯示代碼
移植之前 必須保證 成功移植了文件系統
,這是在VS2008上運行通過的;
//移植的時候要修改printf 函數為LCD的打印一個點的函數,與文件系統相關的函數 酌情修改
這是顯示效果,16*16 的GBK字庫 字庫的文件名是 "
f
ont.DZK
"
#include "stdio.h"
#define FONT_SIZE 32//定義單個漢字所占的字節數
void Display(FILE *f,char *str);
void Displays(FILE *f,char *str,unsigned char count);
int main(void)
{
FILE *f;
f=fopen("font.DZK",r");
if(f==NULL)
{
printf("error..");
return 0;
}
Displays(f,"您好",2);
fclose(f);
return 0;
}
void GetFont(FILE *f,char *str,unsigned char *buff)
{
unsigned char High=*str;
unsigned char Low=*(str+1);
unsigned long offset;
High-=0x81;
if(Low<0x7f)
Low-=0x40;
else
Low-=0x41;
offset=(unsigned long)(High*190+Low)*FONT_SIZE;
fseek(f,offset,0);
fread(buff,FONT_SIZE,1,f);
}
void Display(FILE *f,char *str)
{
char i,j;
unsigned char buff[FONT_SIZE],temp;
GetFont(f,str,buff);
for(i=0;i<32;i+=2)
{
temp=buff[i];
for(j=0;j<8;j++)
{
if(temp&0x80)
printf("*");
else
printf(" ");
temp<<=1;
}
temp=buff[i+1];
for(j=0;j<8;j++)
{
if(temp&0x80)
printf("*");
else
printf(" ");
temp<<=1;
}
printf("\n");
}
}
void printblank(void)
{
unsigned char i;
for(i=0;i<16;i++)
printf(" ");
}
void Displays(FILE *f,char *str,unsigned char count)
{
unsigned char i;
for(i=0;i<count;i++,str+=2)
{
Display(f,str);
printblank();
}
}
復制代碼
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1