⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 globle.c

📁 基于ARM的uCOS-II完整源码,在VC++ WINDOWN下的编程. 利用VC++直接编译显示图形.便于源码的调试.首先下载uC/OS-II - WIN32 Port for 32bit Wind
💻 C
📖 第 1 页 / 共 2 页
字号:
    ShowFont(startregionx,y,str); //根据点陈坐标显示汉字
}
void DispPhoto (INT16U x, INT16U y, char *str, uint8 mode)
{
    INT16U ShowLen,fontx;  //入参字符串的长度
    
    INT16U startregionx,endregionx,startregiony,endregiony;
    
    ShowLen = strlen(str);
    if(ShowLen ==2)
		fontx = x+1;
	else
		fontx = x;
    if(NULL == str || ShowLen >8)
    {
       DispString(0,0,(char *)"系统错误",0);
       if(debug)
         DispString(0,0,(char *)"DispPhoto入参为空",0);
       return;
    }
    if ((y < 1 || y > 23) || (x < 1 || x > 78))
    {
       DispString(0,0,(char *)"系统错误",0);
       if(debug)
         DispString(0,0,(char *)"DispPhoto画点时的边距参数错误",0);
       return;
    }
    if(mode ==0)  
    {
        ShowMatrix(x-1,y-1,x+9,y+1,DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
        PC_DispStr(fontx, y, str, DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);

	}
	else
	{
		ShowMatrix(x-1,y-1,x+9,y+1,DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	    PC_DispStr(fontx, y, str, DISP_FGND_YELLOW + DISP_BGND_BLUE);

	}
}
    //先画矩阵框,再显示字体
    /*ShowMatrix(startregionx,startregiony,endregionx,endregiony,backcolor);
    startregionx = x - (INT16U)((8 - ShowLen) / 2);  //汉字的起始点
    ShowFont(startregionx,y,str); //根据点陈坐标显示汉字
}
/****************************************************************************
* 函数名:
* 功能:如果调试开关打开,则打印定位提示信息
****************************************************************************/
void Debug(char *Err)
{
   if(debug)
       DispString(0,0,Err,0);
   while(1);
}

/****************************************************************************
* 函数名:GetDate
* 功能:  获取系统当前时间于BUFF中,格式为 2005/01/01
  返回值: 获取成功时,返回1,发生错误时返回0
****************************************************************************/
uint8 GetDate(char *Buff)
{
  return 1;
}

/****************************************************************************
* 函数名:measure
* 功能:  调用测量函数,启动测量并保存测量结果
  注意:   在函数开始判断终端状态为IDEL后,要置状态为MEASURE
  返回值: 测量及存储成功时,返回1,发生错误时返回0
****************************************************************************/
uint8 measure()
{
	uint8 sel;
	sel = DispMessage(100,120,(char *)"正在测量您的血压?请稍后........",1);
	return 1;
}


/****************************************************************************
* 函数名:ShowByDate
* 功能:  显示天的血压数据信息,按测量键时,进入测量前界面;按上下键时,查看前后天信息,
          按向左键时返回上层菜单
  注意:   
  返回值: 无
****************************************************************************/
void ShowByDate()
{
	;
}

/****************************************************************************
* 函数名:ShowByWake
* 功能:  显示医嘱信息,按测量键时,进入测量前界面;按上下键时,查看医嘱信息,按向左键
          时返回上层菜单
  注意:   
  返回值: 无
****************************************************************************/
void ShowByWake()
{
	;
}

/****************************************************************************
* 函数名:ShowByMonth
* 功能:  显示医嘱信息,按测量键时,进入测量前界面;按上下键时,查看医嘱信息,按向左键
          时返回上层菜单
  注意:   
  返回值: 无
****************************************************************************/
void ShowByMonth()
{
	;
}

/****************************************************************************
* 函数名:Cvt_SecordToStr
* 功能:  将分钟数转化为小时:分钟的字符串
          例如:  260分钟转化为字符串  4:20
  注意:   Secord为分钟数,转化后的字符串为Str
  返回值: 失败时返回0,成功时返回1
****************************************************************************/
uint8 Cvt_SecordToStr(INT16U Secord,char *Str)
{
	return 0;
}

/****************************************************************************
* 函数名:Cvt_StrToSecord
* 功能:  将小时:分钟的字符串转化为分钟值
          例如:  字符串  4:20 转化为 260分钟
  注意:   Str为字符串地址
  返回值: 返回转化的分钟数,发生错误时返回65534
****************************************************************************/
INT16U Cvt_StrToSecord(char *Str)
{
		return 0;
}

/****************************************************************************
* 函数名: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
****************************************************************************/
INT16U allday(INT16U x)
{ 
  INT16U 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)
{
  INT16U i;
  INT16U yea1,yea2,mon1,mon2,day1,day2,hour2,second2;
  INT16U month1[]={31,28,31,30,31,30,31,31,30,31,30,31};
  INT16U month2[]={31,29,31,30,31,30,31,31,30,31,30,31};
  INT16U *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 yea1,mon1,day1,hour1,second1;
  INT16U month1[]={31,28,31,30,31,30,31,31,30,31,30,31};
  INT16U month2[]={31,29,31,30,31,30,31,31,30,31,30,31};
  INT16U *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++);
		
}

void drap_info()
{
	int a;
}

void line(int sx,int sy,int ex,int ey,uint32 color)
{
   HPEN hPen,hOldPen; //画笔
   //for(;i<500;++i)0x0000ff
            //SetPixel(hDC,10+i,10+i,0x0000ff);//用画点的办法画一根线,最后一个参数是颜色(32位)
   hPen=CreatePen(PS_SOLID,2,color);//生成绿色画笔
   hOldPen=(HPEN)SelectObject(hdc,hPen);//把画笔引入设备场境
   MoveToEx(hdc,sx,sy,NULL); //设置画线起点
   LineTo(hdc,ex,ey);      //画到终点

}
void DrawRec(uint16 sx,uint16 sy,uint16 ex,uint16 ey,uint32 color)
{
   uint16 i;
   for(i=sx;i<ex;i++)
	     line(i,sy,i,ey,color);

}
/*********************************************************************************************************
* 名称 : ShowBattery()
* 功能 : 电池图标
* 入口参数 : 
* 出口参数 : 无
********************************************************************************************************/
void ShowBattery(uint16 x,uint16 y,uint16 CurVolt,uint16 MinVolt,uint16 MaxVolt)
{
   
   uint32 color = 0xff0000;
   uint16 length,width,temp,lop,i,Segline;
   uint16 tmpvolt,Segvolt;
   int8 szChar[40];
   length = 12;
   width  = 32;
   temp = 3;
   tmpvolt = MaxVolt - MinVolt;
   Segvolt = tmpvolt >> 2;
   Segline = width >> 2;
   //画一个矩形
   line(x,y,x,y+length,color);
   line(x+width,y,x+width,y+length,color);
   line(x,y+length,x+width,y+length,color);
   line(x,y,x+width,y,color);
   //画一个实框
   DrawRec(x+width,y+temp,x+width+4,y+3*temp,color);
   for(lop=4;lop>0;lop--)
   {
        if(CurVolt - MinVolt > (lop-1) * Segvolt)
		{
           DrawRec(x+2,y+2,x+Segline*lop,y+length-2,color);
		   for(i=2;i<=lop;i++)
			   line(x+Segline*(i-1),y+1,x+Segline*(i-1),y+length-1,0x808080);
		   if(lop > 0)
               line(x+1,y+1,x+1,y+length-1,0x808080);
           if(lop == 4)
               line(x+width-1,y+1,x+width-1,y+length-1,0x808080);
		   break;
		}
   } 
   
}

/*********************************************************************************************************
* 名称 : ShowGprs()
* 功能 : gprs信号显示
* 入口参数 : 
* 出口参数 : 无
********************************************************************************************************/
void ShowGprs(uint16 x,uint16 y,uint16 CurVolt,uint16 MinVolt,uint16 MaxVolt)
{
   
   uint32 color = 0xff0000;
   uint16 length,width,temp,lop,i,Segline;
   uint16 tmpvolt,Segvolt;
   int8 szChar[40];
   length = 12;
   width  = 32;
   temp = 3;
   tmpvolt = MaxVolt - MinVolt;
   Segvolt = tmpvolt >> 2;
   Segline = width >> 2;
   //画一个矩形
   line(x,y,x,y+length,color);
   line(x+width,y,x+width,y+length,color);
   line(x,y+length,x+width,y+length,color);
   line(x,y,x+width,y,color);
   //画一个实框
   DrawRec(x+width,y+temp,x+width+4,y+3*temp,color);
   //sprintf(szChar,"char is %d",Segvolt);  //获得按键并保存在字符串里
   //TextOut(hdc,0,220,szChar,strlen(szChar));  //打印文字
   for(lop=4;lop>0;lop--)
   {
        if(CurVolt - MinVolt > (lop-1) * Segvolt)
		{
           DrawRec(x+2,y+2,x+Segline*lop,y+length-2,color);
		   sprintf(szChar,"char is %d",lop);  //获得按键并保存在字符串里
           TextOut(hdc,0,220,szChar,strlen(szChar));  //打印文字
		   for(i=2;i<=lop;i++)
			   line(x+Segline*(i-1),y+1,x+Segline*(i-1),y+length-1,0x808080);
		   if(lop > 0)
               line(x+1,y+1,x+1,y+length-1,0x808080);
           if(lop == 4)
               line(x+width-1,y+1,x+width-1,y+length-1,0x808080);
 
		   break;
		}
   } 
   
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -