📄 menu.c
字号:
uchar code OneTab[][5]={
{8, 9, 7, 23,0},//时间日期
{18,19,14,15,0},//温度检测
{26,27,15,28,0},//信号测量
{10,11,12,13,0},//数据采集
{10,11,16,17,0}//数据处理
};
uchar code CHXTab[][5]={
{33,34, 1, 42,0},//通道1
{33,34,2,42,0},//通道2
{33,34,3,42,0},//通道3
{33,34,4,42,0},//通道4
{33,34,5,42,0},//通道5
{33,34,6, 42,0},//通道6
{33,34,53,42,0},//通道7
{33,34,54,42,0}//通道八
};
uchar code WTTab[]={20,21, 8, 9,0};//查看时间
uchar code ADTab[]={24,25, 7,23,0};//修改日期
uchar code ATTab[]={24,25, 8, 9,0};//修改时间
uchar code TCH1Tab[]={49,50,18,19,0};//环境温度
uchar code TCH2Tab[]={51,15,18,19,0};//被测温度
//菜单对应的各个选项处理
void WaitStart(void)
{
ReadTime();//读取时间
TempDetect();//读取温度
LCD_set_RC(1,2);
LCD_putc(39,0);//显示"星"
LCD_putc(23,0);//显示"期"
LCD_putc(TimeBuf[5],0);
LCD_set_XY(53,0);
printf("%2d:%02d",(uint)TimeBuf[2],(uint)TimeBuf[1]);//显示时分
LCD_set_XY(11,3);
printf("%4d-%2d-%2d",(uint)(TimeBuf[6]+2000),(uint)TimeBuf[4],(uint)TimeBuf[3]);//显示日期
LCD_set_XY(0,0);
printf("%2d.%dC ",(uint)TempInt,(uint)TempDec);//显示温度
}
uchar *UpNext(uchar (*Tab)[5],uchar size,uchar sel)
{
uchar(*ptr)[];
if(sel==255)
ptr=Tab+size-1;
else if(sel==254)
ptr=Tab+size-2;
else
{ if(sel<size)
ptr=Tab+sel;
else
ptr=Tab+sel-size;
}
return ptr;
}
void FuncBar(void)
{ uchar idata i;
i=KeyFuncIndex-1;
switch(where)
{
case 0:
GUI_DispStringAt(UpNext(OneTab,5,i ),0,0,6,0,1);
GUI_DispStringAt(UpNext(OneTab,5,i+1),1,0,6,0,0);
GUI_DispStringAt(UpNext(OneTab,5,i+2),2,0,6,0,0);
break;
case 1:
GUI_DispStringAt(UpNext(OneTab,5,i-1 ),0,0,6,0,0);
GUI_DispStringAt(UpNext(OneTab,5,i ),1,0,6,0,1);
GUI_DispStringAt(UpNext(OneTab,5,i+1 ),2,0,6,0,0);
break;
case 2:
GUI_DispStringAt(UpNext(OneTab,5,i-2 ),0,0,6,0,0);
GUI_DispStringAt(UpNext(OneTab,5,i-1),1,0,6,0,0);
GUI_DispStringAt(UpNext(OneTab,5,i ),2,0,6,0,1);
break;
}
GUI_ScrollBar(5,i);
}
//-----------------------------------------------------
void WatchTime (void)
{ where=0;
GUI_DispStringAt(WTTab,0,0,6,0,1);
GUI_DispStringAt(ATTab,1,0,6,0,0);
GUI_DispStringAt(ADTab,2,0,6,0,0);
GUI_ScrollBar(3,where);
}
void TimeAmend(void)
{ where=1;
GUI_DispStringAt(WTTab,0,0,6,0,0);
GUI_DispStringAt(ATTab,1,0,6,0,1);
GUI_DispStringAt(ADTab,2,0,6,0,0);
GUI_ScrollBar(3,where);
}
void DateAmend(void)
{ where=2;
GUI_DispStringAt(WTTab,0,0,6,0,0);
GUI_DispStringAt(ATTab,1,0,6,0,0);
GUI_DispStringAt(ADTab,2,0,6,0,1);
GUI_ScrollBar(3,where);
}
//---------------------------------------------------
void TempCh1(void)
{ where=0;
GUI_DispStringAt(TCH1Tab,0,0,6,0,1);
GUI_DispStringAt(TCH2Tab,1,0,6,0,0);
GUI_ScrollBar(2,0);
}
void TempCh2(void)
{ where=1;
GUI_DispStringAt(TCH1Tab,0,0,6,0,0);
GUI_DispStringAt(TCH2Tab,1,0,6,0,1);
GUI_ScrollBar(2,1);
}
//---------------------------------------------------
void SignalCh(void)
{ uchar idata i;
i=KeyFuncIndex-11;
switch(where)
{
case 0:
GUI_DispStringAt(UpNext(CHXTab,8,i ),0,0,6,0,1);
GUI_DispStringAt(UpNext(CHXTab,8,i+1),1,0,6,0,0);
GUI_DispStringAt(UpNext(CHXTab,8,i+2),2,0,6,0,0);
break;
case 1:
GUI_DispStringAt(UpNext(CHXTab,8,i-1 ),0,0,6,0,0);
GUI_DispStringAt(UpNext(CHXTab,8,i ),1,0,6,0,1);
GUI_DispStringAt(UpNext(CHXTab,8,i+1 ),2,0,6,0,0);
break;
case 2:
GUI_DispStringAt(UpNext(CHXTab,8,i-2 ),0,0,6,0,0);
GUI_DispStringAt(UpNext(CHXTab,8,i-1),1,0,6,0,0);
GUI_DispStringAt(UpNext(CHXTab,8,i ),2,0,6,0,1);
break;
}
GUI_ScrollBar(8,i);
}
//---------------------------------------------------
void KeyIndicate(uchar index)
{
if(index==0)
{ LCD_set_RC(3,0);
LCD_putc(40,0);LCD_putc(41,0);//显示 -功能
LCD_set_RC(3,5);
LCD_putc(31,0);LCD_putc(32,0);//显示 -资料
}
if(index>=1&index<=5)
{ LCD_set_RC(3,0);
LCD_putc(43,0);LCD_putc(44,0);//显示 -选择
LCD_set_RC(3,5);
LCD_putc(45,0);LCD_putc(46,0);//显示 -返回
}
if(index>=6&index<=8)
{ LCD_set_RC(3,0);
LCD_putc(47,0);LCD_putc(48,0);//显示 -操作
LCD_set_RC(3,5);
LCD_putc(45,0);LCD_putc(46,0);//显示 -返回
}
if(index>=9&index<=18)
{ LCD_set_RC(3,0);
LCD_putc(20,0);LCD_putc(21,0);//显示 -查看
LCD_set_RC(3,5);
LCD_putc(45,0);LCD_putc(46,0);//显示 -返回
}
}
extern bit reflash;
void MenuIn(void)
{
SaveIndex[LevelCnt]=KeyTab[KeyFuncIndex].KeyStateIndex;//保存菜单的索引号,即将进入下一层
KeyFuncIndex=MenuTab[SaveIndex[LevelCnt]];//查表,查找对应下一层菜单的索引号。
SaveItemPlace[LevelCnt]=where;//保存当前菜单的位置。
where=0;
LevelCnt++;
reflash=1;
}
extern void USBcontrol(void);
extern bit flash,reflash;
void MenuOut(void)
{
if(LevelCnt)
{ LevelCnt--;
where=SaveItemPlace[LevelCnt];
KeyFuncIndex=SaveIndex[LevelCnt];
reflash=1;
}
else
{
TR0=0;
USBcontrol();
reflash=1;
flash=1;
where=0;
}
}
//----------------------------------------功能退出后恢复环境--------------------------------------------
void Func_Out(void)
{
LevelCnt--;
KeyFuncIndex=SaveIndex[LevelCnt];
where=SaveItemPlace[LevelCnt];
reflash=1;
flash=1;
delay_1ms();
}
///////////////////////////////////有关功能操作/////////////////////////////////////////////////////////////
//-------------------------------查看时间----------------------------------------------------------------
void Time_Watch(void)
{
//LCD_clr();
LCD_set_RC(3,5);
LCD_putc(45,0);LCD_putc(46,0);//显示 -返回
while(1)
{
ReadTime();//读取时间
LCD_set_RC(1,2);
LCD_putc(39,0);//显示"星"
LCD_putc(23,0);//显示"期"
LCD_putc(TimeBuf[5],0);
LCD_set_XY(12,3);
printf("%2d:%02d:%02d",(uint)TimeBuf[2],(uint)TimeBuf[1],(uint)TimeBuf[0]);//显示时分
LCD_set_XY(0,0);
printf("%4d-%2d-%2d",(uint)(TimeBuf[6]+2000),(uint)TimeBuf[4],(uint)TimeBuf[3]);//显示日期
if(key_esc)
{
key_esc_elim();
Func_Out();
break;
}
}
}
//----------------------------------------修改时间-----------------------------------------------------
void Time_AmendReve(uchar i)
{
switch(i)
{
case 0:
LCD_set_XY(48,3);
printf_reverse=1;
printf("%2d",(uint)TimeBuf[0]);
printf_reverse=0;
break;
case 1:
LCD_set_XY(30,3);
printf_reverse=1;
printf("%2d",(uint)TimeBuf[1]);
printf_reverse=0;
break;
case 2:
LCD_set_XY(12,3);
printf_reverse=1;
printf("%2d",(uint)TimeBuf[2]);
printf_reverse=0;
break;
case 3:
LCD_set_RC(1,4);
LCD_putc(TimeBuf[5],1);
break;
case 4:
LCD_set_XY(48,0);
printf_reverse=1;
printf("%2d",(uint)TimeBuf[3]);
printf_reverse=0;
break;
case 5:
LCD_set_XY(30,0);
printf_reverse=1;
printf("%2d",(uint)TimeBuf[4]);
printf_reverse=0;
break;
case 6:
LCD_set_XY(0,0);
printf_reverse=1;
printf("%4d",(uint)(TimeBuf[6]+2000));
printf_reverse=0;
break;
}
}
void Time_AmendReco(uchar i)
{
switch(i)
{
case 0:
LCD_set_XY(48,3);
printf_reverse=0;
printf("%02d",(uint)TimeBuf[0]);
break;
case 1:
LCD_set_XY(30,3);
printf_reverse=0;
printf("%02d",(uint)TimeBuf[1]);
break;
case 2:
LCD_set_XY(12,3);
printf_reverse=0;
printf("%2d",(uint)TimeBuf[2]);
break;
case 3:
LCD_set_RC(1,4);
LCD_putc(TimeBuf[5],0);
break;
case 4:
LCD_set_XY(48,0);
printf_reverse=0;
printf("%2d",(uint)TimeBuf[3]);
break;
case 5:
LCD_set_XY(30,0);
printf_reverse=0;
printf("%2d",(uint)TimeBuf[4]);
break;
case 6:
LCD_set_XY(0,0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -