📄 menu01.c
字号:
eepwrite(c/256,c%256,adtemp[0][a].adig);
temp[a].adig=adtemp[0][a].adig;
check();
c++;
c=c%0x7fef;
}
*/
}
address=0;
ms50=0;
}
}
}
void serial() interrupt 4 //串行中断 接收数据
{
//读回来的数据还没有保存到eeprom
// uchar ud=0;
if(RI==1)
{
if(qi==0)
{
adtemp[0][address].adh=SBUF; //这里应该与上一个数
se=0;
}
else//else01
{
if(qi==1)
{
adtemp[0][address].adl=SBUF;
se=0;
}
else//02
{
if(qi==2)
{
adtemp[0][address].adig=SBUF;
se=0;
}
else//03
{
if(qi==3)
{
qi=SBUF;
if(adtemp[0][address].adh+adtemp[0][address].adl+adtemp[0][address].adig==qi)
{
se=1;
ms6=1;
qi=0;
}
else //05
{
err++;
qi=0;
} //05
}// if 3
RI=0;
}//03
} //02
}//else01
qi++;
qi=qi%4;
} // if RI==1
} //
/* switch(qi)
{
case 0:
adtemp[0][address].adh=SBUF; //这里应该与上一个数
qi++;
se=0;
break;
case 1:
adtemp[0][address].adl=SBUF;
se=0;
qi++;
break;
case 2:
adtemp[0][address].adig=SBUF;
se=0;
qi++;
break;
case 3:
ud=SBUF;
if(adtemp[0][address].adh+adtemp[0][address].adl+adtemp[0][address].adig==ud)
{
se=1;
ms6=1;
qi=0;
}
else
err++;
qi=0;
break;
}
*/
void goback(uchar addr,uchar lcd[16])
{ uchar i;
write(addr,0);
for(i=0;i<16;i++)
write(lcd[i],1);
// for(n=0;n<16;n++)
// write(lcd[n],1);
}
void disfill(uchar adr,uchar lcd_dis[8],uchar u0,uchar u1,uchar u2,uchar u3,uchar u4,uchar u5,uchar u6,uchar u7)
{
uchar ki;
write(adr,0);
for(ki=0;ki<8;ki++)
write(lcd_dis[ki],1);
write(u0,1);
write(u1,1);
write(u2,1);
write(u3,1);
write(u4,1);
write(u5,1);
write(u6,1);
write(u7,1);
}
void his_read(void)
{ uchar i,j;
ET0=0;
if (point2>=0x78)
n=(point2-0x78);
else
n=0x7fef-(0x78-point2);
for(i=0;i<=9;i++)
for(j=0;j<4;j++)
{
addate[i][j].adh=eepread(n/256,n%256);
n++;
n=n%0x7fef;
addate[i][j].adl=eepread(n/256,n%256);
n++;
n=n%0x7fef;
addate[i][j].adig=eepread(n/256,n%256);
n++ ;
n=n%0x7fef;
}
ET0=1;
}
void main(void)
{ uchar i,led;
//uint n;
//***********************************************************************************//
{ //一般的初始化
SP=0xdd;
con=0; // 开液晶屏
cs=1; // iic eeprom 有效
delay6ms(50);
disinit();
} //液晶显示初始化
/*
strcpy(dis,"系统初始化中....");
write(0x90,0);
for(i=0;i<16;i++)
write(dis[i],1);
*/ // 一般的初始化结束
//delay6ms(200);
// eepwrite(0x00,0x00,0x56);
// check();
// n=eepread(0x00,0x00);
point2=eepread(0x7f,0xff);
point2<<=8;
point2=point2|eepread(0x7f,0xfe);
//point1=(point2-0x78)%0x7fef;
if (point2>=0x78)
n=(point2-0x78);
else
n=0x7fef-(0x78-point2);
his_read();
maxinit();//总线485通信初始化
state=0;
while(1)
{ //ms2=1;
//switch(state)
{//0 主界面
if(state==0)
{
goback(0x80," 8: 激活状态 ");//80 qing pin 空行
goback(0x90," 9: 睡眠模式 ");
goback(0x88,"10: 实时监控 ");
goback(0x98,"11: 历史浏览 ");
led=key();
if(led==10)
{
state=1; // jin ru 实时监控界面
}
else //else2
{
if(led==11)
{
state=2;//进入选择历史点数据界面
}
else
if(led==9)
{
con=1;
}
else
if(led==8)
{
con=0;
}
} //else 2
} //else state
if(state==1) //实时监控里面的选择界面
{
goback(0x80," ");//80 qing pin 空行
goback(0x90,"9: 轮流显示 ");
goback(0x88,"10: 可选显示 ");
goback(0x98,"11: 返回上级 ");
led=key();
if(led==9)
{
i=0;
state=3; //实时监控里面的轮流显示界面
}
else
{ //else1
if(led==10)
{
mulb=0;
state=4;//实时监控里面的固定显示界面
}
else //else2
{
if(led==11)
{
state=0; //返回上级
}
} //else2
} //else1
} //if state
if(state==2) //选择那一点的历史数据界面
{
goback(0x80,"请选择下面历史点");//80 qing pin 空行
goback(0x90,"0 1 2 3 4 ");
goback(0x88,"5 6 7 8 9 ");
goback(0x98,"11: 返回上级 ");
led=key();
if(led==0xff||led==10) //返回
{
;//led=0xff;
}
else
if(led==11) //返回上级
{
state=0;
}
else
{ //把选择的数带过去
mulk=led;
state=5;// 进入另一界面来选择固定或者轮流显示
}
} // if state==2
if(state==3)
//实时监控轮流显示
{
if(ms2==1)
{
ms2=0;
disfill(0x80,lcd15,0x30+i,0x20,0x20,0x20,0x20,0x20,0x20,0x20);
disfill(0x90,lcd16,adtemp[0][i].adh/10+0x30,'.',adtemp[0][i].adh%10+0x30,adtemp[0][i].adl/10+0x30,adtemp[0][i].adl%10+0x30,'(','V',')');
disfill(0x88,lcd17,0x30+adtemp[0][i].adig,0x20,0x20,0x20,0x20,0x20,0x20,0x20);
goback(0x98,"11: 返回上级 ");
i++;
i=i%4;
} // ms2
led=key();
if(led==11)
{ state=1;
}
} // if state==3
if(state==4)
{ if(ms2==1)
{
ms2=0;
disfill(0x80,lcd15,0x30+mulb,0x20,0x20,0x20,0x20,0x20,0x20,0x20);
disfill(0x90,lcd16,adtemp[0][mulb].adh/10+0x30,'.',adtemp[0][mulb].adh%10+0x30,adtemp[0][mulb].adl/10+0x30,adtemp[0][mulb].adl%10+0x30,'(','V',')');
disfill(0x88,lcd17,0x30+adtemp[0][mulb].adig,0x20,0x20,0x20,0x20,0x20,0x20,0x20);
goback(0x98,"号: 0~3 返回:11 ");
} // ms2
led=key();
if(led==11)
{ state=1;
}
else
if(led==0||led==1||led==2||led==3)
{
mulb=led;
}
}
if(state==5)
{
goback(0x80,"8:更新历史数据 ");//80 qing pin 空行
goback(0x90,"9: 轮流显示 ");
goback(0x88,"10: 可选显示 ");
goback(0x98,"11: 返回上级 ");
led=key();
if(led==8)
{
his_read();
//**************************************** 如果太大了可以删掉一下的这段 以便减小程序存储器的空间
for(i=0;i<3;i++)
{
goback(0x80,"恭喜^_^ 成功更新");
delay6ms(250);
delay6ms(250);
delay6ms(250);
goback(0x80," ");
delay6ms(250);
delay6ms(250);
delay6ms(250);
}
goback(0x80,"8:更新历史数据 ");
///*************************************到这里结束 和上面对应***************************************
}
else
if(led==9)
{
i=0;
state=6; //历史数据里面的轮流显示界面
}
else
if(led==10)
{
mulb=0;
state=7;//历史数据里面的固定显示界面
}
else
if(led==11)
{
state=2;
}
}
if(state==6) //lun liu xian shi
{
if(ms2==1)
{
ms2=0;
disfill(0x80,lcd15,0x30+i,0x20,0xc0,0xfa,0xca,0xb7,':',0x30+mulk);
disfill(0x90,lcd16,addate[mulk][i].adh/10+0x30,'.',addate[mulk][i].adh%10+0x30,addate[mulk][i].adl/10+0x30,addate[mulk][i].adl%10+0x30,'(','V',')');
disfill(0x88,lcd17,0x30+addate[mulk][i].adig,0x20,0x20,0x20,0x20,0x20,0x20,0x20);
goback(0x98,"11: 返回上级 ");
i++;
i=i%4;
}
led=key();
if(led==11)
{ state=5;
}
}
if(state==7)
if(ms2==1)
{
ms2=0;
disfill(0x80,lcd15,0x30+mulb,0x20,0xc0,0xfa,0xca,0xb7,':',0x30+mulk);
disfill(0x90,lcd16,addate[mulk][mulb].adh/10+0x30,'.',addate[mulk][mulb].adh%10+0x30,addate[mulk][mulb].adl/10+0x30,addate[mulk][mulb].adl%10+0x30,'(','V',')');
disfill(0x88,lcd17,0x30+addate[mulk][mulb].adig,0x20,0x20,0x20,0x20,0x20,0x20,0x20);
goback(0x98,"号: 0~3 返回:11 ");
}
led=key();
if(led==11)
{ state=5;
}
else
if(led==0||led==1||led==2||led==3)
{
mulb=led;
}
} //switch
} // while
}//main
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -