本帖最后由 huangl53 于 2013-7-3 14:15 编辑
显示16x16的汉字,写了一个函数,
没有在NXC中找到指针,
用数组名字做参数居然也成功了
//=====================================================
unsigned char zm[] = {
/*-- 文字: 中 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x07,0xFC,0x02,0x08,0x02,0x08,0x02,0x08,0x02,0x08,0xFF,0xFF,
0x02,0x08,0x02,0x08,0x02,0x08,0x02,0x08,0x07,0xFC,0x00,0x08,0x00,0x00,0x00,0x00,
/*-- 文字: 文 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x08,0x40,0x08,0x40,0x08,0x20,0x08,0x20,0x78,0x11,0x88,0x0A,0x09,0x04,0x0E,
0x0A,0x08,0x11,0x88,0x10,0x78,0x20,0x08,0x60,0x08,0x20,0x08,0x20,0x08,0x00,0x00,
/*-- 文字: 乐 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x20,0x00,0x18,0x40,0x0C,0xFC,0x07,0x44,0x12,0x44,0x20,0x44,0x40,0x46,
0x3F,0xFA,0x00,0x42,0x00,0x43,0x02,0x43,0x0C,0x42,0x38,0x40,0x10,0x00,0x00,0x00,
/*-- 文字: 高 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x04,0xFF,0x04,0x01,0x04,0x01,0x04,0x3D,0x74,0x25,0x54,0x25,0x55,0x25,0x56,
0x25,0x54,0x25,0x54,0x3D,0x74,0x41,0x04,0x81,0x04,0x7F,0x04,0x00,0x04,0x00,0x00,
/*-- 文字: 汉 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x04,0x10,0x04,0x60,0x7E,0x01,0x01,0x86,0x40,0x60,0x20,0x04,0x20,0x1C,0x10,0xE4,
0x0B,0x04,0x04,0x04,0x0B,0x04,0x10,0xE4,0x30,0x1C,0x60,0x04,0x20,0x00,0x00,0x00,
/*-- 文字: 字 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x02,0x10,0x02,0x0C,0x02,0x24,0x02,0x24,0x42,0x24,0x82,0x25,0x7F,0x26,
0x02,0xA4,0x02,0x64,0x02,0x24,0x02,0x04,0x02,0x14,0x02,0x0C,0x02,0x00,0x00,0x00
};
//===========================================================
// x y 为输出点左下坐标,
//unsigned char hzk[],数组名字
//posoffset为数组中第几个汉字,从第0个开始数
void Disp16x16(unsigned char x,unsigned char y,unsigned char hzk[],unsigned char posoffset)
{
unsigned char k = 0;
unsigned char j = 0;
unsigned char i = 0;
for(k=0;k<16;k++) // 16次循环,每次2个字节16个点
{
j = 0x80; //bit mask
for(i=0;i<8;i++) //检测每列2个字节的8个比特,如果为1,则显示一个点
{
if(hzk[k*2+posoffset*32]&j) //偶数字节检测
{
PointOut(x+k,y+i); //显示一个点
}
if(hzk[k*2+posoffset*32+1]&j ) //奇数字节检测
{
PointOut(x+k,y+8+i); //显示一个点
}
j>>= 1;
}
}
}
//===========================================================
task main()
{
unsigned char yy,xx;
for(yy=0;yy<4;yy++) // 垂直控制,4行汉字
{
for(xx=0;xx<6;xx++)//水平控制,第二列开始显示6个汉字
{
//调用时,第三个参数 数组名字 没有[ ]
//参数依次为 横坐标,纵坐标,字库数组名字,显示汉字在字库中的位置
Disp16x16(2+xx*16,yy*16,zm,xx); //在指定位置显示一个汉字
}
}
while(1);
}
//=====================================================
字模软件 字模2.21
|