?? pg160128a.c
字號:
uRow = 0;
uCol = 0;
}
}
fnSetPos(uRow,uCol);
i++;
}
return uLen;
}
/**************** ASCII碼(8×16)及漢字(16×16)顯示函 第二頁 ******************/
uchar dprintf1(char *fmt, ...) {
va_list arg_ptr;
char c1,c2,cData;
char tmpBuf[64]; /* LCD顯示數(shù)據(jù)緩沖區(qū) */
uchar i=0,j,uLen,uRow,uCol;
uint k;
va_start(arg_ptr, fmt);
uLen = (uchar)vsprintf(tmpBuf, fmt, arg_ptr);
va_end(arg_ptr);
while(i<uLen) {
c1 = tmpBuf[i];
c2 = tmpBuf[i+1];
uRow = fnGetRow();
uCol = fnGetCol();
if(c1 >= 0) { //* ASCII碼
if(c1 < 0x20) {
switch(c1) {
case CR:
case LF: i++; // 回車或換行
if(uRow < 112)
fnSetPos1(uRow+16,0);
else
fnSetPos1(0,0);
continue;
case BS: // 退格
if(uCol > 0) uCol--;
fnSetPos1(uRow,uCol);
cData = 0x00;
break;
default: // 其他
c1 = 0x1f;
}
}
for(j=0;j<16;j++) {
fnPR12(LC_AUT_WR); // 寫數(shù)據(jù)
if(c1 >= 0x1f) {
fnPR13(ASC_MSK[(c1-0x1f-1)*ASC_CHR_HEIGHT+j]);
}
else
fnPR13(cData);
fnPR12(LC_AUT_OVR);
fnSetPos1(uRow+j+1,uCol);
}
if(c1 != BS) uCol++; /* 非退格 */
}
else { /* 中文 */
for(j=0;j<sizeof(GB_16)/sizeof(GB_16[0]);j++) {
if(c1 == GB_16[j].Index[0] && c2 == GB_16[j].Index[1])
break;
}
for(k=0;k<sizeof(GB_16[0].Msk)/2;k++)
{
fnSetPos1(uRow+k,uCol);
fnPR12(LC_AUT_WR); /* 寫數(shù)據(jù) */
if(j < sizeof(GB_16)/sizeof(GB_16[0])) {
fnPR13(GB_16[j].Msk[k*2]);
fnPR13(GB_16[j].Msk[k*2+1]);
}
else { /* 未找到該字 */
if(k < sizeof(GB_16[0].Msk)/4) {
fnPR13(0x00);
fnPR13(0x00);
}
else {
fnPR13(0xff);
fnPR13(0xff);
}
}
fnPR12(LC_AUT_OVR);
}
uCol += 2;
i++;
}
if(uCol >= 30) { /* 光標后移 */
uRow += 16;
if(uRow < 0x80) uCol -= 30;
else {
uRow = 0;
uCol = 0;
}
}
fnSetPos1(uRow,uCol);
i++;
}
return uLen;
}
/********************************文本方式下,用指定數(shù)據(jù)填充字符***********/
void cgram80(uchar myc)
{
unsigned int i;
fnPR1(LC_ADD_POS,0x00,0x1c); /* 置地址指針 */
fnPR12(LC_AUT_WR); /* 自動寫 */
for(i=0;i<8;i++)
{
fnST3();
fnPR13(myc); /* 寫數(shù)據(jù) */
}
fnPR12(LC_AUT_OVR); /* 自動寫結(jié)束 */
fnPR1(LC_ADD_POS,0x00,0x00); /* 重置地址指針 */
gCurRow = 0; /* 置地址指針存儲變量 */
gCurCol = 0;
}
/********************************文本方式下,用指定數(shù)據(jù)填充字符***********/
void cgram_wave(void)
{
uint i;
uchar mychar[40]={ 0x00,0x04,0x02,0xff,0x02,0x04,0x00,0x00,//→
0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x00,//─
0x08,0x1c,0x2a,0x08,0x08,0x08,0x08,0x08,//↑
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,//│
0x08,0x08,0x08,0xff,0x08,0x08,0x08,0x08,//┽
};
fnPR1(LC_ADD_POS,0x08,0x1c); /* 置地址指針 */
fnPR12(LC_AUT_WR); /* 自動寫 */
for(i=0;i<40;i++)
{
fnST3();
fnPR13(mychar[i]); /* 寫數(shù)據(jù) */
}
fnPR12(LC_AUT_OVR); /* 自動寫結(jié)束 */
fnPR1(LC_ADD_POS,0x00,0x00); /* 重置地址指針 */
gCurRow = 0; /* 置地址指針存儲變量 */
gCurCol = 0;
}
/*********************************矩形填充0x80字符*******************/
void txtfill(uchar col,uchar row,uchar h,uchar l,uchar arc)
{
uchar i,j;
for(i=0;i<h;i++)
for(j=0;j<l;j++)
{
fnSetPostxt(row+i,j+col);
fnPR11(LC_NOC_WR,arc);
}
}
void cgram_waveinit(void)
{
txtfill(0,3,1,1,'5'-32);
txtfill(1,3,1,1,'V'-32);
txtfill(2,2,12,1,0x84);
txtfill(2,1,1,1,0x83);
txtfill(2,14,1,1,0x85);
txtfill(3,14,1,15,0x82);
txtfill(18,14,1,1,0x81);
txtfill(2,3,1,1,0x85);
}
void cgram_wavecls(void)
{
txtfill(0,3,1,1,' '-32);
txtfill(1,3,1,1,' '-32);
txtfill(2,2,12,1,0x86);
txtfill(2,1,1,1,0x86);
txtfill(2,14,1,1,0x86);
txtfill(3,14,1,15,0x86);
txtfill(18,14,1,1,0x86);
txtfill(2,3,1,1,0x86);
}
void menuprint()
{
fnPR1(LC_GRH_STP,0x00,0x0a);
cursor1(0,0);
dprintf1("%s","請選擇:");//Please choose:
cursor1(2,0);
dprintf1("%s","1,T6963模塊基本功能;");//1,T6963C核LCD;
cursor1(3,0);
dprintf1("%s","2,圖形顯示演示;");//;2,圖形顯示;
cursor1(4,0);
dprintf1("%s","3,指導(dǎo)老師簡介;");//3,Displaywave;
cursor1(5,0);
dprintf1("%s","4,作者簡介;");//4,Stepmotor control;
cursor1(6,0);
dprintf1("%s","5,關(guān)于此畢業(yè)設(shè)計.");//5,LCD接口設(shè)計;
}
//************菜單選擇函數(shù),返回按鍵號
uchar menuselect()
{
uchar row;static uchar index;
index=1;row=(index-1)*2+4;
txtfill(0,row,2,20,0x080);
while(1)
{
if(scankeypad()==3)//上
{ txtfill(0,row,2,20,0);
if(index==1)
{
index=5;row=(index-1)*2+4;
txtfill(0,row,2,20,0x080);
}
else
{
index--;row=(index-1)*2+4;
txtfill(0,row,2,20,0x080);
}
}
if(scankeypad()==7)//下
{ txtfill(0,row,2,20,0);
if(index==5)
{
index=1;row=(index-1)*2+4;
txtfill(0,row,2,20,0x080);
}
else
{
index++;row=(index-1)*2+4;
txtfill(0,row,2,20,0x080);
}
}
if(scankeypad()==11)
{
txtfill(0,row,2,20,0);
return index;
}
}
}
void pdelay()
{
unsigned int i,j;
for (i=500;i>0;i--)
for(j=500;j>0;j--);
}
void showBMP(uchar row,uchar col,uchar prow,char pcol,char *uc_char) {
uchar k,j;
fnPR1(LC_ADD_POS,0x00,0x00); /* 置地址指針 */
for(k=0;k<prow;k++)
{ fnSetPos1(row+k,col);
fnPR12(LC_AUT_WR); /* 自動寫 */
for(j=0;j<pcol;j++)
fnPR13(uc_char[pcol*k+j]);
fnPR12(LC_AUT_OVR); /* 自動寫結(jié)束 */
}
fnPR1(LC_ADD_POS,0x00,0x00); /* 重置地址指針 */
}
/********************************* 主函數(shù) ********************************/
void main(void) {
fnLCMInit();
fnPR1(LC_GRH_STP,0x00,0x0a);
showBMP(0,0,116,20,&WATER);
pdelay();
cls();
while(1)
{
cls();
cgram80(0xff);
menuprint();
switch(menuselect())
{
case 1:{
cls();
showBMP(8,4,46,13,&YAN);
while(scankeypad()!=15);
break;}
case 2:{
cls();
showBMP(0,0,64,16,&STARTLOGO);
while(scankeypad()!=15);
break;
}
case 3:{
cls();
fnPR1(LC_GRH_STP,0x00,0x00);
cursor(0,5);
dprintf("%s","長江大學(xué)");
cursor(1,5);
dprintf("%s","電信學(xué)院");
cursor(2,5);
dprintf("%s","徐愛鈞教授");
while(scankeypad()!=15);
break;
}
case 4:{
cls();
fnPR1(LC_GRH_STP,0x00,0x00);
cursor(0,5);
dprintf("%s","長江大學(xué)");
cursor(1,7);
dprintf("%s","肖歡");
cursor(2,5);
dprintf("%s","自本10502");
while(scankeypad()!=15);
break;
}
case 5:{
cls();
fnPR1(LC_GRH_STP,0x00,0x00);
while(1)
{
cursor(2,3);
dprintf("%s","單片機LCD圖形");
cursor(3,6);
dprintf("%s","接口設(shè)計");
while(scankeypad()!=15);
break;
}
}
default:break;
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -