电路设计,软件开发,专业项目团队承接电子产品开发!


ISPRO下载型编程器
火爆销售中

RS232/TTL转换器
全IC串口窃电

RS232/TTL转换线
全IC串口窃电

ByteBlasterMV Cable
CPLD/FPGA并口下载线

ByteBlaster II Cable ISPRO下载型编程器
支持S51/AVR/PIC
超级51开发板套件
前卫实用超值

PC/MCU/CPLD
三合一学习套件

全新万年历方案
AVR单片机开发板
 

Min51单片机仿真机
迷你型

ARM7开发板
仅售260元!
 

RS-232/RS-485双向接口电平转换器  

51单片机升级STM32
火爆销售中
MPLAB-ICD2
火爆销售中
LED51开发板
玩具又名图文显示棒

面板模块/开发板
经济危机明智决择

       

GSM MODEM GSM猫

SMS短信模块 工业级/全自动
火爆销售中

大功率数传电台

高速数传电台

您当前位置:电子技术资料 -> 外围驱动 -> LCD液晶显示 ->

祝您阅读愉快!

ISPRO下载型编程器

RS232 TO TTL转换器
↑↑本文相关产品介绍↑↑

lcd多级菜单完整代码


类别:技术文章
来源:未知
作者:未知
关键字:菜单
加入日期:2010-8-4

//lcd多级菜单完整代码
//中国电子网 www.EC66.com
#include<reg52.h>
#include<absacc.h>
#include<hz-string_t.c>

#define INPUTSET256;

#define DEBUG 0 //0:运行,1:调试
#define ENABLE_INTERRUPT 1//1:中断允许,0:中断禁止

//定义8155地址
#define I8155A0x7000
#define I8155B0x7200
#definePA1
#define PB2
#define PC3

//定义25045地址
#define OUTNUMBER 0x01a1
#define INNUMBER 0x01a2
#define PASSWORD_ADDR 0x01a3
#define HIDE_PASSWORD_ADDR 0x01af

//定义键盘扫描码
#defineBUTTON_START0x28
#define BUTTON_STOP0x48
#define BUTTON_SET0x84
#define BUTTON_OK0x88
#define BUTTON_SLAVE0x81
//0,1,2,3,4,5,6,7,8,9
unsigned char code keyscancode[]=
{0x82,0x11,0x12,0x14,0x21,0x22,0x24,0x41,0x42,0x44};

#include<x25045.h>
#include<tm12864.h>

//new var
unsigned char bdata bitvar;
sbit keypush=bitvar^0;
sbit rrtime_flag=bitvar^1;//读取运行参数标志
sbit showflag=bitvar^2;

unsigned char keycode,tempkey,i,j;
unsigned char menuitem=0x00;
unsigned int runtime[32];

unsigned int xdata starttime[36];
unsigned int xdata stoptime[32];
unsigned int xdata betweentime[32];
unsigned char xdata runno1[36];
unsigned char xdata linkrun[4];
unsigned char xdata linkrunno1[4];

unsigned char xdata submenuitem=0;
unsigned long xdata i8155out;
unsigned char xdata main_temp,outputnumber,inputnumber;
unsigned int xdata tempvar[9];
char xdata showstr[5]=" ";
//new var end

//定义DS12887地址

#define P12887SEC 0x7f00//12887秒地址
#define P12887SEC_ALM 0x7f01//12887秒报警地址
#define P12887MIN 0x7f02//12887分地址
#define P12887MIN_ALM 0x7f03//12887分报警地址
#define P12887HOUR 0x7f04//12887时地址
#define P12887HOUR_ALM 0x7f05//12887时报警地址
#define P12887WEEK 0x7f06//12887星期地址
#define P12887DAY 0x7f07//12887日期地址
#define P12887MONTH 0x7f08//12887月地址
#define P12887YEAR 0x7f09//12887年地址
#define P12887MCA 0x7f0a//寄存器a地址
#define P12887MCB 0x7f0b//寄存器a地址
#define P12887MCC 0x7f0c//寄存器a地址
#define P12887MCD 0x7f0d//寄存器a地址
#define P12887RAM 0x7f0e//12887不掉电RAM起始地址

void init_12887(); //DS12887初始化程序
void gettime_12887(); //取DS12887时间子程序(年月日时分)
void settime_12887(); //设置DS12887时间子程序


void i8155_init(unsigned int memaddress,unsigned char command);
//intel 8155 端口输出
//memaddress:8155基址;
//portnum:端口号(1:PA、2:PB、3:PC)
//portstatu:端口输出字
void i8155_outport(unsigned int memaddress,unsigned char portnum,unsigned char
portstatu);

//intel 8155 端口输入
//memaddress:8155基址;
//portnum:端口号(1:PA、2:PB、3:PC)
//返回值:端口状态
unsigned char i8155_inport(unsigned int memaddress,unsigned char portnum);

void showinitscreen();
void init();

void timer0() interrupt 1 using 1
{
unsigned char temp;
//晶振为 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;
}
else if((XBYTE[0x7ed0]&0x0f)!=0x0f)
{
keycode=keycode&0x2f;
}
else if((XBYTE[0x7eb0]&0x0f)!=0x0f)
{
keycode=keycode&0x4f;
}
else if((XBYTE[0x7e30]&0x0f)!=0x0f)
{
keycode=keycode&0x8f;
}

}
else
{
keypush=1;
keycode=0;
}
}
else
{
keypush=0;
}
}
void ds12887_int1() interrupt 2 using 2
{
rrtime_flag=0;
ACC=XBYTE[P12887MCC]; //读寄存器C 清除中断请求标志IRQF
}


//**************************************************************
//
//主程序
//
//**************************************************************
void main()
{

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();
TH0=0xd8;
TL0=0x00;


//初始化变量

while(1)
{
init_12887();
//***********************
#if DEBUG
x25045_disable();
#else
x25045_init();
#endif
//***********************

TMOD=0x01;
ET0=1;
TR0=1;
#if ENABLE_INTERRUPT
EX1=1;
PX1=1;
PT0=0;
#endif
EA=1;

//**********************************
//加入限时运行功能
if((x25045_readbyte(0x01bb)==1)&&(menuitem!=0x20)&&(menuitem!=0x1b))
{
tempkey=0;
gettime_12887();
for(i=0;i<3;i++)
{
if(tempvar<=x25045_readbyte(0x01b5-3+i))
{
tempkey++;
}
else
{
break;
}
}
if(tempkey<3)
{
if(menuitem!=0x20)
{
showflag=0;
}
menuitem=0x20;

}
else
{
menuitem=0;
}
tempkey=0x50;
i=0;
}

//**********************************

//主循环开始
tm12864_reset();
x25045_resetwatchdog();
//键盘处理程序

if((keycode!=0)&&(keypush==0))
{
i=0;
while(i<10)
{
if(keycode==keyscancode)
{
tempkey=i;
break;
}
else
{
tempkey=keycode;
}
i++;
}
}
else
{
tempkey=0x50;
}
keycode=0;

//屏幕显示处理
switch(menuitem)
{
case 0x00://自动运行状态
tm12864_reset();
if(showflag==0)
{
tm12864_fillscreen(0x00);
showflag=1;

}
showinitscreen();
tm12864_writestr(0,0," ",0);
tm12864_writestr(12,0," ",0);
tm12864_writestr(0,4," ",0);
tm12864_writestr(0,6," ",0);
tm12864_writehz(4,6,zzyx,0);
tm12864_writestr(12,6," ",0);

if(tempkey==BUTTON_STOP)//进入“设置确认”菜单
{
j=0;
menuitem=0x01;
showflag=0;
}
tempkey=0x50;
break;
case 0x01://设置确认菜单
tm12864_reset();
if(showflag==0)
{
tm12864_fillscreen(0x00);
tm12864_writestr(4,6," ",1);
tm12864_writehz(0,6,mm,0);
showflag=1;
}
showinitscreen();


if((j<6)&&(tempkey<0x0a))
{
tm12864_writehz(0,6,mm,0);
tm12864_writestr((j+4),6,"*",1);
tempvar[j]=tempkey;
j++;
}
if(j==6)
{
for(j=0;j<6;j++)
{
if(tempvar[j]!=x25045_readbyte(PASSWORD_ADDR+j))
{
j=0;
showflag=0;
menuitem=0x00;
break;
}
}
tm12864_writestr(0,6," ",0);
tm12864_writestr(6,6," ",0);
tm12864_writehz(2,6,set,1);
tm12864_writehz(10,6,yunxing,0);
if(tempkey==BUTTON_OK)
{
menuitem=0x03;
j=0;
submenuitem=0;
showflag=0;
tempvar[0]=1;
}
}
submenuitem=0;

if(tempkey==BUTTON_START)
{
menuitem=0x00;
showflag=0;
}

tempkey=0x50;
break;
case 0x02://运行确认菜单
tm12864_reset();
if(showflag==0)
{
tm12864_fillscreen(0x00);
showflag=1;
}
showinitscreen();
switch(submenuitem)
{
case 0x00:
tm12864_writehz(2,6,set,0);
tm12864_writehz(10,6,yunxing,1);
switch(tempkey)
{
case BUTTON_OK:
menuitem=0x00;
showflag=0;
while(1){};
break;
case BUTTON_STOP:
case BUTTON_SLAVE:
submenuitem=0x01;
showflag=0;
break;
}
break;
case 0x01:
tm12864_writehz(2,6,set,1);
tm12864_writehz(10,6,yunxing,0);
switch(tempkey)
{
case BUTTON_OK:
menuitem=0x03;
showflag=0;
submenuitem=0x00;
break;
case BUTTON_START:
case BUTTON_SLAVE:
submenuitem=0;
showflag=0;
break;
}
break;
}
tempkey=0x50;
break;
case 0x03://设置菜单
tm12864_reset();
if(showflag==0)
{
tm12864_fillscreen(0x00);
showflag=1;
j=0;
}
x25045_writestatu(0x00);

原程序2 [huxiangming] [68次] 01-11-16 下午 10:39:14


// *******************************************************
//加入隐蔽菜单功能

if((j<6)&&(tempkey<0x0a))
{
tempvar[j]=tempkey;
j++;
showstr[0]=j+0x30;
showstr[1]='\0';
tm12864_writestr(15,7,showstr,0);
tempkey=0x50;
}

if(j==6)
{
for(j=0;j<6;j++)
{
#if DEBUG
tempvar[j]=x25045_readbyte(0x01a9+j);
#else
if(tempvar[j]!=x25045_readbyte(0x01a9+j))
{
j=0;
break;
}
#endif
}
if(tempkey==BUTTON_SET)
{
menuitem=0x1b;
j=0;
submenuitem=0;
showflag=0;
tempvar[0]=1;
}
}
// *******************************************************
switch(submenuitem)
{
case 0x00:
tm12864_writestr(0,0,"1 ",1);
tm12864_writehz(2,0,scsd,1);
tm12864_writestr(0,2,"2 ",0);
tm12864_writehz(2,2,srsd,0);
tm12864_writestr(0,4,"3 ",0);
tm12864_writehz(2,4,lssd,0);
tm12864_writestr(0,6,"4 ",0);
tm12864_writehz(2,6,xtcs,0);

break;
case 0x01:
tm12864_writestr(0,0,"1 ",0);
tm12864_writehz(2,0,scsd,0);
tm12864_writestr(0,2,"2 ",1);
tm12864_writehz(2,2,srsd,1);
tm12864_writestr(0,4,"3 ",0);
tm12864_writehz(2,4,lssd,0);
tm12864_writestr(0,6,"4 ",0);
tm12864_writehz(2,6,xtcs,0);
break;
case 0x02:
tm12864_writestr(0,0,"1 ",0);
tm12864_writehz(2,0,scsd,0);
tm12864_writestr(0,2,"2 ",0);
tm12864_writehz(2,2,srsd,0);
tm12864_writestr(0,4,"3 ",1);
tm12864_writehz(2,4,lssd,1);
tm12864_writestr(0,6,"4 ",0);
tm12864_writehz(2,6,xtcs,0);
break;
case 0x03:
tm12864_writestr(0,0,"1 ",0);
tm12864_writehz(2,0,scsd,0);
tm12864_writestr(0,2,"2 ",0);
tm12864_writehz(2,2,srsd,0);
tm12864_writestr(0,4,"3 ",0);
tm12864_writehz(2,4,lssd,0);
tm12864_writestr(0,6,"4 ",1);
tm12864_writehz(2,6,xtcs,1);
break;

}
switch(tempkey)
{
case BUTTON_START:
menuitem=0x02;
submenuitem=0;
showflag=0;
break;

case BUTTON_SLAVE:
if(submenuitem<0x03)
{
submenuitem++;
}
else
{
submenuitem=0x00;
}
break;
case BUTTON_OK:
menuitem=0x04+submenuitem;
//如果密码与隐蔽选单密码相符则进入隐蔽选单
/*
if(check_password(HIDEMENU))
{
menuitem=0x20;
}*/
submenuitem=0x00;
tempvar[0]=0x00;
showflag=0;
break;
}
tempkey=0x50;
break;

case 0x04://输出设定菜单
tm12864_reset();
if(showflag==0)
{
tm12864_fillscreen(0x00);

showflag=1;
}
tm12864_writehz(0,0,xzhlh,0);
tm12864_writestr(10,0," ",0);
tm12864_writehz(14,0,hao,0);
tm12864_writehz(0,2,gz,0);
tm12864_writehz(10,2,fen,0);
tm12864_writehz(14,2,miao,0);
tm12864_writehz(0,4,tz,0);
tm12864_writehz(14,4,miao,0);
tm12864_writehz(0,6,jg,0);//汉字“间隔”尚未建立
tm12864_writehz(14,6,miao,0);

if(submenuitem!=7)
{
tm12864_writehz(10,4,fen,0);
tm12864_writehz(10,6,fen,0);

}

switch(tempkey)
{
case BUTTON_SLAVE:
if(submenuitem<7)
{
submenuitem++;
}
else
{
showflag=0;
submenuitem=0;
tempvar[0]=0;
}
if((tempvar[0]>32)||(tempvar[0]==0))
{
submenuitem=0;
tempvar[0]=0;
}
else if(tempvar[2]>59)
{
submenuitem=2;
tempvar[2]=0;
}
else if(tempvar[4]>59)
{
submenuitem=4;
tempvar[4]=0;
}
else if(tempvar[6]>59)
{
submenuitem=6;
tempvar[6]=0;
}
j=0;
break;
case BUTTON_STOP:
submenuitem=0x00;
menuitem=0x03;
showflag=0;
tempvar[0]=0;
j=0;
break;
}

switch(submenuitem)
{
case 0://获取回路号
if((j<2)&&(tempkey<0x0a))
{
tempvar[0]=tempvar[0]*0x0a+tempkey;
j++;
}

showstr[0]=(tempvar[0]/0x0a+0x30);
showstr[1]=(tempvar[0]%0x0a+0x30);
showstr[2]='\0';
tm12864_writestr(12,0,showstr,1);
break;
case 1://获取工作时间-分
showstr[0]=(tempvar[0]/0x0a+0x30);
showstr[1]=(tempvar[0]%0x0a+0x30);
showstr[2]='\0';
tm12864_writestr(12,0,showstr,0);
if(j==0)
{
if(tempvar[0]!=0)
{
tempvar[1]=x25045_readword((tempvar[0]*7-7));
tempvar[2]=tempvar[1]%60;
tempvar[1]=tempvar[1]/60;
tempvar[3]=x25045_readword((tempvar[0]*7-5));
tempvar[4]=tempvar[3]%60;
tempvar[3]=tempvar[3]/60;
tempvar[5]=x25045_readword((tempvar[0]*7-3));
tempvar[6]=tempvar[5]%60;
tempvar[5]=tempvar[5]/60;
showstr[0]=(tempvar[2]/10+0x30);
showstr[1]=(tempvar[2]%10+0x30);
showstr[2]='\0';
tm12864_writestr(12,2,showstr,0);
showstr[0]=(tempvar[3]/1000+0x30);
showstr[1]=((tempvar[3]%1000)/100+0x30);
showstr[2]=((tempvar[3]%100)/10+0x30);
showstr[3]=(tempvar[3]%10+0x30);
showstr[4]='\0';
tm12864_writestr(6,4,showstr,0);
showstr[0]=(tempvar[4]/10+0x30);
showstr[1]=(tempvar[4]%10+0x30);
showstr[2]='\0';
tm12864_writestr(12,4,showstr,0);
showstr[0]=(tempvar[5]/1000+0x30);
showstr[1]=((tempvar[5]%1000)/100+0x30);
showstr[2]=((tempvar[5]%100)/10+0x30);
showstr[3]=(tempvar[5]%10+0x30);
showstr[4]='\0';
tm12864_writestr(6,6,showstr,0);
showstr[0]=(tempvar[6]/10+0x30);
showstr[1]=(tempvar[6]%10+0x30);
showstr[2]='\0';
tm12864_writestr(12,6,showstr,0);


}
else
{
tempvar[1]=0x00;
tempvar[2]=0x00;
tempvar[3]=0x00;
tempvar[4]=0x00;
tempvar[5]=0x00;
tempvar[6]=0x00;

}
}
if((j<4)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[1]=0;
}
tempvar[1]=((tempvar[1]*0x0a)+(int)tempkey);
j++;
}
showstr[0]=(tempvar[1]/1000+0x30);
showstr[1]=((tempvar[1]%1000)/100+0x30);
showstr[2]=((tempvar[1]%100)/10+0x30);
showstr[3]=(tempvar[1]%10+0x30);
showstr[4]='\0';
tm12864_writestr(6,2,showstr,1);
break;
case 2://获取工作时间-秒
showstr[0]=(tempvar[1]/1000+0x30);
showstr[1]=((tempvar[1]%1000)/100+0x30);
showstr[2]=((tempvar[1]%100)/10+0x30);
showstr[3]=(tempvar[1]%10+0x30);
showstr[4]='\0';
tm12864_writestr(6,2,showstr,0);
if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[2]=0;
}
tempvar[2]=tempvar[2]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[2]/10+0x30);
showstr[1]=(tempvar[2]%10+0x30);
showstr[2]='\0';
tm12864_writestr(12,2,showstr,1);
break;
case 3://获取停止时间-分
showstr[0]=(tempvar[2]/10+0x30);
showstr[1]=(tempvar[2]%10+0x30);
showstr[2]='\0';
tm12864_writestr(12,2,showstr,0);
if((j<4)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[3]=0;
}
tempvar[3]=tempvar[3]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[3]/1000+0x30);
showstr[1]=((tempvar[3]%1000)/100+0x30);
showstr[2]=((tempvar[3]%100)/10+0x30);
showstr[3]=(tempvar[3]%10+0x30);
showstr[4]='\0';
tm12864_writestr(6,4,showstr,1);
break;
case 4://获取停止时间-秒
showstr[0]=(tempvar[3]/1000+0x30);
showstr[1]=((tempvar[3]%1000)/100+0x30);
showstr[2]=((tempvar[3]%100)/10+0x30);
showstr[3]=(tempvar[3]%10+0x30);
showstr[4]='\0';
tm12864_writestr(6,4,showstr,0);
if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[4]=0;
}
tempvar[4]=tempvar[4]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[4]/10+0x30);
showstr[1]=(tempvar[4]%10+0x30);
showstr[2]='\0';
tm12864_writestr(12,4,showstr,1);
break;
case 5://获取间隔时间-分
showstr[0]=(tempvar[4]/10+0x30);
showstr[1]=(tempvar[4]%10+0x30);
showstr[2]='\0';
tm12864_writestr(12,4,showstr,0);
if((j<4)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[5]=0;
}
tempvar[5]=tempvar[5]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[5]/1000+0x30);
showstr[1]=((tempvar[5]%1000)/100+0x30);
showstr[2]=((tempvar[5]%100)/10+0x30);
showstr[3]=(tempvar[5]%10+0x30);
showstr[4]='\0';
tm12864_writestr(6,6,showstr,1);
break;
case 6://获取间隔时间-秒
showstr[0]=(tempvar[5]/1000+0x30);
showstr[1]=((tempvar[5]%1000)/100+0x30);
showstr[2]=((tempvar[5]%100)/10+0x30);
showstr[3]=(tempvar[5]%10+0x30);
showstr[4]='\0';
tm12864_writestr(6,6,showstr,0);
if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[6]=0;
}
tempvar[6]=tempvar[6]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[6]/10+0x30);
showstr[1]=(tempvar[6]%10+0x30);
showstr[2]='\0';
tm12864_writestr(12,6,showstr,1);
break;
case 7://确认存储菜单
tm12864_writestr(12,6,showstr,0);
tm12864_writehz(4,5,bmp1,0);
if(tempkey==BUTTON_OK)
{
tempvar[1]=tempvar[1]*60;
tempvar[1]=tempvar[1]+tempvar[2];
tempvar[3]=tempvar[3]*60;
tempvar[3]=tempvar[3]+tempvar[4];
tempvar[5]=tempvar[5]*60;
tempvar[5]=tempvar[5]+tempvar[6];

x25045_init();
//保存工作时间
x25045_writeenable();
x25045_writeword(tempvar[1],(tempvar[0]*7-7));
//保存停止时间
x25045_writeenable();
x25045_writeword(tempvar[3],(tempvar[0]*7-5));
//保存间隔时间
x25045_writeenable();
x25045_writeword(tempvar[5],(tempvar[0]*7-3));

submenuitem=0;
showflag=0;
tempvar[0]=0x00;
j=0;
}
break;

}
tempkey=0x50;
break;

原程序3 [huxiangming] [57次] 01-11-16 下午 10:40:51
case 0x05://设置输入回路
tm12864_reset();
if(showflag==0)
{
tm12864_fillscreen(0x00);
showflag=1;
}
tm12864_writehz(2,0,sdsrhl,0);
tm12864_writehz(0,2,xzhlh,0);
tm12864_writehz(14,2,hao,0);
tm12864_writehz(0,4,lj,0);//连接
if(submenuitem!=0x03)
{
tm12864_writehz(6,4,hschl,0);//号回路
}
tm12864_writehz(0,6,gn,0);//功能
tm12864_writestr(4,6,": ",0);
switch(tempkey)
{
case BUTTON_SLAVE:
if(submenuitem<3)
{
submenuitem++;
}
else
{
submenuitem=0;
showflag=0;
tm12864_writehz(6,4,hschl,0);
tm12864_writestr(4,6,": ",0);
tempvar[0]=0;
}
if((tempvar[0]==0)||(tempvar[0]>76))
{
tempvar[0]=0;
submenuitem=0;
}
else if((tempvar[1]==0)||((tempvar[1]>36)&&(tempvar[1]!=99)))
{
tempvar[1]=0;
submenuitem=1;
}
j=0;
break;
case BUTTON_STOP:
menuitem=0x03;
submenuitem=0x01;
showflag=0;
tempvar[0]=0;
j=0;
break;
}
switch(submenuitem)
{
case 0://获取回路号

if((j<2)&&(tempkey<0x0a))
{
tempvar[0]=tempvar[0]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[0]/0x0a+0x30);
showstr[1]=(tempvar[0]%0x0a+0x30);
showstr[2]='\0';
tm12864_writestr(12,2,showstr,1);
break;
case 1://获取输出回路号
showstr[0]=(tempvar[0]/0x0a+0x30);
showstr[1]=(tempvar[0]%0x0a+0x30);
showstr[2]='\0';
tm12864_writestr(12,2,showstr,0);
if(j==0)
{
if(tempvar[0]!=0)
{
tempvar[1]=x25045_readbyte(tempvar[0]*2-2+0x100);
tempvar[2]=x25045_readbyte(tempvar[0]*2-1+0x100);
if(tempvar[2]==1)
{
tm12864_writehz(6,6,qdsc,0);
}
else
{
tm12864_writehz(6,6,tzsc,0);
}
}
else
{
tempvar[1]=0x00;
tempvar[2]=0x00;
}
}
if((j<4)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[1]=0;
}
tempvar[1]=tempvar[1]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[1]/10+0x30);
showstr[1]=(tempvar[1]%10+0x30);
showstr[2]='\0';
tm12864_writestr(4,4,showstr,1);
break;
case 2://获取功能
tm12864_writestr(4,4,showstr,0);
if(tempvar[2]==1)
{
tm12864_writehz(6,6,qdsc,1);
}
else
{
tm12864_writehz(6,6,tzsc,1);
}
if(tempkey==BUTTON_SET)
{
if(tempvar[2]==0)
{
tempvar[2]=1;
}
else
{
tempvar[2]=0;
}
}
break;
case 3://确认存储菜单
tm12864_writehz(4,5,bmp1,0);
if(tempkey==BUTTON_OK)
{

//保存参数
x25045_init();
x25045_writeenable();
x25045_writebyte(tempvar[1],(0x100+tempvar[0]*2-2));
x25045_writeenable();
x25045_writebyte(tempvar[2],(0x100+tempvar[0]*2-1));
if(tempvar[1]==99)//加入指向联动回路处理
{
x25045_writeenable();
x25045_writebyte(tempvar[0],0x00ff);
}

submenuitem=0;
showflag=0;
tempvar[0]=0;
j=0;
}
break;

}
break;
case 0x06://联锁功能选择
tm12864_reset();
if(showflag==0)
{
tm12864_fillscreen(0x00);
showflag=1;
}
tm12864_writehz(4,0,lssd,0);
switch(submenuitem)
{
case 0x00:
tm12864_writehz(0,2,ldzsd,1);
tm12864_writehz(0,4,hszsd,0);
break;
case 0x01:
tm12864_writehz(0,2,ldzsd,0);
tm12864_writehz(0,4,hszsd,1);
break;
}
switch(tempkey)
{
case BUTTON_SLAVE:
if(submenuitem<1)
{
submenuitem++;
}
else
{
submenuitem=0;
showflag=0;
}
break;
case BUTTON_OK:
menuitem=0x0b+submenuitem;
submenuitem=0x00;
showflag=0;
for(i=0;i<9;i++)
{
tempvar=0;
}
j=0;
break;
case BUTTON_STOP:
menuitem=0x03;
submenuitem=0x02;
showflag=0;
break;
}
break;
case 0x07://系统参数
tm12864_reset();
if(showflag==0)
{
tm12864_fillscreen(0x00);
showflag=1;
}
tm12864_writehz(4,0,xtcs,0);
switch(submenuitem)
{
case 0x00:
tm12864_writehz(0,2,srscds,1);//输入输出点数
tm12864_writehz(0,4,xtsj,0);//系统时间
tm12864_writehz(0,6,mm,0);
break;
case 0x01:
tm12864_writehz(0,2,srscds,0);//输入输出点数
tm12864_writehz(0,4,xtsj,1);//系统时间
tm12864_writehz(0,6,mm,0);
break;
case 0x02:
tm12864_writehz(0,2,srscds,0);//输入输出点数
tm12864_writehz(0,4,xtsj,0);//系统时间
tm12864_writehz(0,6,mm,1);
break;
}
switch(tempkey)
{
case BUTTON_SLAVE:
if(submenuitem<2)
{
submenuitem++;
}
else
{
submenuitem=0;
showflag=0;
}
break;
case BUTTON_OK:
menuitem=0x08+submenuitem;
submenuitem=0x00;
showflag=0;
tempvar[0]=0;
if(menuitem==0x09)
{
gettime_12887();
}
j=0;
break;
case BUTTON_STOP:
menuitem=0x03;
submenuitem=0x03;
showflag=0;
break;
}
break;
case 0x08://输入输出点数
tm12864_reset();
if(showflag==0)
{
tm12864_fillscreen(0x00);
showflag=1;
}
tm12864_writehz(2,0,srscds,0);
if(submenuitem!=0x02)
{
tm12864_writehz(0,4,srds,0);//输入点数
tm12864_writehz(0,6,scds,0);//输出点数
}
tm12864_writehz(14,4,dian,0);
tm12864_writehz(14,6,dian,0);
switch(submenuitem)
{
case 0x00:
if(j==0)
{
tempvar[1]=x25045_readbyte(INNUMBER);
tempvar[2]=x25045_readbyte(OUTNUMBER);
showstr[0]=(tempvar[2]/10+0x30);
showstr[1]=(tempvar[2]%10+0x30);
showstr[2]='\0';
tm12864_writestr(12,6,showstr,0);
}

if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[1]=0;
}
tempvar[1]=tempvar[1]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[1]/10+0x30);
showstr[1]=(tempvar[1]%10+0x30);
showstr[2]='\0';
tm12864_writestr(12,4,showstr,1);
break;
case 0x01:
showstr[0]=(tempvar[1]/10+0x30);
showstr[1]=(tempvar[1]%10+0x30);
showstr[2]='\0';
tm12864_writestr(12,4,showstr,0);

if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[2]=0;
}
tempvar[2]=tempvar[2]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[2]/10+0x30);
showstr[1]=(tempvar[2]%10+0x30);
showstr[2]='\0';
tm12864_writestr(12,6,showstr,1);
break;
case 0x02://确认存储菜单
tm12864_writehz(4,5,bmp1,0);
if(tempkey==BUTTON_OK)
{
//保存参数
x25045_init();
x25045_writeenable();
x25045_writebyte(tempvar[1],INNUMBER);
x25045_writeenable();
x25045_writebyte(tempvar[2],OUTNUMBER);

menuitem=0x07;
submenuitem=0;
showflag=0;
tempvar[0]=0;
j=0;
}
break;
}
switch(tempkey)
{
case BUTTON_SLAVE:
if(submenuitem<2)
{
submenuitem++;
}
else
{
submenuitem=0;
showflag=0;
tempvar[0]=0;
}
if(tempvar[1]>12)
{
tempvar[1]=0;
submenuitem=0;
}
else if((tempvar[2]>32)||(tempvar[2]==0))
{
tempvar[2]=0;
submenuitem=1;
}
j=0;
break;
case BUTTON_STOP:
menuitem=0x07;
submenuitem=0x00;
showflag=0;
tempvar[0]=0;
j=0;
break;
}

break;
case 0x09://系统时间
tm12864_reset();
if(showflag==0)
{
tm12864_fillscreen(0x00);
showflag=1;
showstr[0]=(tempvar[0]/1000+0x30);
showstr[1]=((tempvar[0]%1000)/100+0x30);
showstr[2]=((tempvar[0]%100)/10+0x30);
showstr[3]=(tempvar[0]%10+0x30);
showstr[4]='\0';
tm12864_writestr(0,4,showstr,0);
showstr[0]=(tempvar[1]/10+0x30);
showstr[1]=(tempvar[1]%10+0x30);
showstr[2]='\0';
tm12864_writestr(6,4,showstr,0);
showstr[0]=(tempvar[2]/10+0x30);
showstr[1]=(tempvar[2]%10+0x30);
showstr[2]='\0';
tm12864_writestr(10,4,showstr,0);
showstr[0]=(tempvar[3]/10+0x30);
showstr[1]=(tempvar[3]%10+0x30);
showstr[2]='\0';
tm12864_writestr(2,6,showstr,0);
showstr[0]=(tempvar[4]/10+0x30);
showstr[1]=(tempvar[4]%10+0x30);
showstr[2]='\0';
tm12864_writestr(6,6,showstr,0);
}
tm12864_writehz(4,0,xtsj,0);
tm12864_writehz(12,4,ri,0);

if(submenuitem!=5)
{
tm12864_writehz(4,4,nian,0);
tm12864_writehz(8,4,yue,0);
tm12864_writehz(4,6,shi,0);
tm12864_writehz(8,6,fen,0);
}
switch(tempkey)
{
case BUTTON_SLAVE:
if(submenuitem<5)
{
submenuitem++;
}
else
{
showflag=0;
submenuitem=0;
gettime_12887();
}
if(tempvar[0]<2000)
{
tempvar[0]=2001;
submenuitem=0;
}
else if((tempvar[1]>12)||(tempvar[1]==0))
{
tempvar[1]=0;
submenuitem=1;
}
else if((tempvar[2]>31)||(tempvar[2]==0))
{
tempvar[2]=0;
submenuitem=2;
}
else if(tempvar[3]>24)
{
tempvar[3]=0;
submenuitem=3;
}
else if(tempvar[4]>59)
{
tempvar[4]=0;
submenuitem=4;
}
j=0;
break;
case BUTTON_STOP:
submenuitem=0x01;
menuitem=0x07;
showflag=0;
tempvar[0]=0;
j=0;
break;
}


原程序4 [huxiangming] [58次] 01-11-16 下午 10:41:44

switch(submenuitem)
{
case 0://获取年

if((j<4)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[0]=0;
}
tempvar[0]=((tempvar[0]*0x0a)+(int)tempkey);
j++;
}
showstr[0]=(tempvar[0]/1000+0x30);
showstr[1]=((tempvar[0]%1000)/100+0x30);
showstr[2]=((tempvar[0]%100)/10+0x30);
showstr[3]=(tempvar[0]%10+0x30);
showstr[4]='\0';
tm12864_writestr(0,4,showstr,1);

break;
case 1://获取月
showstr[0]=(tempvar[0]/1000+0x30);
showstr[1]=((tempvar[0]%1000)/100+0x30);
showstr[2]=((tempvar[0]%100)/10+0x30);
showstr[3]=(tempvar[0]%10+0x30);
showstr[4]='\0';
tm12864_writestr(0,4,showstr,0);
if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[1]=0;
}
tempvar[1]=((tempvar[1]*0x0a)+(int)tempkey);
j++;
}
showstr[0]=(tempvar[1]/10+0x30);
showstr[1]=(tempvar[1]%10+0x30);
showstr[2]='\0';
tm12864_writestr(6,4,showstr,1);
break;
case 2://获取日
showstr[0]=(tempvar[1]/10+0x30);
showstr[1]=(tempvar[1]%10+0x30);
showstr[2]='\0';
tm12864_writestr(6,4,showstr,0);
if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[2]=0;
}
tempvar[2]=((tempvar[2]*0x0a)+(int)tempkey);
j++;
}
showstr[0]=(tempvar[2]/10+0x30);
showstr[1]=(tempvar[2]%10+0x30);
showstr[2]='\0';
tm12864_writestr(10,4,showstr,1);
break;
case 3://获取时
showstr[0]=(tempvar[2]/10+0x30);
showstr[1]=(tempvar[2]%10+0x30);
showstr[2]='\0';
tm12864_writestr(10,4,showstr,0);
if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[3]=0;
}
tempvar[3]=((tempvar[3]*0x0a)+(int)tempkey);
j++;
}
showstr[0]=(tempvar[3]/10+0x30);
showstr[1]=(tempvar[3]%10+0x30);
showstr[2]='\0';
tm12864_writestr(2,6,showstr,1);
break;
case 4://获取分
showstr[0]=(tempvar[3]/10+0x30);
showstr[1]=(tempvar[3]%10+0x30);
showstr[2]='\0';
tm12864_writestr(2,6,showstr,0);
if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[4]=0;
}
tempvar[4]=((tempvar[4]*0x0a)+(int)tempkey);
j++;
}
showstr[0]=(tempvar[4]/10+0x30);
showstr[1]=(tempvar[4]%10+0x30);
showstr[2]='\0';
tm12864_writestr(6,6,showstr,1);
break;
case 5://确认存储菜单
tm12864_writehz(4,5,bmp1,0);
if(tempkey==BUTTON_OK)
{
settime_12887();
menuitem=0x07;
submenuitem=1;
showflag=0;
j=0;
}
break;

}
tempkey=0x50;
break;

break;
case 0x0a://密码

tm12864_reset();
if(showflag==0)
{
tm12864_fillscreen(0x00);
}
tm12864_writehz(2,0,ymm,0);
tm12864_writestr(8,0,": ",0);
if(submenuitem!=2)
{
tm12864_writehz(2,4,xmm,0);
tm12864_writestr(8,4,": ",0);
}
switch(submenuitem)
{
case 0://获取旧密码
if(showflag==0)
{
tm12864_writestr(0,2," ",1);
showflag=1;
}

if((j<6)&&(tempkey<0x0a))
{
tm12864_writestr(j,2,"*",1);
tempvar[j]=tempkey;
j++;
}
break;
case 1://获取新密码
tm12864_writestr(0,2,"******",0);
if(showflag==0)
{
tm12864_writestr(0,6," ",1);
showflag=1;
}
if((j<6)&&(tempkey<0x0a))
{
tm12864_writestr(j,6,"*",1);
tempvar[j]=tempkey;
j++;
}
break;
case 2://确认存储菜单
tm12864_writestr(12,6," ",0);
tm12864_writehz(4,5,bmp1,0);
showflag=1;
if(tempkey==BUTTON_OK)
{
x25045_init();
for(i=0;i<6;i++)
{
x25045_writeenable();
x25045_writebyte(tempvar,(PASSWORD_ADDR+i));
tempvar=0;
}

menuitem=0x07;
submenuitem=2;
showflag=0;
j=0;
}
break;

}

switch(tempkey)
{
case BUTTON_SLAVE:
if(submenuitem<2)
{
if(submenuitem==0x00)
{
for(i=0;i<6;i++)
{
if(tempvar!=x25045_readbyte(PASSWORD_ADDR+i))
{
goto jp;
break;
}
}
}
submenuitem++;
}
else
{
submenuitem=0;
}
jp:showflag=0;
j=0;
break;
case BUTTON_STOP:
submenuitem=2;
menuitem=0x07;
showflag=0;
break;
}
break;
case 0x0b://联动回路设定
tm12864_reset();
if(showflag==0)
{
tm12864_fillscreen(0x00);

showflag=1;
}
tm12864_writehz(0,0,xzldz,0);
tm12864_writestr(10,0," ",0);
tm12864_writehz(14,0,zu,0);
tm12864_writehz(0,2,xlhlld,0);
tm12864_writehz(2,4,hao,0);
tm12864_writehz(6,4,hao,0);
tm12864_writehz(10,4,hao,0);
tm12864_writehz(14,4,hao,0);
tm12864_writehz(2,6,hao,0);
tm12864_writehz(6,6,hao,0);
tm12864_writehz(10,6,hao,0);
tm12864_writehz(14,6,hao,0);

if(submenuitem!=7)
{

}

switch(tempkey)
{
case BUTTON_SLAVE:
if(submenuitem<9)
{
submenuitem++;
}
else
{
showflag=0;
submenuitem=0;
tempvar[0]=0;
}

if(tempvar[0]>4)
{
tempvar[0]=0;
submenuitem=0;
}
else
{
for(i=1;i<9;i++)
{
if(tempvar>32)
{
tempvar=0;
submenuitem=i;
break;
}
}
}
j=0;
break;
case BUTTON_STOP:
submenuitem=0x00;
menuitem=0x06;
showflag=0;
tempvar[0]=0;
j=0;
break;
}

switch(submenuitem)
{
case 0://获取回路号
if((j<2)&&(tempkey<0x0a))
{
tempvar[0]=tempvar[0]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[0]/0x0a+0x30);
showstr[1]=(tempvar[0]%0x0a+0x30);
showstr[2]='\0';
tm12864_writestr(12,0,showstr,1);
break;
case 1://获取回路号1
showstr[0]=(tempvar[0]/0x0a+0x30);
showstr[1]=(tempvar[0]%0x0a+0x30);
showstr[2]='\0';
tm12864_writestr(12,0,showstr,0);
if(j==0)
{
if(tempvar[0]!=0)
{
for(i=1;i<9;i++)
{
tempvar=x25045_readbyte((0x01bc+(tempvar[0]-1)*9+i-1));
}
showstr[0]=(tempvar[2]/10+0x30);
showstr[1]=(tempvar[2]%10+0x30);
showstr[2]='\0';
tm12864_writestr(4,4,showstr,0);
showstr[0]=(tempvar[3]/10+0x30);
showstr[1]=(tempvar[3]%10+0x30);
showstr[2]='\0';
tm12864_writestr(8,4,showstr,0);
showstr[0]=(tempvar[4]/10+0x30);
showstr[1]=(tempvar[4]%10+0x30);
showstr[2]='\0';
tm12864_writestr(12,4,showstr,0);
showstr[0]=(tempvar[5]/10+0x30);
showstr[1]=(tempvar[5]%10+0x30);
showstr[2]='\0';
tm12864_writestr(0,6,showstr,0);
showstr[0]=(tempvar[6]/10+0x30);
showstr[1]=(tempvar[6]%10+0x30);
showstr[2]='\0';
tm12864_writestr(4,6,showstr,0);
showstr[0]=(tempvar[7]/10+0x30);
showstr[1]=(tempvar[7]%10+0x30);
showstr[2]='\0';
tm12864_writestr(8,6,showstr,0);
showstr[0]=(tempvar[8]/10+0x30);
showstr[1]=(tempvar[8]%10+0x30);
showstr[2]='\0';
tm12864_writestr(12,6,showstr,0);
}
else
{
tempvar[1]=0x00;
tempvar[2]=0x00;
tempvar[3]=0x00;
tempvar[4]=0x00;
tempvar[5]=0x00;
tempvar[6]=0x00;

}
}
if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[1]=0;
}
tempvar[1]=((tempvar[1]*0x0a)+(int)tempkey);
j++;
}
showstr[0]=(tempvar[1]/10+0x30);
showstr[1]=(tempvar[1]%10+0x30);
showstr[2]='\0';
tm12864_writestr(0,4,showstr,1);
break;
case 2://获取回路号2
showstr[0]=(tempvar[1]/10+0x30);
showstr[1]=(tempvar[1]%10+0x30);
showstr[2]='\0';
tm12864_writestr(0,4,showstr,0);
if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[2]=0;
}
tempvar[2]=tempvar[2]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[2]/10+0x30);
showstr[1]=(tempvar[2]%10+0x30);
showstr[2]='\0';
tm12864_writestr(4,4,showstr,1);
break;
case 3://获取回路号3
showstr[0]=(tempvar[2]/10+0x30);
showstr[1]=(tempvar[2]%10+0x30);
showstr[2]='\0';
tm12864_writestr(4,4,showstr,0);
if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[3]=0;
}
tempvar[3]=tempvar[3]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[3]/10+0x30);
showstr[1]=(tempvar[3]%10+0x30);
showstr[2]='\0';
tm12864_writestr(8,4,showstr,1);
break;
case 4://获取回路号4
showstr[0]=(tempvar[3]/10+0x30);
showstr[1]=(tempvar[3]%10+0x30);
showstr[2]='\0';
tm12864_writestr(8,4,showstr,0);
if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[4]=0;
}
tempvar[4]=tempvar[4]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[4]/10+0x30);
showstr[1]=(tempvar[4]%10+0x30);
showstr[2]='\0';
tm12864_writestr(12,4,showstr,1);
break;
case 5://获取回路号5
showstr[0]=(tempvar[4]/10+0x30);
showstr[1]=(tempvar[4]%10+0x30);
showstr[2]='\0';
tm12864_writestr(12,4,showstr,0);
if((j<4)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[5]=0;
}
tempvar[5]=tempvar[5]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[5]/10+0x30);
showstr[1]=(tempvar[5]%10+0x30);
showstr[2]='\0';
tm12864_writestr(0,6,showstr,1);
break;

原程序5 [huxiangming] [57次] 01-11-16 下午 10:42:22
case 6://获取回路号6
showstr[0]=(tempvar[5]/10+0x30);
showstr[1]=(tempvar[5]%10+0x30);
showstr[2]='\0';
tm12864_writestr(0,6,showstr,0);
if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[6]=0;
}
tempvar[6]=tempvar[6]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[6]/10+0x30);
showstr[1]=(tempvar[6]%10+0x30);
showstr[2]='\0';
tm12864_writestr(4,6,showstr,1);
break;
case 7://获取回路号7
showstr[0]=(tempvar[6]/10+0x30);
showstr[1]=(tempvar[6]%10+0x30);
showstr[2]='\0';
tm12864_writestr(4,6,showstr,0);
if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[7]=0;
}
tempvar[7]=tempvar[7]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[7]/10+0x30);
showstr[1]=(tempvar[7]%10+0x30);
showstr[2]='\0';
tm12864_writestr(8,6,showstr,1);
break;
case 8://获取回路号8
showstr[0]=(tempvar[7]/10+0x30);
showstr[1]=(tempvar[7]%10+0x30);
showstr[2]='\0';
tm12864_writestr(8,6,showstr,0);
if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[8]=0;
}
tempvar[8]=tempvar[8]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[8]/10+0x30);
showstr[1]=(tempvar[8]%10+0x30);
showstr[2]='\0';
tm12864_writestr(12,6,showstr,1);
break;
case 9://确认存储菜单
tm12864_writehz(4,5,bmp1,0);
if(tempkey==BUTTON_OK)
{
if(tempvar[0]!=0)
{
x25045_init();
//保存联动回路
for(i=0;i<8;i++)
{
x25045_writeenable();
x25045_writebyte(tempvar[i+1],(0x01bc+(tempvar[0]-1)*9+i));
}
}
submenuitem=0;
showflag=0;
tempvar[0]=0x00;
j=0;
}
break;

}
tempkey=0x50;
break;
case 0x0c://互锁回路设定
tm12864_reset();
if(showflag==0)
{
tm12864_fillscreen(0x00);

showflag=1;
}
tm12864_writehz(0,0,xzhsz,0);
tm12864_writestr(10,0," ",0);
tm12864_writehz(14,0,zu,0);
tm12864_writehz(0,2,dang,0);
tm12864_writehz(4,2,hhlqd,0);
tm12864_writehz(0,4,tzxlhl,0);
tm12864_writehz(2,6,hao,0);
tm12864_writehz(6,6,hao,0);
tm12864_writehz(10,6,hao,0);
tm12864_writehz(14,6,hao,0);

if(submenuitem!=7)
{

}

switch(tempkey)
{
case BUTTON_SLAVE:
if(submenuitem<6)
{
submenuitem++;
}
else
{
showflag=0;
submenuitem=0;
tempvar[0]=0;

}

if(tempvar[0]>6)
{
tempvar[0]=0;
submenuitem=0;
}
else
{
for(i=1;i<6;i++)
{
if(tempvar>32)
{
tempvar=0;
submenuitem=i;
break;
}
}
}
j=0;
break;
case BUTTON_STOP:
submenuitem=0x01;
menuitem=0x06;
showflag=0;
tempvar[0]=0;
j=0;
break;
}

switch(submenuitem)
{
case 0://获取互锁组
if((j<2)&&(tempkey<0x0a))
{
tempvar[0]=tempvar[0]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[0]/0x0a+0x30);
showstr[1]=(tempvar[0]%0x0a+0x30);
showstr[2]='\0';
tm12864_writestr(12,0,showstr,1);
break;
case 1://获取回路号1
showstr[0]=(tempvar[0]/0x0a+0x30);
showstr[1]=(tempvar[0]%0x0a+0x30);
showstr[2]='\0';
tm12864_writestr(12,0,showstr,0);
if(j==0)
{
if(tempvar[0]!=0)
{
for(i=1;i<6;i++)
{
tempvar=x25045_readbyte((0x01e0+(tempvar[0]-1)*9+i-1));
}
showstr[0]=(tempvar[2]/10+0x30);
showstr[1]=(tempvar[2]%10+0x30);
showstr[2]='\0';
tm12864_writestr(0,6,showstr,0);
showstr[0]=(tempvar[3]/10+0x30);
showstr[1]=(tempvar[3]%10+0x30);
showstr[2]='\0';
tm12864_writestr(4,6,showstr,0);
showstr[0]=(tempvar[4]/10+0x30);
showstr[1]=(tempvar[4]%10+0x30);
showstr[2]='\0';
tm12864_writestr(8,6,showstr,0);
showstr[0]=(tempvar[5]/10+0x30);
showstr[1]=(tempvar[5]%10+0x30);
showstr[2]='\0';
tm12864_writestr(12,6,showstr,0);
}
else
{
tempvar[1]=0x00;
tempvar[2]=0x00;
tempvar[3]=0x00;
tempvar[4]=0x00;
tempvar[5]=0x00;
tempvar[6]=0x00;

}
}
if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[1]=0;
}
tempvar[1]=((tempvar[1]*0x0a)+(int)tempkey);
j++;
}
showstr[0]=(tempvar[1]/10+0x30);
showstr[1]=(tempvar[1]%10+0x30);
showstr[2]='\0';
tm12864_writestr(2,2,showstr,1);
break;
case 2://获取回路号2
showstr[0]=(tempvar[1]/10+0x30);
showstr[1]=(tempvar[1]%10+0x30);
showstr[2]='\0';
tm12864_writestr(2,2,showstr,0);
if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[2]=0;
}
tempvar[2]=tempvar[2]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[2]/10+0x30);
showstr[1]=(tempvar[2]%10+0x30);
showstr[2]='\0';
tm12864_writestr(0,6,showstr,1);
break;
case 3://获取回路号3
showstr[0]=(tempvar[2]/10+0x30);
showstr[1]=(tempvar[2]%10+0x30);
showstr[2]='\0';
tm12864_writestr(0,6,showstr,0);
if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[3]=0;
}
tempvar[3]=tempvar[3]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[3]/10+0x30);
showstr[1]=(tempvar[3]%10+0x30);
showstr[2]='\0';
tm12864_writestr(4,6,showstr,1);
break;
case 4://获取回路号4
showstr[0]=(tempvar[3]/10+0x30);
showstr[1]=(tempvar[3]%10+0x30);
showstr[2]='\0';
tm12864_writestr(4,6,showstr,0);
if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[4]=0;
}
tempvar[4]=tempvar[4]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[4]/10+0x30);
showstr[1]=(tempvar[4]%10+0x30);
showstr[2]='\0';
tm12864_writestr(8,6,showstr,1);
break;
case 5://获取回路号5
showstr[0]=(tempvar[4]/10+0x30);
showstr[1]=(tempvar[4]%10+0x30);
showstr[2]='\0';
tm12864_writestr(8,6,showstr,0);
if((j<4)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[5]=0;
}
tempvar[5]=tempvar[5]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[5]/10+0x30);
showstr[1]=(tempvar[5]%10+0x30);
showstr[2]='\0';
tm12864_writestr(12,6,showstr,1);
break;
case 6://确认存储菜单
tm12864_writehz(4,5,bmp1,0);
if(tempkey==BUTTON_OK)
{
if(tempvar[0]!=0)
{
x25045_init();
//保存互锁回路
for(i=0;i<8;i++)
{
x25045_writeenable();
x25045_writebyte(tempvar[i+1],(0x01e0+(tempvar[0]-1)*9+i));
}
}
submenuitem=0;
showflag=0;
tempvar[0]=0x00;
j=0;
}
break;

}
tempkey=0x50;
break;;


case 0x1a://手动处理
tm12864_reset();
if(showflag==0)
{
tm12864_fillscreen(0x00);
showflag=1;

}
tm12864_writehz(4,0,sdyx,0);
tm12864_writehz(0,2,xzschl,0);
tm12864_writehz(14,2,hao,0);
if((j<2)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[0]=0;
}
tempvar[0]=tempvar[0]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[0]/10+0x30);
showstr[1]=(tempvar[0]%10+0x30);
showstr[2]='\0';
tm12864_writestr(12,2,showstr,1);
if((tempvar[0]!=0)&&(tempvar[0]<33))
{
switch(tempkey)
{
case BUTTON_START:
tm12864_writehz(6,6,qd,0);
i8155out=i8155out|((unsigned long)0x00000001<<(tempvar[0]-1));
j=2;
break;
case BUTTON_STOP:
tm12864_writehz(6,6,tz,0);
i8155out=i8155out&(~((unsigned long)0x00000001<<(tempvar[0]-1)));
j=2;
break;
case BUTTON_SET:
tm12864_writestr(6,6," ",0);
j=0;
tempvar[0]=0;
break;
}
}
break;
case 0x1b://隐蔽功能,尚未加入
tm12864_reset();
if(showflag==0)
{
tm12864_fillscreen(0x00);
showflag=1;

}
tm12864_writehz(0,0,ckgn,0);
tm12864_writehz(0,2,cksj,0);
tm12864_writehz(4,4,nian,0);
tm12864_writehz(8,4,yue,0);
tm12864_writehz(12,4,ri,0);
tm12864_writehz(0,6,mm,0);
//******************************************
switch(tempkey)
{
case BUTTON_SLAVE:
if(submenuitem<5)
{
submenuitem++;
}
else
{
submenuitem=0;
}
if(submenuitem==4)
{
tm12864_writestr(6,6," ",1);
}
j=0;
break;
case BUTTON_STOP:
menuitem=0x03;
submenuitem=0x01;
showflag=0;
tempvar[0]=0;
j=0;
break;
}
switch(submenuitem)
{
case 0://获取功能
if(tempvar[0]==1)
{
tm12864_writehz(10,0,kai,1);
}
else
{
tm12864_writehz(10,0,guan,1);
}
if(tempkey==BUTTON_SET)
{
if(tempvar[0]==0)
{
tempvar[0]=1;
}
else
{
tempvar[0]=0;
}
}
break;
case 1://获取年
if(tempvar[0]==1)
{
tm12864_writehz(10,0,kai,0);
}
else
{
tm12864_writehz(10,0,guan,0);
}
if((j<4)&&(tempkey<0x0a))
{
if(j==0)
{
tempvar[1]=0;
}
tempvar[1]=tempvar[1]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[1]/1000+0x30);
showstr[1]=((tempvar[1]%1000)/100+0x30);
showstr[2]=((tempvar[1]%100)/10+0x30);
showstr[3]=(tempvar[1]%10+0x30);
showstr[4]='\0';
tm12864_writestr(0,4,showstr,1);
break;
case 2://获取月
showstr[0]=(tempvar[1]/1000+0x30);
showstr[1]=((tempvar[1]%1000)/100+0x30);
showstr[2]=((tempvar[1]%100)/10+0x30);
showstr[3]=(tempvar[1]%10+0x30);
showstr[4]='\0';
tm12864_writestr(0,4,showstr,0);

if((j<2)&&(tempkey<0x0a))
{
tempvar[2]=tempvar[2]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[2]/0x0a+0x30);
showstr[1]=(tempvar[2]%0x0a+0x30);
showstr[2]='\0';
tm12864_writestr(6,4,showstr,1);
break;
case 3://获取日
showstr[0]=(tempvar[2]/0x0a+0x30);
showstr[1]=(tempvar[2]%0x0a+0x30);
showstr[2]='\0';
tm12864_writestr(6,4,showstr,0);

if((j<2)&&(tempkey<0x0a))
{
tempvar[3]=tempvar[3]*0x0a+tempkey;
j++;
}
showstr[0]=(tempvar[3]/0x0a+0x30);
showstr[1]=(tempvar[3]%0x0a+0x30);
showstr[2]='\0';
tm12864_writestr(10,4,showstr,1);
break;
case 4://获取密码
showstr[0]=(tempvar[3]/0x0a+0x30);
showstr[1]=(tempvar[3]%0x0a+0x30);
showstr[2]='\0';
tm12864_writestr(10,4,showstr,0);

if((j<6)&&(tempkey<0x0a))
{
tm12864_writestr(j+6,6,"*",1);
tempvar[j+4]=tempkey;
j++;
}
break;

原程序6 [huxiangming] [57次] 01-11-16 下午 10:43:28
case 5://确认存储菜单
tm12864_writehz(4,5,bmp1,0);
if(tempkey==BUTTON_OK)
{
//保存参数
x25045_init();
x25045_writeenable();
x25045_writebyte(tempvar[0],(0x1bb));
x25045_writeenable();
x25045_writeword(tempvar[1],(0x1b5));
x25045_writeenable();
x25045_writebyte(tempvar[2],(0x1b7));
x25045_writeenable();
x25045_writebyte(tempvar[3],(0x1b8));
x25045_init();
for(i=0;i<6;i++)
{
x25045_writeenable();
x25045_writebyte(tempvar[i+4],(0x01a9+i));
tempvar=0;
}
submenuitem=0;
showflag=0;
tempvar[0]=0;
j=0;
}
break;

}
//******************************************
break;
case 0x20:

// *******************************************************
//加入隐蔽菜单功能
tm12864_reset();
if(showflag==0)
{
tm12864_fillscreen(0x00);
showflag=1;

}
tm12864_writehz(4,2,sbgz,0);
if((j<6)&&(tempkey<0x0a))
{
tempvar[j]=tempkey;
j++;
showstr[0]=j+0x30;
showstr[1]='\0';
tm12864_writestr(15,7,showstr,0);
tempkey=0x50;
}

if(j==6)
{
for(j=0;j<6;j++)
{
#if DEBUG
tempvar[j]=x25045_readbyte(0x01a9+j);
#else
if(tempvar[j]!=x25045_readbyte(0x01a9+j))
{
j=0;
break;
}
#endif
}
if(tempkey==BUTTON_SET)
{
menuitem=0x1b;
j=0;
submenuitem=0;
showflag=0;
tempvar[0]=1;
}
}
// *******************************************************
break;
case 0xb1://菜单循环处理
menuitem=0x01;
showflag=0;
break;
default:
break;
}
tempkey=0x50;
//屏幕显示处理结束

//自动运行
if(menuitem<2)
{
//************************
//获取输入,确定运行模式(手动/自动)
main_temp=x25045_readbyte(0x00ff)-1;
if(main_temp<6)
{
tempkey=(~i8155_inport(I8155A,PC))>>main_temp;
}
else
{
tempkey=(~i8155_inport(I8155B,PC))>>(main_temp-6);
}
if((tempkey&0x01)==1)
{
if(x25045_readbyte(0x0100+main_temp*2+1)==0)
{
menuitem=0x1a;
showflag=0;
}
}
else
{

if(x25045_readbyte(0x0100+main_temp*2+1)==1)
{
menuitem=0x1a;
showflag=0;
}
}
//************************

if(rrtime_flag==0)//获取运行参数
{
for(i=0;i<outputnumber;i++)
{
runtime++;
}
rrtime_flag=1;
//获取输入

main_temp=~i8155_inport(I8155B,PC);
inputnumber=x25045_readbyte(INNUMBER);
if(main_temp!=0x00)
{
for(i=6;i<inputnumber;i++)
{
if(((main_temp>>(i-6))&0x01)==1)
{
tempkey=x25045_readbyte(0x100+i*2)-1;
if(tempkey<32)
{
runno1[tempkey]=1;
if(x25045_readbyte(0x100+i*2+1)==1)//start
{
runtime[tempkey]=0;
}
else
{
runtime[tempkey]=starttime[tempkey];
}
}
else if(tempkey<36)
{
linkrun[tempkey-32]=1;
}
}
}
}
if(inputnumber>6)
{
inputnumber=6;
}
main_temp=~i8155_inport(I8155A,PC);
if(main_temp!=0x00)
{
for(i=0;i<inputnumber;i++)
{
tempkey=x25045_readbyte(0x100+i*2)-1;
if(((main_temp>>i)&0x01)==1)
{
if(tempkey<32)
{
runno1[tempkey]=1;
if(x25045_readbyte(0x100+i*2+1)==1)
{
runtime[tempkey]=0;
}
else
{
runtime[tempkey]=starttime[tempkey];
}
}
else if(tempkey<36)
{
if(x25045_readbyte(0x100+i*2+1)==1)
{
linkrun[tempkey-32]=1;
}
else
{

linkrun[tempkey-32]=2;
}
}
}
else
{
if(tempkey>31)
{
linkrun[tempkey-32]=0;
}
}
}
}
//加入联动回路处理
for(i=0;i<4;i++)
{
//第 i 组联动回路处理
tempkey=x25045_readbyte(0x01bc+i*9);
if(linkrun==1)
{
if(linkrunno1!=1)
{//第1次循环,如果输入信号存在,则令所有联动回路处于起始状态;
if((runtime[tempkey]>=starttime[tempkey])||(runno1[tempkey]!=1))
{
for(tempkey=0;tempkey<8;tempkey++)
{
tempvar[6]=x25045_readbyte(0x01bc+i*9+tempkey);
if((tempvar[6]!=0)&&(tempvar<33))
{
runtime[tempvar[6]-1]=0;
runno1[tempvar[6]-1]=0;
}
}
}
linkrunno1=1;
}
else
{//第2次循环后,如果输入信号仍旧存在,且电机处于运行状态,则令电机运行时间
=0;
for(tempkey=0;tempkey<8;tempkey++)
{
tempvar[6]=x25045_readbyte(0x01bc+i*9+tempkey);
if((tempvar[6]!=0)&&(tempvar<33))
{
if(runno1[tempvar[6]-1]==1)
{
runtime[tempvar[6]-1]=0;
}
}
}
}
}
else if(linkrun==2)//停止
{//
if(linkrunno1!=2)
{//第1次循环,如果输入信号存在,则令所有联动回路处于起始停止状态;
if((runtime[tempkey]<starttime[tempkey])&&(runno1[tempkey]==1))
{
tempvar[7]=tempkey;
for(tempkey=0;tempkey<8;tempkey++)
{
tempvar[6]=x25045_readbyte(0x01bc+i*9+tempkey);
if((tempvar[6]!=0)&&(tempvar<33))
{
runtime[tempvar[6]-1]=starttime[tempvar[6]-1]-starttime[tempvar[7];
}
}
}
linkrunno1=2;
}
else
{//第2次循环后,如果输入信号仍旧存在,且电机处于运行状态,则令电机运行时间
=0;
for(tempkey=0;tempkey<8;tempkey++)
{
tempvar[6]=x25045_readbyte(0x01bc+i*9+tempkey);
if((tempvar[6]!=0)&&(tempvar<33)&&(runtime[tempvar[6]-1]>=starttime[tempvar
[6]-1]))
{
runno1[tempvar[6]-1]=0;
runtime[tempvar[6]-1]=0;
}
}
}
}
else if(linkrun==0)//如果无输入信号,则复位联动运行次数
{
linkrunno1=0;
}
}
//联动回路处理结束
}
else
{
//自动运行
for(i=0;i<outputnumber;i++)
{
if(runno1==0)//第一次运行
{
main_temp=(i*7)+4;
if(runtime>betweentime)
{
i8155out=i8155out&(~((unsigned long)0x00000001<<i));
runtime=0x00;
runno1=1;
}
}
else
{
if(runtime<starttime)
{
i8155out=i8155out|((unsigned long)0x00000001<<i);
}
else if(runtime>(starttime+stoptime))
{
i8155out=i8155out&(~((unsigned long)0x00000001<<i));
runtime=0x00;
}
else
{
i8155out=i8155out&(~((unsigned long)0x00000001<<i));
}
}
}
}
//互锁回路处理
for(i=0;i<6;i++)
{
tempkey=x25045_readbyte(0x01e0+i*5);
if((tempkey!=0)&&(tempkey<33))
{
if((runtime[tempkey]<starttime[tempkey])&&(runno1[tempkey]==1))
{
for(tempkey=0;tempkey<4;tempkey++)
{
tempvar[6]=x25045_readbyte(0x01e0+i*5+tempkey);
if((tempvar[6]!=0)&&(tempvar<33))
{
runtime[tempvar[6]=starttime[tempvar[6];
runno1[tempvar[6]=1;
}
}
}
}
}
//互锁回路处理结束
i=0;
}
else if(menuitem==0x1a)//手动处理
{
//************************
//获取输入,确定运行模式(手动/自动)
main_temp=x25045_readbyte(0x00ff)-1;
if(main_temp<6)
{
tempkey=(~i8155_inport(I8155A,PC))>>main_temp;
}
else
{
tempkey=(~i8155_inport(I8155B,PC))>>(main_temp-6);
}
if((tempkey&0x01)==1)
{
if(x25045_readbyte(0x0100+main_temp*2+1)==1)
{
menuitem=0x0;
showflag=0;
}
}
else
{

if(x25045_readbyte(0x0100+main_temp*2+1)==0)
{
menuitem=0;
showflag=0;
}
}
if(menuitem==0)
{
i8155out=(long)0;
}
//************************
}
else
{
i8155out=(long)0x00;
for(i=0;i<32;i++)
{
runtime=0x00;
}
}


tempkey=0x50;


i8155_init(I8155A,0x03);
i8155_init(I8155B,0x03);
//outportall();
i8155_outport(I8155A,PA,((unsigned char)i8155out));
i8155_outport(I8155A,PB,((unsigned char)(i8155out>>8)));
i8155_outport(I8155B,PA,((unsigned char)(i8155out>>16)));
i8155_outport(I8155B,PB,((unsigned char)(i8155out>>24)));
}
}


void i8155_init(unsigned int memaddress,unsigned char command)
{
/* 8155初始化 */
XBYTE[memaddress+0x100]=command; /*设置8155各口功能 */
}

//intel 8155 端口输出
//memaddress:8155基址;
//portnum:端口号(1:PA、2:PB、3:PC)
//portstatu:端口输出字
void i8155_outport(unsigned int memaddress,unsigned char portnum,unsigned char
portsdata)
{
XBYTE[(memaddress+0x100+portnum)]=portsdata;
}
//intel 8155 端口输入
//memaddress:8155基址;
//portnum:端口号(1:PA、2:PB、3:PC)
//返回值:端口状态
unsigned char i8155_inport(unsigned int memaddress,unsigned char portnum)
{
return(XBYTE[(memaddress+0x100+portnum)]);
}
//初始化
void init()
{
tm12864_reset();
tm12864_fillscreen(0x00);
x25045_writestatu(0x0C);
i8155_init(I8155A,0x03);//初始化8155Apa,pb输出,pc输入;
i8155_init(I8155B,0x03);//初始化8155B pa,pb输出,pc输入
}

void showinitscreen()
{
unsigned char initi;
//显示初始屏幕
tm12864_writestr(4,0,"HJD 95m",0);
//显示平方符号
for(initi=0;initi<16;initi++)
{
if(initi<
tm12864_writedata(88+initi,0,p2[initi]);
else
tm12864_writedata(88-8+initi,1,p2[initi]);
}
//显示平方符号结束
tm12864_writehz(0,2,gyjdccsb,0);

}

/*******************************************************************

初始化12887子程序

*******************************************************************/

void init_12887()
{
XBYTE[P12887MCA]=0x2F; //0 010 1111
//0 允许读写时标寄存器
//010 启动DS12887内部晶振工作,00X 晶振停止工作
//1111 中断周期时间设为500ms

ACC=XBYTE[P12887MCC]; //读寄存器C 清除中断请求标志IRQF
ACC=XBYTE[P12887MCD]; //读寄存器D 置VRT=1,内部资源可用
// XBYTE[P12887MCB]=0x06; //0 000 0 1 1 0 禁止中断
//P12887SEC_ALM= 0xff;//秒报警
XBYTE[P12887MCB]=0x16; //0 001 0 1 1 0
//0 启动芯片正常工作,为1时停止工作
//001 允许更新周期结束中断有效(UIE=1)
//0 不许方波输出
//1 时标以BIN码表示
//1 24小时制
//0 不进行夏令时转换
}


/*******************************************************************

读取12887时间子程序(年月日时分)

*******************************************************************/

void gettime_12887()
{
unsigned char uip;

do
{
uip=XBYTE[P12887MCA];
uip=uip>>7;
} while(uip); //判UIP位,直到UIP=0方可操作时标寄存器

tempvar[0]=XBYTE[P12887YEAR];
if(tempvar[0]>99)
{
tempvar[0]=2001;
}
else
{
tempvar[0]=tempvar[0]+2000;
}
tempvar[1]=XBYTE[P12887MONTH];
if(tempvar[1]>12) tempvar[1]=1;
tempvar[2]=XBYTE[P12887DAY];
if(tempvar[2]>31) tempvar[2]=1;
tempvar[3]=XBYTE[P12887HOUR];
if(tempvar[3]>23) tempvar[3]=0;
tempvar[4]=XBYTE[P12887MIN];
if(tempvar[4]>59) tempvar[4]=0;
tempvar[5]=XBYTE[P12887SEC];
if(tempvar[5]>59) tempvar[5]=0;
}


/*******************************************************************

设置12887时间子程序

*******************************************************************/

void settime_12887()
{
XBYTE[P12887MCB] =0x80; //SET=1,芯片停止工作,此时可编程时标寄存器
XBYTE[P12887YEAR] =(unsigned char)(tempvar[0]-2000);
XBYTE[P12887MONTH]=(unsigned char)tempvar[1];
XBYTE[P12887DAY] =(unsigned char)tempvar[2];
XBYTE[P12887HOUR] =(unsigned char)tempvar[3];
XBYTE[P12887MIN] =(unsigned char)tempvar[4];
XBYTE[P12887SEC] =(unsigned char)tempvar[5];
init_12887();
}

您可能还会关注的相关技术资料:

中国电子网
www.EC66.com
QQ:34740080 EMAIL:iloveaoe@163.com
最佳浏览:1024*768
Copyright (C) 2001-2010 EC66.COM All Rights Reserved
Aoe/帝国 制作维护
粤ICP备18061901号