初学者:大虾帮忙看看
main()
{
/*...*/
fnLCMInit();/*fs=H,6bit font,40 cols,graphic mode*/
cls();
cursor(1,0);
print("abcdefghijklmnopqrstuvwxyz1234567890~!@#");
/*
屏幕显示为:
abcdefghijklmnopqrstuvwxyz1abcdefgh23456
^^^^^^^^ ~~~~~~~~这8个字符总是与前面一样!
而且在写^标记时,~处同时亮,百思不得其解,那位置点一二,感激不尽!.
我用的是6*12字库,程序是按Youth的修改的,模块是信利的mspg240128*/
}
void fnSetPos(uchar urow, uchar ucol)
{
uint iPos;
iPos = urow * 40 + ucol;
fnCmd2(LC_ADD_POS,iPos & 0xFF,iPos / 256);
gCurRow = urow;
gCurCol = ucol;
}
void cursor(uchar uRow, uchar uCol)
{
fnSetPos(uRow * 12, uCol);
}
uchar fnLCMInit(void)
{
if(fnCmd2(LC_TXT_STP,0x00,0x00) != 0) /*text home*/
return -1;
fnCmd2(LC_TXT_WID,40,0x00); /*text area,40 cols for 6 bit font*/
fnCmd2(LC_GRH_STP,0x00,0x00); /*graphic home*/
fnCmd2(LC_GRH_WID,40,0x00); /*graphic area,40 cols for 6 bit
font*/
fnCmd0(LC_CUR_SHP | 0x01); /*cursor shape*/
fnCmd0(LC_MOD_OR); /*display mode*/
fnCmd0(LC_DIS_SW | 0x08); /*display switch*/
return 0;
}
void print(char *fmt, ...)
{
va_list arg_ptr;
data uchar uRow,uCol,uLen;
idata uchar buf[25];
uchar i,j;
uint offset;
va_start(arg_ptr, fmt);
uLen = (uchar)vsprintf(buf, fmt, arg_ptr);
va_end(arg_ptr);
uRow=gCurRow;
uCol=gCurCol;
for(i=0;i<uLen;i++)
{
offset=((uchar)buf[i]-0x20)*12;
for(j=12;j>0;j--)
{
fnSetPos(uRow++,uCol);
fnCmd1(LC_NOC_WR,asc12[offset++]);
}
uCol++;
uRow-=12;
}
}
发表时间:2001年10月24日21:10:00