📄 menu.c
字号:
uint8 i,ret,sel = 1; //当前选择的菜单
int8 date[20];
uint8 WinFlag = 1; //懑足窗体切换条件时置为0
uint8 MenuFlag ;//满足菜单选择条件时,置为0
int8 StrValue[7][5]; //保存年,月,日,时段小时,时段分钟的字符串
uint16 IntValue[8]; //保存年,月,日,时段小时,时段分钟,用户状态的数值
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));
strcpy(StrValue[5],(char *)"0");
strcpy(StrValue[6],(char *)"0");
for(i=0;i<7;i++)
IntValue[i] = atoi(StrValue[i]);
//根据系统时间初始化以上的值
while(WinFlag)
{
clr_scr();
//显示界面静态数据
DispPhoto( 16,20,(char *)"状态设定",1);
//line(10,80,160,130);
DispString (1, 4, (char *)"起始时间",0);
DispString (1, 8, (char *)"时段",0);
DispString (4, 5, (char *)"年",0);
DispString (8, 5, (char *)"月",0);
DispString (12, 5, (char *)"日",0);
DispString (8, 6, (char *)"时",0);
DispString (12, 6, (char *)"分",0);
DispString (8, 8, (char *)"时",0);
DispString (12, 8, (char *)"分",0);
DispString (15, 3, (char *)"所处状态",0);
//显示界面动态数据
DispChar (1, 5, StrValue[0], sel==1?1:0);
DispChar (6, 5, StrValue[1], sel==2?1:0);
DispChar (10, 5, StrValue[2], sel==3?1:0);
DispChar (6, 6, StrValue[3], sel==4?1:0);
DispChar (10, 6, StrValue[4], sel==5?1:0);
DispChar (6, 8, StrValue[5], sel==6?1:0);
DispChar (10, 8, StrValue[6], sel==7?1:0);
DispPhoto (230, 80,(char *)"午休", sel==8?1:0);
DispPhoto (230 ,110,(char *)"日常工作", sel==9?1:0);
DispPhoto (230, 140,(char *)"剧烈运动", sel==10?1:0);
DispPhoto (230, 170,(char *)"情绪激动", sel==11?1:0);
DispPhoto (230, 200,(char *)"返回", sel==12?1:0);
DispPhoto (0, 0, (char *)"dd",0); //去掉
MenuFlag = 1;
while(MenuFlag)
{
pMsg = GetMessagetemp(task1_tmq);
switch(pMsg->message)
{
case TM_KEYOK:
clr_kb(); //清除键盘缓存消息
if(sel != 12)
ret = DispMessage(100,120,(char *)"正在退出,是否保存消息?功能键是,其它键否",1);
;//保存设置的数据于分配的地址
WinId = 6;
MenuFlag = 0;
WinFlag = 0;
break;
case TM_KEYUP: //向上 数值累加
switch(sel)
{
case 1: //年份
if(IntValue[sel-1] < 2999)
IntValue[sel-1]++;
else
IntValue[sel-1] = 2005;
itoa(IntValue[sel-1],StrValue[sel-1],10); //转化为字符串
break;
case 2: //月份
if(IntValue[sel-1] < 12)
IntValue[sel-1]++;
else
IntValue[sel-1] = 1;
itoa(IntValue[sel-1],StrValue[sel-1],10); //转化为字符串
break;
case 3: //日子
if(IntValue[sel-1] < 31)
IntValue[sel-1]++;
else
IntValue[sel-1] = 1;
itoa(IntValue[sel-1],StrValue[sel-1],10); //转化为字符串
break;
case 4: //小时数
if(IntValue[sel-1] < 23)
IntValue[sel-1]++;
else
IntValue[sel-1] = 0;
itoa(IntValue[sel-1],StrValue[sel-1],10); //转化为字符串
break;
case 5: //分钟数
if(IntValue[sel-1] < 59)
IntValue[sel-1]++;
else
IntValue[sel-1] = 0;
itoa(IntValue[sel-1],StrValue[sel-1],10); //转化为字符串
case 6: //小时数
if(IntValue[sel-1] < 23)
IntValue[sel-1]++;
else
IntValue[sel-1] = 0;
itoa(IntValue[sel-1],StrValue[sel-1],10); //转化为字符串
break;
case 7: //分钟数
if(IntValue[sel-1] == 30)
{
if(IntValue[sel-2] < 23)
IntValue[sel-2] ++;
else
IntValue[sel-2] = 0;
IntValue[sel-1] = 0;
itoa(IntValue[sel-2],StrValue[sel-2],10); //转化为字符串
}
else
IntValue[sel-1] = 30;
itoa(IntValue[sel-1],StrValue[sel-1],10); //转化为字符串
break;
default:
break;
}
if(sel > 7 && sel <12) //选择子菜单6,7,8,9
{
if(sel == 8)
sel = 11;
else
sel--;
}
MenuFlag = 0;
break;
case TM_KEYDOWN: //向下 数值减少
switch(sel)
{
case 1: //年份
if(IntValue[sel-1] > 2000)
IntValue[sel-1]--;
else
IntValue[sel-1] = 2999;
itoa(IntValue[sel-1],StrValue[sel-1],10); //转化为字符串
break;
case 2: //月份
if(IntValue[sel-1] > 1)
IntValue[sel-1]--;
else
IntValue[sel-1] = 12;
itoa(IntValue[sel-1],StrValue[sel-1],10); //转化为字符串
break;
case 3: //日子
if(IntValue[sel-1] > 1)
IntValue[sel-1]--;
else
IntValue[sel-1] = 31;
itoa(IntValue[sel-1],StrValue[sel-1],10); //转化为字符串
break;
case 4: //小时数
if(IntValue[sel-1] > 0)
IntValue[sel-1]--;
else
IntValue[sel-1] = 23;
itoa(IntValue[sel-1],StrValue[sel-1],10); //转化为字符串
break;
case 5: //分钟数
if(IntValue[sel-1] > 0)
IntValue[sel-1]--;
else
IntValue[sel-1] = 59;
itoa(IntValue[sel-1],StrValue[sel-1],10); //转化为字符串
break;
case 6: //小时数
if(IntValue[sel-1] > 0)
IntValue[sel-1]--;
else
IntValue[sel-1] = 23;
itoa(IntValue[sel-1],StrValue[sel-1],10); //转化为字符串
break;
case 7: //分钟数
if(IntValue[sel-1] == 30)
{
IntValue[sel-1] = 0;
}
else
{
IntValue[sel-1] = 30;
if(IntValue[sel-2] > 1)
IntValue[sel-2]--;
else
IntValue[sel-2] = 23;
itoa(IntValue[sel-2],StrValue[sel-2],10); //转化为字符串
}
itoa(IntValue[sel-1],StrValue[sel-1],10); //转化为字符串
break;
default:
break;
}
if(sel > 7 && sel <12) //选择子菜单6,7,8,9
{
if(sel == 11)
sel = 8;
else
sel++;
}
MenuFlag = 0;
break;
case TM_KEYRIGHT: //按向左键
if(sel ==12) //退出
{
WinId = 6;
WinFlag = 0;
} //菜单循环
else if(sel > 7 && sel < 12) //6,7,8,9 项只选一个即可
sel = 12;
else
sel++;
MenuFlag = 0;
break;
case TM_KEYLEFT: //按向右键
if(sel == 1)
sel = 12; //菜单循环
else if(sel > 7 && sel<12) //6,7,8,9 项只选一个即可
sel = 7;
else
sel--;
MenuFlag = 0;
break;
case TM_KEYMEASURE: // 此时按测量键时,如果未进入通讯及测量操作,
//则开始测量,否则提示用户稍后进行
switch(TStatus)
{
//注意显示信息不能覆盖界面上的静态数据
case Idle: //空闲时进入测量界面
WinId = 1; //测量前界面
WinFlag = 0;
break;
case Measure: //正在启动测量
SetFont(2); //设置字体
DispMessage(7,7,(char *)"正在启动测量!",0);
break;
case communication: //正在传输数据
SetFont(2); //设置字体
DispMessage(7,7,(char *)"正在传输数据!",0);
break;
case Buff: //无效时错误
SetFont(2); //设置字体
DispMessage(7,7,(char *)"系统错误!",0);
break;
default:
break;
}
MenuFlag = 0;
break;
default:
break;
} //switch(pMsg->message)
}//while(MenuFlag)
}//while(WinFlag)
}
/****************************************************************************
* 函数名:SetFrequency
* 功能: 设置测量频率(默认半小时一次)
上下键数据增加或减少(每次变化1分种),功能键确定并保存,右键表示设置下一个数据
向左键表示返回,不保存
说明: 返回时WinId为6
****************************************************************************/
void SetFrequency()
{
uint8 i,sel=1; //当前选择的菜单
uint8 WinFlag = 1; //懑足窗体切换条件时置为0
uint8 MenuFlag ;//满足菜单选择条件时,置为0
uint8 IntFrequency[2]; //频率 时数/分数
char StrFrequency[2][5]; //字符串 时数/分数
MSGtemp *pMsg; //声明消息
SetFont(2);
;//获取保存的频率数据于变量中
strcpy(StrFrequency[0],(char *)"0");
strcpy(StrFrequency[1],(char *)"30");
for(i=0;i<2;i++)
IntFrequency[i] = atoi(StrFrequency[i]);
while(WinFlag)
{
clr_scr();
//显示界面静态数据
DispPhoto (10, 120, (char *)"测量频率",1);
DispString(12,6,(char *)"时",0);
DispString(16,6,(char *)"分",0);
//显示界面动态数据
DispPhoto (90,60, (char *)"更改", sel==1?1:0);
DispPhoto (90,200, (char *)"返回", sel==2?1:0);
DispChar (10, 6, StrFrequency[0], sel == 3?1:0);
DispChar (14, 6, StrFrequency[1], sel == 4?1:0);
DispPhoto (0, 0, (char *)"dd",0); //去掉
MenuFlag = 1;
while(MenuFlag)
{
pMsg = GetMessagetemp(task1_tmq);
switch(pMsg->message)
{
case TM_KEYOK:
if(sel != 2)
sel = DispMessage(100,120,(char *)"正在退出,是否保存数据?功能键是,其它键否",1);
;//保存数据于指定的空间
WinId = 6;
MenuFlag = 0;
WinFlag = 0;
break;
case TM_KEYRIGHT: //进入下一个处理
if(sel == 1)
sel = 3; //菜单循环
else if(sel == 2)
{
WinId = 6;
WinFlag = 0;
}
else if(sel == 3)
sel++;
else
sel = 2;
MenuFlag = 0;
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -