📄 menu.c
字号:
case TM_KEYUP: //按向上键
switch(sel)
{
case 1:
sel = 2;
break;
case 2:
sel = 1;
break;
case 3: //小时数
if(IntFrequency[sel-3] < 23)
IntFrequency[sel-3]++;
else
IntFrequency[sel-3] = 0;
itoa(IntFrequency[sel-3],StrFrequency[sel-3],10); //转化为字符串
break;
case 4: //分钟数
if(IntFrequency[sel-3] < 59)
IntFrequency[sel-3]++;
else
IntFrequency[sel-3] = 0;
itoa(IntFrequency[sel-3],StrFrequency[sel-3],10); //转化为字符串
break;
default:
break;
}
MenuFlag = 0;
break;
case TM_KEYDOWN: //按向下键
switch(sel)
{
case 1:
sel = 2;
break;
case 2:
sel = 1;
break;
case 3: //小时数
if(IntFrequency[sel-3] > 0)
IntFrequency[sel-3]--;
else
IntFrequency[sel-3] = 23;
itoa(IntFrequency[sel-3],StrFrequency[sel-3],10); //转化为字符串
break;
case 4: //分钟数
if(IntFrequency[sel-3] > 0)
IntFrequency[sel-3]--;
else
IntFrequency[sel-3] = 59;
itoa(IntFrequency[sel-3],StrFrequency[sel-3],10); //转化为字符串
break;
default:
break;
}
MenuFlag = 0;
break;
case TM_KEYMEASURE: // 此时按测量键时,如果未进入通讯及测量操作,
//则开始测量,否则提示用户稍后进行
switch(TStatus)
{
//注意显示信息不能覆盖界面上的静态数据
case Idle: //空闲时进入测量界面
WinId = 1; //测量前界面
WinFlag = 0;
break;
case Measure: //正在启动测量
SetFont(2); //设置字体
DispString(7,7,(char *)"正在启动测量!",0);
break;
case communication: //正在传输数据
SetFont(2); //设置字体
DispString(7,7,(char *)"正在传输数据!",0);
break;
case Buff: //无效时错误
SetFont(2); //设置字体
DispString(7,7,(char *)"系统错误!",0);
break;
default:
break;
}
MenuFlag = 0;
break;
default:
break;
} //switch(pMsg->message)
}//while(MenuFlag)
}//while(WinFlag)
}
/****************************************************************************
* 函数名:SetDayNight
* 功能: 设置昼夜定义,今日和平时的定义
白天 平时 7:00 -- 22:00
今日 7:00 -- 22:00
返回
白天/返回 ---上下键选择,向右键进入子菜单
平时/今日 ---上下键选择,向右键进入,向左键返回上层菜单
7:00/12:00 ---上下键以30分钟变化,向右键进入下一个设定
任何时候按功能键--提示是否保存并退出
说明: 返回时WinId为3(主界面)
7:00 -- 22:00 则保存为: 420,1320
****************************************************************************/
void SetDayNight()
{
uint8 i,rRet,sel=1; //当前选择的菜单
uint8 WinFlag = 1; //懑足窗体切换条件时置为0
uint8 MenuFlag ;//满足菜单选择条件时,置为0
char StrValue[8][6]; //小时:分钟的字符串
uint16 IntValue[8]; //保存设置的分钟数
MSGtemp *pMsg; //声明消息
SetFont(2);
strcpy(StrValue[0],(char *)"7");
strcpy(StrValue[1],(char *)"0");
strcpy(StrValue[2],(char *)"22");
strcpy(StrValue[3],(char *)"0");
strcpy(StrValue[4],(char *)"7");
strcpy(StrValue[5],(char *)"0");
strcpy(StrValue[6],(char *)"22");
strcpy(StrValue[7],(char *)"0");
for(i=0;i<8;i++)
IntValue[i] = atoi(StrValue[i]);
//根据系统时间和所存的值初始化以上的值
while(WinFlag)
{
clr_scr();
//显示界面静态数据
DispPhoto(10,120,(char *)"昼夜定义",1);
DispString(9,6,(char *)"时",0);
DispString(11,6,(char *)"分",0);
DispString(12,6,(char *)"至",0);
DispString(15,6,(char *)"时",0);
DispString(17,6,(char *)"分",0);
DispString(9,10,(char *)"时",0);
DispString(11,10,(char *)"分",0);
DispString(12,10,(char *)"至",0);
DispString(15,10,(char *)"时",0);
DispString(17,10,(char *)"分",0);
DispString (12, 4, (char *)"平时", 0);
DispString (12, 8, (char *)"今日", 0);
//显示界面动态数据
DispPhoto (90,60, (char *)"白天", sel==1?1:0);
DispPhoto (90,200, (char *)"返回", sel==2?1:0);
DispChar (8, 6, StrValue[0], sel==3?1:0);
DispChar (10, 6, StrValue[1], sel==4?1:0);
DispChar (14, 6, StrValue[2], sel==5?1:0);
DispChar (16, 6, StrValue[3], sel==6?1:0);
DispChar (8, 10, StrValue[4], sel==7?1:0);
DispChar (10, 10, StrValue[5], sel==8?1:0);
DispChar (14, 10, StrValue[6], sel==9?1:0);
DispChar (16, 10, StrValue[7], sel==10?1:0);
DispPhoto (0, 0, (char *)"dd",0); //去掉
MenuFlag = 1;
clr_kb(); //清除键盘缓存消息
while(MenuFlag)
{
pMsg = GetMessagetemp(task1_tmq);
switch(pMsg->message)
{
case TM_KEYOK:
clr_kb(); //清除键盘缓存消息
if(sel != 2)
sel = DispMessage(100,120,(char *)"正在退出,是否保存数据?功能键是,其它键否",1);
;//保存设置的数据于分配的地址
WinId = 3;
MenuFlag = 0;
WinFlag = 0;
break;
case TM_KEYUP: //向上
if(sel == 1)
sel++;
else if(sel == 2)
sel--;
else if(0 == sel % 2) //分钟数
{
if(IntValue[sel-3] == 30)
{
if(IntValue[sel-4] < 23)
IntValue[sel-4] ++;
else
IntValue[sel-4] = 0;
IntValue[sel-3] = 0;
itoa(IntValue[sel-4],StrValue[sel-4],10); //转化为字符串
}
else
IntValue[sel-3] = 30;
itoa(IntValue[sel-3],StrValue[sel-3],10); //转化为字符串
}
else //时钟数
{
if(IntValue[sel-3] < 23)
IntValue[sel-3]++;
else
IntValue[sel-3] = 0;
itoa(IntValue[sel-3],StrValue[sel-3],10); //转化为字符串
}
MenuFlag = 0;
break;
case TM_KEYDOWN: //向下
if(sel == 1)
sel++;
else if(sel == 2)
sel--;
else if(0 == sel % 2) //分钟数
{
if(IntValue[sel-3] == 0)
{
if(IntValue[sel-4] > 0)
IntValue[sel-4] --;
else
IntValue[sel-4] = 23;
IntValue[sel-3] = 30;
itoa(IntValue[sel-4],StrValue[sel-4],10); //转化为字符串
}
else
IntValue[sel-3] = 0;
itoa(IntValue[sel-3],StrValue[sel-3],10); //转化为字符串
}
else //时钟数
{
if(IntValue[sel-3] > 0)
IntValue[sel-3]--;
else
IntValue[sel-3] = 23;
itoa(IntValue[sel-3],StrValue[sel-3],10); //转化为字符串
}
MenuFlag = 0;
break;
case TM_KEYRIGHT: //按向左键
if(sel == 2) //退出
{
WinId = 3;
WinFlag = 0;
}
else if(sel == 1)
sel = 3;
else if(sel < 10)
sel++;
else
sel = 2;
MenuFlag = 0;
break;
case TM_KEYLEFT: //按向右键
if((sel < 10) && (sel > 2))
sel--;
MenuFlag = 0;
break;
case TM_KEYMEASURE: // 此时按测量键时,如果未进入通讯及测量操作,
//则开始测量,否则提示用户稍后进行
switch(TStatus)
{
//注意显示信息不能覆盖界面上的静态数据
case Idle: //空闲时进入测量界面
WinId = 1; //测量前界面
WinFlag = 0;
break;
case Measure: //正在启动测量
SetFont(2); //设置字体
DispString(7,7,(char *)"正在启动测量!",0);
break;
case communication: //正在传输数据
SetFont(2); //设置字体
DispString(7,7,(char *)"正在传输数据!",0);
break;
case Buff: //无效时错误
SetFont(2); //设置字体
DispString(7,7,(char *)"系统错误!",0);
break;
default:
break;
}
MenuFlag = 0;
break;
default:
break;
} //switch(pMsg->message)
}//while(MenuFlag)
}//while(WinFlag)
}
/****************************************************************************
* 函数名:SetTime
* 功能: 设置时间
白天
返回
2006年11月21日
21:45
---上下键选择,向右键进入下一个设置
---上下键对数据进行修正,上加下减
任何时候按功能键--提示是否保存并退出
说明: 返回时WinId为3(主界面)
日期: 2000-2999
月份; 1-12
日期: 1-31
小时: 0-23
分钟: 0-59
****************************************************************************/
void SetTime()
{
uint8 i,sel=1; //当前选择的菜单
uint8 WinFlag = 1; //懑足窗体切换条件时置为0
uint8 MenuFlag ;//满足菜单选择条件时,置为0
int8 date[20];
int8 StrValue[5][5]; //保存年,月,日,时段小时,时段分钟的字符串
uint16 IntValue[5]; //保存年,月,日,时段小时,时段分钟的数值
MSGtemp *pMsg; //声明消息
SetFont(2);
PC_GetDateTime(date); //"YYYY-MM-DD HH:MM:SS"
strcpy(StrValue[0],SubString(date,0,4));
strcpy(StrValue[1],SubString(date,5,2));
strcpy(StrValue[2],SubString(date,8,2));
strcpy(StrValue[3],SubString(date,12,2));
strcpy(StrValue[4],SubString(date,15,2));
for(i=0;i<5;i++)
IntValue[i] = atoi(StrValue[i]);
//根据系统时间初始化以上的值
while(WinFlag)
{
clr_scr();
//显示界面静态数据
DispPhoto (10, 120, (char *)"时间设定",1);
DispString (10, 7, (char *)"年",0);
DispString (14, 7, (char *)"月",0);
DispString (18, 7, (char *)"日",0);
DispString (14, 8, (char *)"时",0);
DispString (18, 8, (char *)"分",0);
//显示界面动态数据
DispPhoto (90,60, (char *)"更改", sel==1?1:0);
DispPhoto (90,200, (char *)"返回", sel==2?1:0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -