📄 util.c
字号:
dprintf("·锁控模式 ",10);
GLCD_Locate(16,48);
reverse=1;
dprintf("·报警参数 ",10);
break;
case enroll_tele:
GLCD_ClearScreen ();
GLCD_Locate(0,0);
reverse=0;
dprintf("报警参数",8);
GLCD_Locate(16,16);
reverse=1;
dprintf("·注册话号 ",10);
GLCD_Locate(16,32);
reverse=0;
dprintf("·清除话号 ",10);
GLCD_Locate(16,48);
if(tele_alarm_on)
dprintf("·报警布控 ",10);
else
dprintf("·报警撤控 ",10);
break;
case delete_tele:
GLCD_ClearScreen ();
GLCD_Locate(0,0);
reverse=0;
dprintf("报警参数",8);
GLCD_Locate(16,16);
dprintf("·注册话号 ",10);
GLCD_Locate(16,32);
reverse=1;
dprintf("·清除话号 ",10);
GLCD_Locate(16,48);
reverse=0;
if(tele_alarm_on)
dprintf("·报警布控 ",10);
else
dprintf("·报警撤控 ",10);
break;
case tele_on_off:
GLCD_ClearScreen ();
GLCD_Locate(0,0);
reverse=0;
dprintf("报警参数",8);
GLCD_Locate(16,16);
dprintf("·注册话号 ",10);
GLCD_Locate(16,32);
dprintf("·清除话号 ",10);
GLCD_Locate(16,48);
reverse=1;
if(tele_alarm_on)
dprintf("·报警布控 ",10);
else
dprintf("·报警撤控 ",10);
break;
default:
reverse=0;
break;
}
if(Menu_state!=Menu_top)
{
key=0;
do{}while(!key);
key_judge();
}
}while(Menu_state!=Menu_top);
reverse=0;
key=0;
}
///////////////////////////////////////////////////////////////////////////////
// 设置系统时间
///////////////////////////////////////////////////////////////////////////////
void Set_cur_time_proc()
{
idata uint temp;
read_time(); // 读取系统当前时间
GLCD_ClearScreen();
GLCD_Locate(0,0);
reverse=0;
dprintf("设置时间",8);
GLCD_Locate(0,16);
dprintf(" 年 月 日",15);
GLCD_Locate(0,32);
dprintf(" 时 分 秒",15);
GLCD_Locate(0,48);
dprintf(" 星期",9); // 设置时间底色
reverse=1;
disp_buf[0]=cur_time[0];
disp_buf[1]=cur_time[1];
disp_buf[2]=cur_time[2];
disp_buf[3]=cur_time[3];
disp_buf[4]=0x00;
GLCD_Locate(8,16);
dprintf(disp_buf,4); // 年
reverse=0;
disp_buf[0]=cur_time[4];
disp_buf[1]=cur_time[5];
disp_buf[2]=0x00;
GLCD_Locate(56,16);
dprintf(disp_buf,2); // 月
disp_buf[0]=cur_time[6];
disp_buf[1]=cur_time[7];
GLCD_Locate(88,16);
dprintf(disp_buf,2); // 日
disp_buf[0]=cur_time[8];
disp_buf[1]=cur_time[9];
GLCD_Locate(24,32);
dprintf(disp_buf,2); // 时
disp_buf[0]=cur_time[10];
disp_buf[1]=cur_time[11];
GLCD_Locate(56,32);
dprintf(disp_buf,2); // 分
disp_buf[0]=cur_time[12];
disp_buf[1]=cur_time[13];
GLCD_Locate(88,32);
dprintf(disp_buf,2); // 秒
GLCD_Locate(72,48);
dprintf(week[cur_time[14]-0x30],2);
disp_buf[0]=cur_time[0];
disp_buf[1]=cur_time[1];
disp_buf[2]=cur_time[2];
disp_buf[3]=cur_time[3];
disp_buf[4]=0x00;
while(1)
{
reverse=1;
GLCD_Locate(8,16);
dprintf(disp_buf,4);
key=0;
do{}while(!key); // 读键盘
key_judge();
if((key>=0x30) && (key<=0x39))
{
disp_buf[0]=disp_buf[1];
disp_buf[1]=disp_buf[2];
disp_buf[2]=disp_buf[3];
disp_buf[3]=key;
disp_buf[4]=0x00;
}
if(key=='F')
{
temp=(disp_buf[0]-0x30)*1000 + (disp_buf[1]-0x30)*100 + (disp_buf[2]-0x30)*10
+ (disp_buf[2]-0x30)*10;
if((temp<=2050)&&(temp>=2000))
{
cur_time[0]=disp_buf[0];
cur_time[1]=disp_buf[1];
cur_time[2]=disp_buf[2];
cur_time[3]=disp_buf[3];
reverse=0;
GLCD_Locate(8,16);
dprintf(disp_buf,4);
break;
}
else
pulse=3;
}
if(key=='C')
{
reverse=0;
return;
}
} // 设置年
disp_buf[0]=cur_time[4];
disp_buf[1]=cur_time[5];
disp_buf[2]=0x00;
while(1)
{
reverse=1;
GLCD_Locate(56,16);
dprintf(disp_buf,2);
key=0;
do{}while(!key); // 读键盘
key_judge();
if((key>=0x30) && (key<=0x39))
{
disp_buf[0]=disp_buf[1];
disp_buf[1]=key;
disp_buf[2]=0x00;
}
if(key=='F')
{
temp=(disp_buf[0]-0x30)*10 + (disp_buf[1]-0x30);
if((temp<=12)&&(temp>=1))
{
cur_time[4]=disp_buf[0];
cur_time[5]=disp_buf[1];
reverse=0;
GLCD_Locate(56,16);
dprintf(disp_buf,2);
break;
}
else
pulse=3;
}
if(key=='C')
{
reverse=0;
return;
}
} // 设置月
disp_buf[0]=cur_time[6];
disp_buf[1]=cur_time[7];
disp_buf[2]=0x00;
while(1)
{
reverse=1;
GLCD_Locate(88,16);
dprintf(disp_buf,2);
key=0;
do{}while(!key); // 读键盘
key_judge();
if((key>=0x30) && (key<=0x39))
{
disp_buf[0]=disp_buf[1];
disp_buf[1]=key;
disp_buf[2]=0x00;
}
if(key=='F')
{
temp=(disp_buf[0]-0x30)*10 + (disp_buf[1]-0x30);
if((temp<=31)&&(temp>=1))
{
cur_time[6]=disp_buf[0];
cur_time[7]=disp_buf[1];
reverse=0;
GLCD_Locate(88,16);
dprintf(disp_buf,2);
break;
}
else
pulse=3;
}
if(key=='C')
{
reverse=0;
return;
}
} // 设置日
disp_buf[0]=cur_time[8];
disp_buf[1]=cur_time[9];
disp_buf[2]=0x00;
while(1)
{
reverse=1;
GLCD_Locate(24,32);
dprintf(disp_buf,2);
key=0;
do{}while(!key); // 读键盘
key_judge();
if((key>=0x30) && (key<=0x39))
{
disp_buf[0]=disp_buf[1];
disp_buf[1]=key;
disp_buf[2]=0x00;
}
if(key=='F')
{
temp=(disp_buf[0]-0x30)*10 + (disp_buf[1]-0x30);
if((temp<=23)&&(temp>=0))
{
cur_time[8]=disp_buf[0];
cur_time[9]=disp_buf[1];
reverse=0;
GLCD_Locate(24,32);
dprintf(disp_buf,2);
break;
}
else
pulse=3;
}
if(key=='C')
{
reverse=0;
return;
}
} // 设置时
disp_buf[0]=cur_time[10];
disp_buf[1]=cur_time[11];
disp_buf[2]=0x00;
while(1)
{
reverse=1;
GLCD_Locate(56,32);
dprintf(disp_buf,2);
key=0;
do{}while(!key); // 读键盘
key_judge();
if((key>=0x30) && (key<=0x39))
{
disp_buf[0]=disp_buf[1];
disp_buf[1]=key;
disp_buf[2]=0x00;
}
if(key=='F')
{
temp=(disp_buf[0]-0x30)*10 + (disp_buf[1]-0x30);
if((temp<=59)&&(temp>=0))
{
cur_time[10]=disp_buf[0];
cur_time[11]=disp_buf[1];
reverse=0;
GLCD_Locate(56,32);
dprintf(disp_buf,2);
break;
}
else
pulse=3;
}
if(key=='C')
{
reverse=0;
return;
}
} // 设置分
disp_buf[0]=cur_time[12];
disp_buf[1]=cur_time[13];
disp_buf[2]=0x00;
while(1)
{
reverse=1;
GLCD_Locate(88,32);
dprintf(disp_buf,2);
key=0;
do{}while(!key); // 读键盘
key_judge();
if((key>=0x30) && (key<=0x39))
{
disp_buf[0]=disp_buf[1];
disp_buf[1]=key;
disp_buf[2]=0x00;
}
if(key=='F')
{
temp=(disp_buf[0]-0x30)*10 + (disp_buf[1]-0x30);
if((temp<=59)&&(temp>=0))
{
cur_time[12]=disp_buf[0];
cur_time[13]=disp_buf[1];
reverse=0;
GLCD_Locate(88,32);
dprintf(disp_buf,2);
break;
}
else
pulse=3;
}
if(key=='C')
{
reverse=0;
return;
}
} // 设置秒
GLCD_Locate(72,48);
temp=cur_time[14];
while(1)
{
GLCD_Locate(72,48);
reverse=1;
dprintf(week[temp-0x30],2);
key=0;
do{}while(!key); // 读键盘
key_judge();
if(key=='U')
{
temp++;
if(temp>'6')temp='0'; // 循环
}
if(key=='D')
{
temp--;
if(temp<'0')temp='6'; // 循环
}
if(key=='F')
{
reverse=0;
cur_time[14]=temp;
break;
}
if(key=='C')
{
reverse=0;
return;
}
} // 设置星期
reverse=0;
set_time(); // 设置时间
}
///////////////////////////////////////////////////////////////////////////////
// 设置通信地址、直接输入地址编号
///////////////////////////////////////////////////////////////////////////////
void set_addr_proc()
{
idata uchar temp;
GLCD_ClearScreen ();
GLCD_Locate(0,0);
reverse=0;
dprintf("设备地址设置",12);
GLCD_Locate(0,16);
dprintf("速率:",6);
GLCD_Locate(0,32);
dprintf("设备地址:",10);
GLCD_Locate(0,48);
dprintf("分组地址:",10);
switch(baudrate)
{
case 0:
disp_buf[0]=' ';
disp_buf[1]=' ';
disp_buf[2]='4';
disp_buf[3]='8';
disp_buf[4]='0';
disp_buf[5]='0';
break;
case 1:
disp_buf[0]=' ';
disp_buf[1]=' ';
disp_buf[2]='9';
disp_buf[3]='6';
disp_buf[4]='0';
disp_buf[5]='0';
break;
case 2:
disp_buf[0]=' ';
disp_buf[1]='1';
disp_buf[2]='9';
disp_buf[3]='2';
disp_buf[4]='0';
disp_buf[5]='0';
break;
case 3:
disp_buf[0]=' ';
disp_buf[1]='3';
disp_buf[2]='8';
disp_buf[3]='4';
disp_buf[4]='0';
disp_buf[5]='0';
break;
case 4:
disp_buf[0]=' ';
disp_buf[1]='5';
disp_buf[2]='7';
disp_buf[3]='6';
disp_buf[4]='0';
disp_buf[5]='0';
break;
case 5:
disp_buf[0]='1';
disp_buf[1]='1';
disp_buf[2]='5';
disp_buf[3]='2';
disp_buf[4]='0';
disp_buf[5]='0';
break;
default:
break;
}
disp_buf[6]=0x00;
reverse=1;
GLCD_Locate(64,16);
dprintf(disp_buf,6);
temp=Para_ee.Actual_para->Machine_addr; // 设备地址
disp_buf[0]=(temp/100)+0x30;
disp_buf[1]=((temp%100)/10)+0x30;
disp_buf[2]=(temp%10)+0x30;
disp_buf[3]=0x00;
reverse=0;
GLCD_Locate(80,32);
dprintf(disp_buf,3);
temp=Para_ee.Actual_para->Area_addr; // 分组地址
disp_buf[0]=(temp/100)+0x30;
disp_buf[1]=((temp%100)/10)+0x30;
disp_buf[2]=(temp%10)+0x30;
disp_buf[3]=0x00;
reverse=0;
GLCD_Locate(80,48);
dprintf(disp_buf,3);
temp=baudrate+1; // 波特率
while(1)
{
switch(temp-1)
{
case 0:
disp_buf[0]=' ';
disp_buf[1]=' ';
disp_buf[2]='4';
disp_buf[3]='8';
disp_buf[4]='0';
disp_buf[5]='0';
break;
case 1:
disp_buf[0]=' ';
disp_buf[1]=' ';
disp_buf[2]='9';
disp_buf[3]='6';
disp_buf[4]='0';
disp_buf[5]='0';
break;
case 2:
disp_buf[0]=' ';
disp_buf[1]='1';
disp_buf[2]='9';
disp_buf[3]='2';
disp_buf[4]='0';
disp_buf[5]='0';
break;
case 3:
disp_buf[0]=' ';
disp_buf[1]='3';
disp_buf[2]='8';
disp_buf[3]='4';
disp_buf[4]='0';
disp_buf[5]='0';
break;
case 4:
disp_buf[0]=' ';
disp_buf[1]='5';
disp_buf[2]='7';
disp_buf[3]='6';
disp_buf[4]='0';
disp_buf[5]='0';
break;
case 5:
disp_buf[0]='1';
disp_buf[1]='1';
disp_buf[2]='5';
disp_buf[3]='2';
disp_buf[4]='0';
disp_buf[5]='0';
break;
default:
break;
}
disp_buf[6]=0x00;
reverse=1;
GLCD_Locate(64,16);
dprintf(disp_buf,6);
key=0;
do{}while(!key); // 读键盘
key_judge();
if(key=='U')
{
temp++;
if(temp>6)temp=1; // 循环
}
if(key=='D')
{
temp--;
if(temp<1)temp=6; // 循环
}
if(key=='F')
{
Para_ee.Actual_para->Baudrate=temp-1; // 修改波特率
Write_Para(); // 保存波特率
baudrate=temp-1;
Baud_Init(); // 设置波特率
switch(baudrate)
{
case 0:
disp_buf[0]=' ';
disp_buf[1]=' ';
disp_buf[2]='4';
disp_buf[3]='8';
disp_buf[4]='0';
disp_buf[5]='0';
break;
case 1:
disp_buf[0]=' ';
disp_buf[1]=' ';
disp_buf[2]='9';
disp_buf[3]='6';
disp_buf[4]='0';
disp_buf[5]='0';
break;
case 2:
disp_buf[0]=' ';
disp_buf[1]='1';
disp_buf[2]='9';
disp_buf[3]='2';
disp_buf[4]='0';
disp_buf[5]='0';
break;
case 3:
disp_buf[0]=' ';
disp_buf[1]='3';
disp_buf[2]='8';
disp_buf[3]='4';
disp_buf[4]='0';
disp_buf[5]='0';
break;
case 4:
disp_buf[0]=' ';
disp_buf[1]='5';
disp_buf[2]='7';
disp_buf[3]='6';
disp_buf[4]='0';
disp_buf[5]='0';
break;
case 5:
disp_buf[0]='1';
disp_buf[1]='1';
disp_buf[2]='5';
disp_buf[3]='2';
disp_buf[4]='0';
disp_buf[5]='0';
break;
default:
break;
}
disp_buf[6]=0x00;
reverse=0;
GLCD_Locate(64,16);
dprintf(disp_buf,6);
break;
}
if(key=='C')
{
reverse=0;
return;
}
}
temp=Para_ee.Actual_para->Machine_addr; // 设备地址
disp_buf[0]=(temp/100)+0x30;
disp_buf[1]=((temp%100)/10)+0x30;
disp_buf[2]=(temp%10)+0x30;
disp_buf[3]=0x00;
while(1)
{
reverse=1;
GLCD_Locate(80,32);
dprintf(disp_buf,3);
key=0;
do{}while(!key); // 读键盘
key_judge();
if((key>=0x30) && (key<=0x39))
{
disp_buf[0]=disp_buf[1];
disp_buf[1]=disp_buf[2];
disp_buf[2]=key;
disp_buf[3]=0x00;
}
if(key=='F')
{
temp=(disp_buf[0]-0x30)*100 + (disp_buf[1]-0x30)*10 + (disp_buf[2]-0x30);
if(temp<=254)
{
Para_ee.Actual_para->Machine_addr=temp; // 保存设备地址
Write_Para();
haddr=(temp&0xF0)>>4;
haddr=Hex_ascii(haddr); // ASC地址
laddr=temp&0x0F;
laddr=Hex_ascii(laddr);
decaddr=temp;
reverse=0;
GLCD_Locate(80,32);
dprintf(disp_buf,3);
break;
}
else
pulse=3;
}
if(key=='C')
{
reverse=0;
return;
}
}
temp=Para_ee.Actual_para->Area_addr; // 分组地址
disp_buf[0]=(temp/100)+0x30;
disp_buf[1]=((temp%100)/10)+0x30;
disp_buf[2]=(temp%10)+0x30;
disp_buf[3]=0x00;
while(1)
{
reverse=1;
GLCD_Locate(80,48);
dprintf(disp_buf,3);
key=0;
do{}while(!key); // 读键盘
key_judge();
if((key>=0x30) && (key<=0x39))
{
disp_buf[0]=disp_buf[1];
disp_buf[1]=disp_buf[2];
disp_buf[2]=key;
disp_buf[3]=0x00;
}
if(key=='F')
{
temp=(disp_buf[0]-0x30)*100 + (disp_buf[1]-0x30)*10 + (disp_buf[2]-0x30);
if(temp<240)
{
Para_ee.Actual_para->Area_addr=temp; // 保存分组地址
Write_Para();
areaaddr=temp;
reverse=0;
if(wieformat==1) // 自定义门禁方式
addr_reg(); // 向门控器注册终端地址
return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -