近日在写一个驱动LED点阵屏的程序, 程序中使用到字模数组, 同时还要做HEX到BCD的转换, 所以本想将字模定义成一个数组, 然后将BCD转换表也定义成数组, 在显示时通过BCD转换表查找到字模数组, 然后从字模数组中取出一行数据输出.
在字模数组文件中如此定义: _AUTOEXTERN const unsigned short array_0[_FONT_ARRAY_SIZE] = { 0x1010, 0x0000,0x0000,0x03E0,0x0630,0x0C18,0x0C18,0x0C18,0x0C18, 0x0C18,0x0C18,0x0C18,0x0C18,0x0630,0x03E0,0x0000,0x0000};
_AUTOEXTERN const unsigned short array_1[_FONT_ARRAY_SIZE] = { 0x1010, 0x0000,0x0000,0x0080,0x0380,0x0180,0x0180,0x0180,0x0180, 0x0180,0x0180,0x0180,0x0180,0x0180,0x03C0,0x0000,0x0000};
_AUTOEXTERN const unsigned short array_2[_FONT_ARRAY_SIZE] = { 0x1010, 0x0000,0x0000,0x03C0,0x0660,0x0C30,0x0C30,0x0030,0x0030, 0x0060,0x00C0,0x0180,0x0310,0x0610,0x0FF0,0x0000,0x0000};
BCD转换表是这样定义的: const unsigned short *const BCD_Tbl[] = { array_0, array_1, array_2, array_3, array_4, array_5, array_6, array_7, array_8, array_9, array_dian3, array_mao4hao4, array_jian3hao4, array_nian2, array_yue4, array_ri4, array_shi2, array_fen1, array_miao3, array_wen1, array_du4, array_shi1, array_she4shi4, array_bfh, array_AllOff, array_AllOn };
... unsigned char Screen[_SCREEN_SIZE] = { 19, 20, 11, //温度: };
在显示函数中我是这样用的: void ShowScreen(unsigned char BlinkPos) { static unsigned char LinePtr = 0; const unsigned short* pFont; //当前字模指针 unsigned char x_size, y_size; //当前字模的水平方向和垂直方向的点数(数字与汉字可能不同) unsigned short fontLine, temp; //保存字模的当前行的数据 unsigned char n, i; ....
//串行输出列数据 for(n = 0; n < _SCREEN_SIZE; ++n) { pFont = BCD_Tbl[Screen[n]]; //Screen数组里面存的是要显示的数字和汉字信息相当于地址码吧 x_size = (pFont[0] & 0xFF00) >> 8; //字模中的第一个元素是字模的宽度和高度停息 y_size = (pFont[0] & 0x00FF); fontLine = pFont[LinePtr + 1]; //本以为这里取出的就是字模中的一行数据, 可实际上不是, 请问各位高手, 问题究竟出在哪里呀? .....
|