|
汉字的读取我是用bozai 的程序如下:
unsigned char Read_One_GBK16(unsigned char *ch) //根据汉字内码找其点阵数据
{
unsigned int temp1;
unsigned char temp2;
unsigned int sector_offset;//扇区偏移
unsigned int byte_offset;//字节偏移
unsigned char buffer[512];
temp1=*ch;
temp2=*(ch+1);
if(temp1<0x81||temp2<0x40)return 1;//不合法的汉字
temp1-=0x81;//的到类似于2312的区号
temp2-=0x40;//位号
temp1*=192;//xx7f and xxff are included
temp1+=temp2;//得到偏移
//temp1*=24;
sector_offset = temp1/(BytesPerSector/32);//算出要读哪个扇区
byte_offset = (temp1%(BytesPerSector/32))*32;//算出要读扇区的哪个字节
if(FAT_ReadSector(GBK16 + sector_offset,buffer))return 1;//读要读的扇区
for(temp2 = 0,temp1 = byte_offset;temp2<32;temp2++,temp1++)GBK_Buffer[temp2] = buffer[temp1];//复制要复制的数据
return 0;
}
我的液晶写字程序如下:
uchar GUI_PutChar16_16(uint x, uint y, uchar *ch)
{
uint font_dat,tmp,a,b;
uchar i, j;
LCD_BlockSet(x, y, x+15, y+15);
tmp=pgm_read_byte(ch);
tmp += (pgm_read_byte(++ch))<<8;
if(Read_One_GBK16((unsigned char *)(&tmp)))return 1;
是显示单个汉字的,我在主函数这样调用:GUI_PutChar16_16(20, 210,PSTR("没"));
可是出来的不“没”,而个很偏的汉字,如果改成其他字,会相应的显示其他字,但总对不上!
热心的同学帮帮我把 ,我实在没辙了
for(i=0; i<32; i++) // 16x32/8=64;
{
a= GBK_Buffer;
a=a<<8;
b= GBK_Buffer[++i];
font_dat = a|b;
for(j=0; j<16; j++)
{
if(font_dat&0x8000)
{
LCD_WriteDat(B);
}
else
{
LCD_WriteDat(G);
}
font_dat = font_dat<<1;
}
}
return(1);
} |
|