lcd的多屏多层菜单程序Word格式文档下载.docx
《lcd的多屏多层菜单程序Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《lcd的多屏多层菜单程序Word格式文档下载.docx(56页珍藏版)》请在冰豆网上搜索。
#defineBUTTON_SLAVE0x81
//0,1,2,3,4,5,6,7,8,9
unsignedcharcodekeyscancode[]={0x82,0x11,0x12,0x14,0x21,0x22,0x24,0x41,0x42,0x44};
x25045.h>
tm12864.h>
//newvar
unsignedcharbdatabitvar;
sbitkeypush=bitvar^0;
sbitrrtime_flag=bitvar^1;
//读取运行参数标志
sbitshowflag=bitvar^2;
unsignedcharkeycode,tempkey,i,j;
unsignedcharmenuitem=0x00;
unsignedintruntime[32];
unsignedintxdatastarttime[36];
unsignedintxdatastoptime[32];
unsignedintxdatabetweentime[32];
unsignedcharxdatarunno1[36];
unsignedcharxdatalinkrun[4];
unsignedcharxdatalinkrunno1[4];
unsignedcharxdatasubmenuitem=0;
unsignedlongxdatai8155out;
unsignedcharxdatamain_temp,outputnumber,inputnumber;
unsignedintxdatatempvar[9];
charxdatashowstr[5]="
"
;
//newvarend
//定义DS12887地址
#defineP12887SEC
0x7f00//12887秒地址
#defineP12887SEC_ALM
0x7f01//12887秒报警地址
#defineP12887MIN
0x7f02//12887分地址
#defineP12887MIN_ALM
0x7f03//12887分报警地址
#defineP12887HOUR
0x7f04//12887时地址
#defineP12887HOUR_ALM
0x7f05//12887时报警地址
#defineP12887WEEK
0x7f06//12887星期地址
#defineP12887DAY
0x7f07//12887日期地址
#defineP12887MONTH
0x7f08//12887月地址
#defineP12887YEAR
0x7f09//12887年地址
#defineP12887MCA
0x7f0a//寄存器a地址
#defineP12887MCB
0x7f0b//寄存器a地址
#defineP12887MCC
0x7f0c//寄存器a地址
#defineP12887MCD
0x7f0d//寄存器a地址
#defineP12887RAM
0x7f0e//12887不掉电RAM起始地址
void
init_12887();
//DS12887初始化程序
gettime_12887();
//取DS12887时间子程序(年月日时分)
settime_12887();
//设置DS12887时间子程序
voidi8155_init(unsignedintmemaddress,unsignedcharcommand);
//intel8155端口输出
//memaddress:
8155基址;
//portnum:
端口号(1:
PA、2:
PB、3:
PC)
//portstatu:
端口输出字
voidi8155_outport(unsignedintmemaddress,unsignedcharportnum,unsignedcharportstatu);
//intel8155端口输入
//返回值:
端口状态
unsignedchari8155_inport(unsignedintmemaddress,unsignedcharportnum);
voidshowinitscreen();
voidinit();
voidtimer0()interrupt1using1
{
unsignedchartemp;
//晶振为11.0592MHZ时计数9216(0xdb00)次为10ms
TH0=0xd8;
TL0=0x00;
temp=(XBYTE[0x7e00]&
0x0f);
//有键按下时!
=0x0f
if(temp!
=0x0f)//是否有键按下
if(keypush==1)
keycode=~temp;
if((XBYTE[0x7ee0]&
0x0f)!
=0x0f)
keycode=keycode&
0x1f;
}
elseif((XBYTE[0x7ed0]&
0x2f;
elseif((XBYTE[0x7eb0]&
0x4f;
elseif((XBYTE[0x7e30]&
0x8f;
else
keypush=1;
keycode=0;
keypush=0;
voidds12887_int1()interrupt2using2
rrtime_flag=0;
ACC=XBYTE[P12887MCC];
//读寄存器C清除中断请求标志IRQF
//**************************************************************
//
//主程序
voidmain()
i8155out=0x00;
x25045_disable();
outputnumber=x25045_readbyte(OUTNUMBER);
for(i=0;
i<
outputnumber;
i++)
runtime=(int)0x00;
runno1=0x00;
starttime=x25045_readword(i*7);
stoptime=x25045_readword(i*7+2);
betweentime=x25045_readword(i*7+4);
x25045_init();
init();
//初始化变量
while
(1)
//***********************
#ifDEBUG
#else
#endif
TMOD=0x01;
ET0=1;
TR0=1;
#ifENABLE_INTERRUPT
EX1=1;
PX1=1;
PT0=0;
EA=1;
//**********************************
//加入限时运行功能
if((x25045_readbyte(0x01bb)==1)&
&
(menuitem!
=0x20)&
=0x1b))
tempkey=0;
3;
if(tempvar<
=x25045_readbyte(0x01b5-3+i))
tempkey++;
break;
if(tempkey<
3)
if(menuitem!
=0x20)
showflag=0;
menuitem=0x20;
menuitem=0;
tempkey=0x50;
i=0;
//主循环开始
tm12864_reset();
x25045_resetwatchdog();
//键盘处理程序
if((keycode!
=0)&
(keypush==0))
while(i<
10)
if(keycode==keyscancode)
tempkey=i;
tempkey=keycode;
i++;
//屏幕显示处理
switch(menuitem)
case0x00:
//自动运行状态
if(showflag==0)
tm12864_fillscreen(0x00);
showflag=1;
showinitscreen();
tm12864_writestr(0,0,"
0);
tm12864_writestr(12,0,"
tm12864_writestr(0,4,"
tm12864_writestr(0,6,"
tm12864_writehz(4,6,zzyx,0);
tm12864_writestr(12,6,"
if(tempkey==BUTTON_STOP)//进入“设置确认”菜单
j=0;
menuitem=0x01;
case0x01:
//设置确认菜单
tm12864_writestr(4,6,"
1);
tm12864_writehz(0,6,mm,0);
if((j<
6)&
(tempkey<
0x0a))
tm12864_writestr((j+4),6,"
*"
tempvar[j]=tempkey;
j++;
if(j==6)
for(j=0;
j<
6;
j++)
if(tempvar[j]!
=x25045_readbyte(PASSWORD_ADDR+j))
menuitem=0x00;
tm12864_writestr(6,6,"
tm12864_writehz(2,6,set,1);
tm12864_writehz(10,6,yunxing,0);
if(tempkey==BUTTON_OK)
menuitem=0x03;
submenuitem=0;
tempvar[0]=1;
if(tempkey==BUTTON_START)
case0x02:
//运行确认菜单
switch(submenuitem)
tm12864_writehz(2,6,set,0);
tm12864_writehz(10,6,yunxing,1);
switch(tempkey)
caseBUTTON_OK:
while
(1){};
caseBUTTON_STOP:
caseBUTTON_SLAVE:
submenuitem=0x01;
submenuitem=0x00;
caseBUTTON_START:
case0x03:
//设置菜单
x25045_writestatu(0x00);
//*******************************************************
//加入隐蔽菜单功能
showstr[0]=j+0x30;
showstr[1]='
\0'
tm12864_writestr(15,7,showstr,0);
tempvar[j]=x25045_readbyte(0x01a9+j);
=x25045_readbyte(0x01a9+j))
if(tempkey==BUTTON_SET)
menuitem=0x1b;
1"
tm12864_writehz(2,0,scsd,1);
tm12864_writestr(0,2,"
2"
tm12864_writehz(2,2,srsd,0);
3"
tm12864_writehz(2,4,lssd,0);
4"
tm12864_writehz(2,6,xtcs,0);
tm12864_writehz(2,0,scsd,0);
tm12864_writehz(2,2,srsd,1);
tm12864_writehz(2,4,lssd,1);
tm12864_writehz(2,6,xtcs,1);
menuitem=0x02;
if(submenuitem<
0x03)
submenuitem++;
menuitem=0x04+submenuitem;
//如果密码与隐蔽选单密码相符则进入隐蔽选单
/*
if(check_password(HIDEMENU))
}*/
tempvar[0]=0x00;
case0x04:
//输出设定菜单