📄 globle.c.bak
字号:
/****************************************************************************
* 函数名:ShowByWake
* 功能: 显示医嘱信息,按测量键时,进入测量前界面;按上下键时,查看医嘱信息,按向左键
时返回上层菜单
注意:
返回值: 无
****************************************************************************/
void ShowByWake()
{
;
}
/****************************************************************************
* 函数名:ShowByMonth
* 功能: 显示医嘱信息,按测量键时,进入测量前界面;按上下键时,查看医嘱信息,按向左键
时返回上层菜单
注意:
返回值: 无
****************************************************************************/
void ShowByMonth()
{
;
}
/****************************************************************************
* 函数名:Cvt_SecordToStr
* 功能: 将分钟数转化为小时:分钟的字符串
例如: 260分钟转化为字符串 4:20
注意: Secord为分钟数,转化后的字符串为Str
返回值: 失败时返回0,成功时返回1
****************************************************************************/
uint8 Cvt_SecordToStr(uint16 Secord,char *Str)
{
;
}
/****************************************************************************
* 函数名:Cvt_StrToSecord
* 功能: 将小时:分钟的字符串转化为分钟值
例如: 字符串 4:20 转化为 260分钟
注意: Str为字符串地址
返回值: 返回转化的分钟数,发生错误时返回65534
****************************************************************************/
uint16 Cvt_StrToSecord(char *Str)
{
;
}
/****************************************************************************
* 函数名:SubString
* 功能: 载取字符串的部分内容
参数: 源字符串,起始位置,截取长度
注意: 位置从0开始
返回值:
****************************************************************************/
char* SubString(char *source,int pos,int length)
{
/*char Disc[255];
char str[255];
int i;
strcpy(str,source);
for(i=0;i<length;i++)
Disc[i]=str[i+pos];
Disc[i]=0;
return Disc;*/
}
/****************************************************************************
* 函数名:allday
* 功能: 判断是否是润年,是时返回366,否返回365
返回值: 是时返回366,否返回365
****************************************************************************/
uint16 allday(uint16 x)
{
uint16 y;
if(((x%4==0)&&(x%100!=0))||((x%100==0)&&(x%400==0)))
y=366;
else
y=365;
return (y);
}
/****************************************************************************
* 函数名:GetSecond
* 功能: 根据两个时间点,获取间隔的分钟数
参数: 参数格式: 2000/01/01/00:00 起始时间和终止时间
注意: 第一个参数要小于第二个参数
起始时间格式为:2000/01/01/00:00 (必须) 年份可变,其它不可变
返回值: 错误时返回0,正常时返回得到的分钟数
****************************************************************************/
uint32 GetSecond(int8 *InitDate,int8 *StrDate)
{
uint16 i;
uint16 yea1,yea2,mon1,mon2,day1,day2,hour2,second2;
uint16 month1[]={31,28,31,30,31,30,31,31,30,31,30,31};
uint16 month2[]={31,29,31,30,31,30,31,31,30,31,30,31};
uint16 *p = NULL;
int32 add_day1=0;
int32 add_day2=0;
int32 add_day3=0;
int32 add_day4=0;
int32 add_all =0;
if(InitDate == NULL || StrDate == NULL)
return 0; //参数错误
if(strcmp(InitDate,StrDate) > 0)
return 0; //参数错误
//获取数值到相应的变量
yea1 = atoi(SubString(InitDate,0,4));
mon1 = atoi(SubString(InitDate,5,2));
day1 = atoi(SubString(InitDate,8,2));
yea2 = atoi(SubString(StrDate,0,4));
mon2 = atoi(SubString(StrDate,5,2));
day2 = atoi(SubString(StrDate,8,2));
hour2 = atoi(SubString(StrDate,11,2));
second2 = atoi(SubString(StrDate,14,2));
if(judge(yea1))
p=month2;
else
p=month1;
add_day1=*(p+mon1-1)-day1;
for(i=mon1;i<=11;i++)
add_day2=add_day2+*(p+i);
for(i=yea1+1;i<yea2;i++)
add_day3=add_day3+allday(i);
if(judge(yea2)) p=month2;
else p=month1;
for(i=1;i<mon2;i++)
add_day4=add_day4+*(p+i-1);
add_all = add_day1+add_day2+add_day3+add_day4+day2; //得到天数
add_all = add_all*24*60 + hour2*60 + second2;
return add_all;
}
/****************************************************************************
* 函数名:GetDateTime
* 功能: 根据起始时间和分钟数得到当前时间
参数: 起始时间和当前时间参数格式: 2000/01/01/00:00
注意: 起始时间格式为:2000/01/01/00:00 (必须) 年份可变,其它不可变
返回值: 错误时返回0,正常时返回1
****************************************************************************/
uint8 GetDateTime(uint32 Second,int8 *InitDate,int8 *StrDate)
{
INT16U i;
uint16 yea1,mon1,day1,hour1,second1;
uint16 month1[]={31,28,31,30,31,30,31,31,30,31,30,31};
uint16 month2[]={31,29,31,30,31,30,31,31,30,31,30,31};
uint16 *p = NULL;
uint32 daysecond = 24*60;
uint32 year_second = 0;
int8 Str[10];
if(InitDate == NULL)
return 0; //参数错误
//获取数值到相应的变量
yea1 = atoi(SubString(InitDate,0,4));
mon1 = atoi(SubString(InitDate,5,2));
day1 = atoi(SubString(InitDate,8,2));
hour1 = atoi(SubString(InitDate,11,2));
second1 = atoi(SubString(InitDate,14,2));
while(Second)
{
if(judge(yea1))
year_second = 356*daysecond;
else
year_second = 355*daysecond;
if(judge(yea1))
p=month2;
else
p=month1;
if(Second >= year_second) //年份加1
{
yea1++;
Second -= year_second;
}
else if(Second >= (*(p+mon1-1))*daysecond) //月份加1
{
mon1++;
Second -= (*(p+mon1-1))*daysecond;
}
else if(Second >= daysecond) //天数加1
{
day1++;
Second -= daysecond;
}
else if(Second >= 60) //时间加1
{
hour1++;
Second -= 60;
}
else //秒数加
{
second1 += Second;
}
} //end while
itoa(yea1,Str,10);
strcpy(StrDate,Str);
strcat(StrDate,(char *)"/");
itoa(mon1,Str,10);
strcat(StrDate,Str);
strcat(StrDate,(char *)"/");
itoa(mon1,Str,10);
strcat(StrDate,Str);
strcat(StrDate,(char *)"/");
itoa(day1,Str,10);
strcat(StrDate,Str);
strcat(StrDate,(char *)"/");
itoa(hour1,Str,10);
strcat(StrDate,Str);
strcat(StrDate,(char *)":");
itoa(second1,Str,10);
strcat(StrDate,Str);
return 1;
}
/********************************************************************************************************
* 名称 : DelayNS()
* 功能 : 长软件延时
* 入口参数 : dly 延时参数, 值越大,延时越久
* 出口参数 : 无
********************************************************************************************************
*/
void DelayNS(uint32 dly)
{
uint32 i;
for(;dly>0;dly--)
for(i=0;i<50000;i++);
}
/*********************************************************************************************************
* 名称 : DelayNS()
* 功能 : 长软件延时
* 入口参数 : dly 延时参数, 值越大,延时越久
* 出口参数 : 无
********************************************************************************************************
*/
void OS_memcpy(int8 *des,int8 *src)
{
uint8 i,dly;
for(;dly>0;dly--)
for(i=0;i<50000;i++);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -