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

📄 wio.c

📁 基于WinCE操作系统、SMDK2410硬件开发平台下的WIO
💻 C
📖 第 1 页 / 共 5 页
字号:
		{
			for(i = 0; i<g_bpflg; i++)
			{
				beep_flg = temp[i] - 1;
				pszSet[1] = beep_horl[beep_flg];
				pszSet[2] = beep_time[beep_flg];
				for (j=0; j<beep_retimes[beep_flg]; j++)
				{
					WriteFile(g_hPms, pszSet, 3, &nByte, NULL);
					Sleep(beep_spacetime[beep_flg]);	
				}
			}
			g_bpflg = 0;
			memset(temp, 0x20, 1000);
		}
		else
		{
			Sleep(1);
		}						
	}//end while

}
/* -------------------------------- */
/* Function:                        */
/*   nBeepSet                       */
/* Parameter:                       */
/*   int n                          */
/*         the flag of Beep			*/
/*   int retimes                    */
/*         The number of repetitions*/ 
/*   int horl                       */
/*         high or low Beep         */
/*   int beeptime                   */
/*         the time of Beep         */
/*   int spacetime                  */
/*         The interval of time between two beeps
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   ZhangJun                       */
/* Date:                            */
/*   2005.9.27                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
nBeepSet(int n, int retimes, int horl, int beeptime, int spacetime)
{
	n = n - 1;
	beep_retimes[n]  = retimes;
	beep_horl[n]     = horl;
	beep_time[n] = beeptime;
	beep_spacetime[n]= spacetime*10;

	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   BeepInit                       */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   ZhangJun                       */
/* Date:                            */
/*   2005.7.25                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int BeepInit()
{
	BeepThread = CreateThread(NULL, 0, bThread, 0, 0, NULL);
	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   Beep                           */
/* Parameter:                       */
/*   int nTimes                     */
/*       the times 0f 25 millisecond*/
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   Yuan Kexin                     */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int Beep(int nTimes)
{	
//	n_flg = nTimes - 1;
//	nTimes = nTimes * 25;
	temp[g_bpflg] = nTimes;
	g_bpflg++;
	if(g_bpflg > 10)
	{
		g_bpflg = 0;
	}
	
	return 0;
}
/*int Beep(int nTimes)
{
	DWORD nByte = 0;
	char pszSetOn[] = "SetSpeakerOn";
	char pszSetOff[] = "SetSpeakerOff";
	nTimes = nTimes * 20;

	WriteFile(g_hPms, pszSetOn, dim(pszSetOn), &nByte, NULL);
	Sleep(nTimes);
	WriteFile(g_hPms, pszSetOff, dim(pszSetOff), &nByte, NULL);
	Sleep(50);
	
	return 0;
}*/

/* -------------------------------- */
/* Function:                        */
/*   SBar_Open                      */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   Yuan Kexin                     */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
/*int SBar_Open()
{
	DWORD nByte = 0;
//	char pszOpen[] = "SetUARTOn";
	int pszOpen[5];
	int rtAPI;
	pszOpen[0] = 2;
	pszOpen[1] = 0;
	pszOpen[2] = 1;
	pszOpen[3] = 0x00;

	rtAPI = WriteFile(g_hPms, pszOpen, 3, &nByte, NULL);

	if (!rtAPI)
	{
		return -1;
	}

	return 0;
}*/

/* -------------------------------- */
/* Function:                        */
/*   SBar_Close                     */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   Yuan Kexin                     */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
/*int SBar_Close()
{
	DWORD nByte = 0;
//	char pszClose[] = "SetUARTOff";
	int pszClose[5];
	int rtAPI;
	pszClose[0] = 2;
	pszClose[1] = 0;
	pszClose[2] = 0;
	pszClose[3] = 0x00;

	rtAPI = WriteFile(g_hPms, pszClose, 3, &nByte, NULL);

	if (!rtAPI)
	{
		return -1;
	}

	return 0;
}*/

/* -------------------------------- */
/* Function:                        */
/*   Sbar_init                      */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   Zhang Jun                      */
/* Date:                            */
/*   2006.8.15                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
/*int sbar_init()
{
	int ch[2];
	int rtAPI;
	DWORD nByte = 0;

	ch[0] = 1;  // 1: Open Bar
	ch[1] = 0x00;
	
	hBar = CreateFile(TEXT("BAR1:"), GENERIC_READ | GENERIC_WRITE, 0, NULL,
		OPEN_EXISTING, 0, NULL);

	if (hBar == INVALID_HANDLE_VALUE)
	{
		Beep(4);
		SetLine(0);
		printX("Error Open Bar Port!");
		return -1;
	}

	rtAPI = WriteFile(hBar, ch, 1, &nByte, NULL);

	if (!rtAPI)
	{
		return -1;
	}
	sbar_flg = 1;

	return 0;

}*/

/* -------------------------------- */
/* Function:                        */
/*   Sbar_off                       */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   Zhang Jun                      */
/* Date:                            */
/*   2006.8.15                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
/*int sbar_off()
{
	int ch[2];
	int rtAPI;
	DWORD nByte = 0;

	ch[0] = 0; // 0: Close Bar
	ch[1] = 0x00;

	rtAPI = WriteFile(hBar, ch, 1, &nByte, NULL);

	if (!rtAPI)
	{
		return -1;
	}
	sbar_flg = 0;

	return 0;
}*/

/* -------------------------------- */
/* Function:                        */
/*   BLiteAllow                     */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   ZhangJun                       */
/* Date:                            */
/*   2005.9.21                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
/*int BLiteAllow()
{
	DWORD nByte = 0;
//	char pszAllow[] = "SetLightAllow";
	int pszAllow[5];
	int rtAPI;
	pszAllow[0] = 1;
	pszAllow[1] = 1;
	pszAllow[2] = 1;
	pszAllow[3] = 0x00;

	rtAPI = WriteFile(g_hPms, pszAllow, 3, &nByte, NULL);

	if (!rtAPI)
	{
		return -1;
	}

	return 0;
}*/


/* -------------------------------- */
/* Function:                        */
/*   BackLightSet                   */
/* Parameter:                       */
/*   int  n							*/
/*		  1--Allow                  */  
/*		  0--Limit                  */
/* Return Value                     */
/*   int							*/
/*      0---- success               */
/*     -1---- failure               */
/* Author:                          */
/*   ZhangJun                       */
/* Date:                            */
/*   2006.8.17                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int BackLightSet(int n) //1: Allow 0: Limit
{
	DWORD nByte = 0;
	int rtAPI;
	int pszAllow[5];
	int pszLimit[5];
	pszAllow[0] = pszLimit[0] = 1;
	pszAllow[1] = pszLimit[1] = 1;
	pszAllow[2] = 1;
	pszLimit[2] = 0;
	pszAllow[3] = pszLimit[3] = 0x00;

	if (n == 1)
	{
		rtAPI = WriteFile(g_hPms, pszAllow, 3, &nByte, NULL);

		if (!rtAPI)
		{
			return -1;
		}
	}
	else if (n == 0)
	{
		rtAPI = WriteFile(g_hPms, pszLimit, 3, &nByte, NULL);

		if (!rtAPI)
		{
			return -1;
		}
	}
	else
	{
		return -1;
	}

	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   BLiteLimit                     */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   ZhangJun                       */
/* Date:                            */
/*   2005.9.21                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
/*int BLiteLimit()
{
	DWORD nByte = 0;
//	char pszLimit[] = "SetLightLimit";
	int pszLimit[5];
	int rtAPI;
	pszLimit[0] = 1;
	pszLimit[1] = 1;
	pszLimit[2] = 0;
	pszLimit[3] = 0x00;

	rtAPI = WriteFile(g_hPms, pszLimit, 3, &nByte, NULL);

	if (!rtAPI)
	{
		return -1;
	}

	return 0;
}*/

/* -------------------------------- */
/* Function:                        */
/*   BackLite                       */
/* Parameter:                       */
/*   int nStatus                    */
/*		 1----  on                  */
/*       0----  off                 */
/* Return Value                     */
/*   int							*/
/*      0---- success               */
/*     -1---- failure               */
/* Author:                          */
/*   Yuan Kexin                     */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int BackLite(int nStatus)
{
	DWORD nByte = 0;
//	char pszLiteOn[]  = "SetBackLightOn";
//	char pszLiteOff[] = "SetBackLightOff";
	int pszLiteOn[5];
	int pszLiteOff[5];
	int rtAPI;
	pszLiteOn[0] = 1;
	pszLiteOn[1] = 0;
	pszLiteOn[2] = 1;
	pszLiteOn[3] = 0x00;
	pszLiteOff[0] = 1;
	pszLiteOff[1] = 0;
	pszLiteOff[2] = 0;
	pszLiteOff[3] = 0x00;

	if (nStatus == 1)
	{
		if (g_LiteStatus == 0)
		{
			rtAPI = WriteFile(g_hPms, pszLiteOn, 3, &nByte, NULL);

			if (!rtAPI)
			{
				return -1;
			}
			g_LiteStatus = 1;
		}
		return 0;
	}
	if (nStatus == 0)
	{
		if (g_LiteStatus == 1)
		{
			rtAPI = WriteFile(g_hPms, pszLiteOff, 3, &nByte, NULL);

			if (!rtAPI)
			{
				return -1;
			}

			g_LiteStatus = 0;
		}
		backliteflg = 0;
		return 0;
	}
	return -1;
}

/* -------------------------------- */
/* Function:                        */
/*   DispClr                        */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   int							*/
/*      0---- success               */
/*     -1---- failure               */
/* Author:                          */
/*   Yuan Kexin                     */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int DispClr()
{
	int cmd[2];
	int rtAPI;
	DWORD num = 0;
	
	cmd[0] = 2;
	cmd[1] = 0;

	WaitForSingleObject (hMutex, INFINITE);

    rtAPI = WriteFile(hDspIns, cmd, 2, &num, NULL);

	if (!rtAPI)
	{
		return -1;
	}

	ReleaseMutex(hMutex);
		
	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   DateGet                        */
/* Parameter:                       */
/*   AD1DATE *date                  */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   Yuan Kexin                     */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int DateGet(AD1DATE *date)
{
	SYSTEMTIME  SysTime;

	GetSystemTime(&SysTime);
	
	(*date).year      = SysTime.wYear;
	(*date).month     = SysTime.wMonth;
	(*date).dayofweek = SysTime.wDayOfWeek;
	(*date).day       = SysTime.wDay;
	
	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   TimeGet                        */
/* Parameter:                       */
/*   AD1DATE *time                  */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   Yuan Kexin                     */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int TimeGet(AD1TIME *time)
{
	SYSTEMTIME  SysTime;

	GetSystemTime(&SysTime);

	(*time).hour     = SysTime.wHour;
	(*time).minute   = SysTime.wMinute;	
	(*time).second   = SysTime.wSecond;
	(*time).centisec = SysTime.wMilliseconds;
	
	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   DateSet                        */
/* Parameter:                       */
/*   AD1DATE *date                  */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   Yuan Kexin                     */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int DateSet(AD1DATE *date)
{

	SYSTEMTIME  SysTime;

	GetSystemTime(&SysTime);

	SysTime.wYear     = (*date).year;
	SysTime.wMonth    = (*date).month;
	SysTime.wDay      = (*date).day;

	SetSystemTime(&SysTime);

	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   TimeSet                        */
/* Parameter:                       */
/*   AD1DATE *time                  */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   Yuan Kexin                     */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int TimeSet(AD1TIME *time)
{
    SYSTEMTIME  SysTime;	

	GetSystemTime(&SysTime);

	SysTime.wYear     = SysTime.wYear;
	SysTime.wMonth	  = SysTime.wMonth;
	SysTime.wDay	  = SysTime.wDay;

	SysTime.wHour     = (*time).hour;

⌨️ 快捷键说明

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