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

📄 globle.c

📁 基于ARM的uCOS-II完整源码,在VC++ WINDOWN下的编程. 利用VC++直接编译显示图形.便于源码的调试.首先下载uC/OS-II - WIN32 Port for 32bit Wind
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************
* 文件名:globle.C
* 功能:全局功能函数及变量定义
****************************************************************************/
#include "includes.h"
#define judge(y)  ((y%4==0)&&(y%100!=0)||(y%400==0))


 TemiStatus TStatus; //定义终端状态全局变量
 uint8      WinId;   //定义当前窗体状态
 uint8      debug;    //调试开关,默认关闭
 extern  HWND               hwnd  ; 
 extern HDC  hdc;
 extern TMQ	 *task1_tmq;
uint8  init_beep[] = { 20,50, 0,5, 20,50, 0,5, 20,50, 0,5, 0,0}; //音频设置
//函数声明
void SetVideoMode(uint8 mode);
void DispString (uint8 x, uint8 y, char *str, uint8 mode);
void SetFont(uint8 type);
void gotoxy (uint8 x, uint8 y);
void Debug(char *Err);
uint8 GetDate(char *Buff);
uint8 measure();
//void  clr_kb(); 
uint8 Cvt_SecordToStr(INT16U Secord,char *Str);
INT16U Cvt_StrToSecord(char *Str);

/*
void OpenComm();
void CloseComm();
void ReadComm(char c);
void WriteComm(char c);
void GPRSInit();
void GPRSDial(); //拨号函数
void GPRSHangup(); //断开连接函数
void GPRSOnline(); //检测是否处于在线状态函数
void GPRSBuffFlush (); // 清空buffer           */

/*********************************以下需要根据硬件写函数*/
/****************************************************************************
* 函数名:OpenComm
* 功能:打开串口
****************************************************************************/
void OpenComm(char c)
{

}
/****************************************************************************
* 函数名:CloseComm
* 功能:关闭串口
****************************************************************************/
void CloseComm()
{
}

/****************************************************************************
* 函数名:ReadComm
* 功能:读串口数据
****************************************************************************/
void ReadComm(char c)
{
}

/****************************************************************************
* 函数名:WriteComm
* 功能:写串口数据
****************************************************************************/
void WriteComm(char c)
{
/*ES = 0;
SBUF = c;
while(TI==0);
TI=0;
ES = 1;*/
}



/****************************************************************************
* 函数名:
* 功能:全局功能函数及变量定义
****************************************************************************/
void SetFont(uint8 type)
{
   ;//设置用户字体,1为12*12 / 2为16*16
}

/****************************************************************************
* 函数名:
* 功能:全局功能函数及变量定义
****************************************************************************/
void SetVideoMode(uint8 mode)
{
  ;//设置反显模式
  //mode为0 正常显示/1 反显
   
}
void DispKey (INT16U x, INT16U y, char *str, uint8 mode)
{
    INT16U ShowLen,fontx;  //入参字符串的长度
    
    INT16U sx,ex,sy,ey,relx,rely;
    RECT   rc;   
    HBRUSH hbr,hbr2;
	hbr=CreateSolidBrush(RGB(255,0,0));
	hbr2=CreateSolidBrush(RGB(100,100,100));
    SetRect(&rc,x-4,y-4,x+72,y+24); 
    FillRect(hdc,&rc,(HBRUSH)GetStockObject(GRAY_BRUSH)); 
    ShowLen = strlen(str);
	if(ShowLen == 4)
		relx = x+16;
	else 
		relx = x;	
    if(ShowLen == 2)
		fontx = x+1;
	else
		fontx = x;
    if(NULL == str || ShowLen >8)
    {
       DispString(0,0,(char *)"系统错误",1);
       if(debug)
         DispString(0,0,(char *)"DispPhoto入参为空",0);
       return;
    }
	if(x==0)
		return;
    /*if ((y < 4 || y > 216) || (x < 4 || x > 248))
    {
       DispString(0,0,(char *)"显示菜单时XY错误",0);
       if(debug)
         DispString(0,0,(char *)"DispPhoto画点时的边距参数错误",0);
       return;
    }*/
    if(mode == 1)  
    {
        SetRect(&rc,x-4,y-4,x+72,y+24);
        FillRect(hdc,&rc,hbr); 
        SetTextColor(hdc,RGB(0,0,255));
		SetBkColor(hdc,RGB(255,0,0));
        TextOut(hdc,relx,y,str,strlen(str));  //打印文字

	}
	else
	{
		SetRect(&rc,x-4,y-4,x+72,y+24);
        FillRect(hdc,&rc,hbr2);  
        SetTextColor(hdc,RGB(0,0,255));
		SetBkColor(hdc,RGB(100,100,100));
        TextOut(hdc,relx,y,str,strlen(str));  //打印文字
	}
}
/****************************************************************************
* 函数名:
* 功能:全局功能函数及变量定义
****************************************************************************/
void clr_scr()
{
   //清屏函数
   //PC_DispClrScr(DISP_BGND_LIGHT_GRAY);
   //HBRUSH hbr;
   int8 s[40];
   RECT   rc;   
   //hbr=CreateSolidBrush(RGB(100,200,255));
   SetRect(&rc,0,16,320,240);
   //FillRect(hdc,&rc,(HBRUSH)GetStockObject(BLACK_BRUSH));  
   FillRect(hdc,&rc,(HBRUSH)GetStockObject(GRAY_BRUSH)); 
   //以下代码测试时用到
   line(0,0,0,240,0x0000ff);  //lcd区域
   //line(0,0,320,0,0x0000ff);
   line(320,0,320,240,0x0000ff);
   line(0,240,320,240,0x0000ff);
   DispKey (500, 120, (char *)"向上5",  1);
   DispKey (500, 200, (char *)"向下2",  1);
   DispKey (400, 160, (char *)"向左1",  1);
   DispKey (600, 160, (char *)"向右3",  1);
   DispKey (500, 160, (char *)"功能ent",  1);
   DispKey (500, 40, (char *)"测量esc",  1);
}

/****************************************************************************
* 函数名:
* 功能:全局功能函数及变量定义
****************************************************************************/
void on_beeper(uint8 frequency[])
{
  ;//根据指定的频率提示音给用户
}

/****************************************************************************
* 函数名:
* 功能:全局功能函数及变量定义
****************************************************************************/
void gotoxy (uint8 x, uint8 y)
{
  ;//将屏幕指针指向X/Y处
   //置显存地址
}
/****************************************************************************
* 函数名:
* 功能:清除键盘缓存消息
****************************************************************************/
void  clr_kb() 
{
	;//清除键盘缓存消息
}
/****************************************************************************
* 函数名:
* 功能:全局功能函数及变量定义
****************************************************************************/
void DispString (uint8 x, uint8 y, char *str, uint8 mode)
{
	uint16 relx,rely,len;
	relx = x*16;
	rely = y*16;
    if ( y > 14 || x > 39)
        return;
    if(mode ==1)  
	{
		SetTextColor(hdc,RGB(255,0,0));
		SetBkColor(hdc,RGB(128,128,128));
        TextOut(hdc,relx,rely,str,strlen(str));  //打印文字
		//PC_DispStr(x, y, str, DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);

	}
	else
	{
        SetTextColor(hdc,RGB(0,0,255));
		SetBkColor(hdc,RGB(128,128,128));  
	    TextOut(hdc,relx,rely,str,strlen(str));  //打印文字
		//PC_DispStr(x, y, str, DISP_FGND_YELLOW + DISP_BGND_BLUE);
	}

    //ReleaseDC(hwnd,hdc);  //释放DC
}

/****************************************************************************
* 函数名:显示字符
* 功能:全局功能函数及变量定义
****************************************************************************/
void DispChar (uint8 x, uint8 y, char *str, uint8 mode)
{
	uint16 relx,rely,len;
	relx = x*16;
	rely = y*16;
    if ( y > 14 || x > 39)
        return;
    if(mode ==1)  
	{
		SetTextColor(hdc,RGB(255,0,0));
		SetBkColor(hdc,RGB(128,128,128));
        TextOut(hdc,relx,rely,str,strlen(str));  //打印文字
	}
	else
	{
        SetTextColor(hdc,RGB(0,0,255));
		SetBkColor(hdc,RGB(100,100,100));  
	    TextOut(hdc,relx,rely,str,strlen(str));  //打印文字
		//PC_DispStr(x, y, str, DISP_FGND_YELLOW + DISP_BGND_BLUE);
	}

    //ReleaseDC(hwnd,hdc);  //释放DC
}
/****************************************************************************
* 函数名:
* 功能:全局功能函数及变量定义
****************************************************************************/
void ShowFont(INT16U x, INT16U y, char *str)
{
   ;//增加代码
}

/****************************************************************************
* 函数名:
* 功能:全局功能函数及变量定义
****************************************************************************/
void ShowMatrix(uint8 sx,uint8 sy,uint8 ex,uint8 ey,uint8 color)
{
  uint8 i;
  int8 str1,str2;
  str1='-';
  str2='|';
  for(i=sx;i<ex;i++)
  {
     PC_DispChar(i, sy, str1, color);
     PC_DispChar(i, ey, str1, color);
  }
    for(i=sy;i<ey;i++)
  {
     PC_DispChar(sx, i, str2, color);
     PC_DispChar(ex, i, str2, color);
  }
}

/****************************************************************************
* 函数名:
* 功能:一个菜单固定显示4个汉字字符,周围用背景色包围
        显示长度为8  包围的空隙为2(即汉字与边框距离为4个点
        汉字16*16 /屏幕为320*240 
        一行可显示13个菜单
        一列可显示10个菜单
        x,y为汉字起始点  4<x<300  4<y<220
****************************************************************************/
void DispPhoto (INT16U x, INT16U y, char *str, uint8 mode)
{
    INT16U ShowLen,fontx;  //入参字符串的长度
    
    INT16U sx,ex,sy,ey,relx,rely;
    RECT   rc;   
    HBRUSH hbr,hbr2;
	hbr=CreateSolidBrush(RGB(255,0,0));
	hbr2=CreateSolidBrush(RGB(100,100,100));
    SetRect(&rc,x-4,y-4,x+72,y+24); 
    FillRect(hdc,&rc,(HBRUSH)GetStockObject(GRAY_BRUSH)); 
    ShowLen = strlen(str);
	if(ShowLen == 4)
		relx = x+16;
	else 
		relx = x;	
    if(ShowLen == 2)
		fontx = x+1;
	else
		fontx = x;
    if(NULL == str || ShowLen >8)
    {
       DispString(0,0,(char *)"系统错误",1);
       if(debug)
         DispString(0,0,(char *)"DispPhoto入参为空",0);
       return;
    }
	if(x==0)
		return;
    if ((y < 4 || y > 216) || (x < 4 || x > 248))
    {
       DispString(0,0,(char *)"显示菜单时XY错误",0);
       if(debug)
         DispString(0,0,(char *)"DispPhoto画点时的边距参数错误",0);
       return;
    }
    if(mode == 1)  
    {
        SetRect(&rc,x-4,y-4,x+72,y+24);
        FillRect(hdc,&rc,hbr); 
        SetTextColor(hdc,RGB(0,0,255));
		SetBkColor(hdc,RGB(255,0,0));
        TextOut(hdc,relx,y,str,strlen(str));  //打印文字

	}
	else
	{
		SetRect(&rc,x-4,y-4,x+72,y+24);
        FillRect(hdc,&rc,hbr2);  
        SetTextColor(hdc,RGB(0,0,255));
		SetBkColor(hdc,RGB(100,100,100));
        TextOut(hdc,relx,y,str,strlen(str));  //打印文字
	}
}
 /****************************************************************************
* 函数名:
* 功能:一个菜单固定显示4个汉字字符,周围用背景色包围
        显示长度为8  包围的空隙为2(即汉字与边框距离为4个点
        汉字16*16 /屏幕为320*240 
        一行可显示13个菜单
        一列可显示10个菜单
        x,y为汉字起始点  4<x<300  4<y<220
		mode: 0表示延时1秒, 1表示用户选择
****************************************************************************/
uint8 DispMessage (INT16U x, INT16U y, int8 *str, uint8 mode)
{
    INT16U ShowLen,fontx;  //入参字符串的长度
    INT16U sx,ex,sy,ey,relx,rely;
    uint8 i,type;
	int8 row1[37],row2[37];
    RECT   rc;   
	MSGtemp  *pMsg;        //声明消息
    HBRUSH hbr,hbr2;
	hbr=CreateSolidBrush(RGB(255,0,0));
	hbr2=CreateSolidBrush(RGB(100,100,100));
    FillRect(hdc,&rc,(HBRUSH)GetStockObject(GRAY_BRUSH)); 
    ShowLen = strlen(str);
	clr_scr();
	if(ShowLen <= 14)
	{
		type = 0; //一行
        strcpy(row1,str);
	}
	else 
	{
		type = 1; //二行
		for(i=0;i<ShowLen;i++)
			if(str[i] =='?')
				break;
        strcpy(row1,SubString(str,0,i));
		strcpy(row2,SubString(str,i+1,ShowLen-i-1));
	}
	if(ShowLen == 4)
		relx = x+16;
	else 
		relx = x;	
    if(ShowLen == 2)
		fontx = x+1;
	else
		fontx = x;
    if(NULL == str || ShowLen >72)
    {
       DispString(0,0,(char *)"系统错误",1);
       if(debug)
         DispString(0,0,(char *)"DispPhoto入参为空",0);
       return 2;
    }
	if(x==0)
		return 0;
    if ((y < 8 || y > 200) || (x < 8 || x > 240))
    {
       DispString(0,0,(char *)"显示菜单时XY错误",0);
       if(debug)
         DispString(0,0,(char *)"DispPhoto画点时的边距参数错误",0);
       return 2;
    }
	if(type == 0)
        SetRect(&rc,x-8,y-8,x+ShowLen*8+8,y+24);
    else
        SetRect(&rc,x-8,y-8,x+strlen(row1)*8+8,y+40);
    if(mode == 1)  
    {
        FillRect(hdc,&rc,hbr); 
        SetTextColor(hdc,RGB(0,0,255));
		SetBkColor(hdc,RGB(255,0,0));
		if(type == 1)
           TextOut(hdc,relx,y+16,row2,strlen(row2));  //打印文字
        TextOut(hdc,relx,y,row1,strlen(row1));  //打印文字
		TextOut(hdc,relx,y,row1,strlen(row1));  //打印文字
		while ((GetMessagetemp(task1_tmq))->message == 0x00);
        //if(pMsg->message == TM_KEYOK)
			return 1;
	}
	else
	{
        FillRect(hdc,&rc,hbr2);  
        SetTextColor(hdc,RGB(0,0,255));
		SetBkColor(hdc,RGB(255,0,0));
		if(type == 1)
           TextOut(hdc,relx,y+16,row2,strlen(row2));  //打印文字
        TextOut(hdc,relx,y,row1,strlen(row1));  //打印文字
		TextOut(hdc,relx,y,row1,strlen(row1));  //打印文字
		OSTimeDly(OS_TICKS_PER_SEC); 
	}
	return 0;
}  

 //先画矩阵框,再显示字体
    /*ShowMatrix(startregionx,startregiony,endregionx,endregiony,backcolor);
    startregionx = x - (INT16U)((8 - ShowLen) / 2);  //汉字的起始点

⌨️ 快捷键说明

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