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

📄 wio.c

📁 基于WinCE操作系统、SMDK2410硬件开发平台下的WIO
💻 C
📖 第 1 页 / 共 5 页
字号:
		// Add WriteFile Function here
		for (i = 0, j = 2; i < nCount; i++, j++)
		{
			iDspCmd[j] = iDsp[k][i];
		}

		LeaveCriticalSection (&LinSection);
	
		for (i = nCount+2; i < 28; i++)
		{
			iDspCmd[i] = 0x4c;
		}

		iDspCmd[28] = 0xFF;

		WaitForSingleObject (hMutex,   // Handle of mutex object
                                      INFINITE);	
		rtAPI = WriteFile(hDspIns, iDspCmd, nCount+3, &nNumber, NULL);

		if (!rtAPI)
		{
			return -1;
		}

		ReleaseMutex(hMutex);
	}
				
	return 0;
}
/*int printX(const char *pszFormat,...)
{
	int i;
	int j;
	int nCount;

	DWORD nNumber;

	char szMsz[1024];
	wchar swzMsz[1024];
	
	wchar DispBuffer[120];

	int iDspCmd[100];

	int nflg = 0;

	va_list arg_ptr;
	
	for (i = 0; i < 120; i++)
	{
		DispBuffer[i] = 0x20;
	}
	
	va_start (arg_ptr, pszFormat);
	i = vsprintf(szMsz, pszFormat, arg_ptr);
	nCount = strlen(szMsz);

	wcsncpy(swzMsz, DispBuffer, 120);

	MultiByteToWideChar(CP_ACP, 0, szMsz, 
		nCount + 1, swzMsz, dim(swzMsz));

	for (i = 0; i < nCount; i++)
	{
		DispBuffer[i] = swzMsz[i];
	}
	
	EnterCriticalSection (&LinSection);

	for (i = 0; i < nCount; i++)
	{
		// Translate the code here
		iDsp[iDspLine][i] = CodeCharacter(DispBuffer[i]);
	}
	
	memset(iDspCmd, 0x00, 100);

	// Write Cmd
	iDspCmd[0] = 1;
	
	// Write Line Number
	iDspCmd[1] = iDspLine;
	// Add WriteFile Function here
	for (i = 0, j = 2; i < nCount; i++, j++)
	{
		iDspCmd[j] = iDsp[iDspLine][i];
	}

	LeaveCriticalSection (&LinSection);
	
	for (i = nCount+2; i < 28; i++)
	{
		iDspCmd[i] = 0x4c;
	}

	iDspCmd[28] = 0xFF;

	WaitForSingleObject (hMutex,   // Handle of mutex object
                                      INFINITE);	
	WriteFile(hDspIns, iDspCmd, nCount+3, &nNumber, NULL);
	ReleaseMutex(hMutex);
				
	return 0;
}*/

/* -------------------------------- */
/* Function:                        */
/*   PowerDsp                       */
/* Parameter:                       */
/*   int num                        */
/*                                  */
/* Return Value                     */
/*   int							*/
/*      0---- success               */
/*     -1---- failure               */
/* Author:                          */
/*   Yuan Kexin                     */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int PowerDsp(int num)
{
	int DspCmd[10];
	int rtAPI;
	DWORD nNumber;

	DspCmd[0] = 5;
	DspCmd[1] = num;
	DspCmd[2] = 0xff;

	WaitForSingleObject (hMutex, INFINITE);

	rtAPI = WriteFile(hDspIns,DspCmd, 2, &nNumber, NULL);

	if (!rtAPI)
	{
		return -1;
	}

	ReleaseMutex(hMutex);

	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   ReverseDsp                     */
/* Parameter:                       */
/*   int iPos     the Column        */
/*   int iLines   the Line          */
/*   int iNum     Number of Char    */
/* Return Value                     */
/*   int							*/
/*      0---- success               */
/*     -1---- failure               */
/* Author:                          */
/*   Yuan Kexin                     */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int ReverseDsp(int iPos, int iLines, int iNum)
{
	int iCmd[10];
	int rtAPI;
	DWORD nNumber = 0;

	iCmd[0] = 3;
	iCmd[1] = iPos;
	iCmd[2] = iLines;
	iCmd[3] = iNum;
	iCmd[4] = 0xFF;
	
	WaitForSingleObject (hMutex, INFINITE);

	rtAPI = WriteFile(hDspIns, iCmd, 5, &nNumber, NULL);

	if (!rtAPI)
	{
		return -1;
	}

	ReleaseMutex(hMutex);

	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   ReverseLine                    */
/* Parameter:                       */
/*   int iLines   the Line          */
/* Return Value                     */
/*   int							*/
/*      0---- success               */
/*     -1---- failure               */
/* Author:                          */
/*   Yuan Kexin                     */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int ReverseLine(int iLine)
{
	EnterCriticalSection (&rSection);
	Sleep(1);
	if ((iLine>=0) && (iLine<=3))
	{
		ReverseDsp(0, iLine, 26);
	}
	else
	{
		return -1;
	}
	Sleep(1);
	LeaveCriticalSection (&rSection);
	return 0;
}	

/* -------------------------------- */
/* Function:                        */
/*   DispCurPosCr                   */
/* Parameter:                       */
/*   int iPos     the Column        */
/*   int iLines   the Line          */
/*   int iNum     Number of Char    */
/* Return Value                     */
/*   int							*/
/*      0---- success               */
/*     -1---- failure               */
/* Author:                          */
/*   Yuan Kexin                     */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int DispCurPosCr(int iPos, int iLines, int iNum)
{
	int iCmd[10];
	int rtAPI;
	DWORD nNumber = 0;

	iCmd[0] = 4;
	iCmd[1] = iPos;
	iCmd[2] = iLines;
	iCmd[3] = iNum;
	iCmd[4] = 0xFF;

	WaitForSingleObject (hMutex, INFINITE);

	rtAPI = WriteFile(hDspIns, iCmd, 5, &nNumber, NULL);

	if (!rtAPI)
	{
		return -1;
	}

	ReleaseMutex(hMutex);

	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   WINAPI CThread                 */
/* Parameter:                       */
/*   PVOID pvoid                    */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   Yuan Kexin                     */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit:						*/
/*   2006.12.14			            */
/* By ZhangJun						*/
/* -------------------------------- */
DWORD WINAPI CThread(PVOID pvoid)
{
	int x;
	int y;
	int i;
	
	while (1)
	{
		
		if(Cursor.CurStatus == 1)
		{
			EnterCriticalSection (&rSection);

			x = Cursor.x;
			y = Cursor.y;
			
			ReverseDsp(x, y, 1);
			for (i = 0; i < 10; i++)
			{
				if(Cursor.CurStatus == 1)
				{
					Sleep(50);
				}
			}
//			Sleep(300);	

			DispCurPosCr(x, y, 1);
			for (i = 0; i < 10; i++)
			{
				if(Cursor.CurStatus == 1)
				{
					Sleep(50);
				}
			}
//			Sleep(300);

			LeaveCriticalSection (&rSection);
		}
		else
		{
			Sleep(1);
		}
		
	}
}

/* -------------------------------- */
/* Function:                        */
/*   CrsrInit                       */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   Yuan Kexin                     */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int CrsrInit()
{
	Cursor.hCThread  = CreateThread(NULL, 0, CThread, 0, 0, NULL);
	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   CloseCrsr                      */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   Yuan Kexin                     */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int EndCrsr()
{
	TerminateThread(Cursor.hCThread, 1);
	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   CrsrMake                       */
/* Parameter:                       */
/*   int type                       */
/*       0----  off                 */
/*		 1----  on                  */
/* Return Value                     */
/*   int							*/
/*      0---- success               */
/*     -1---- failure               */
/* Author:                          */
/*   Yuan Kexin                     */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int CrsrMake(int type)
{
	if (type == 0) /* hide the Cursor */
	{
		if (Cursor.CurStatus == 0) /* the cursor is already been off */
		{
			return 0; /* do nothing */
		}

		if (Cursor.CurStatus == 1) /* the cursor need to be hiden */
		{
			Cursor.CurStatus = 0;
			return 0;
		}
		return -1;
	}

	if (type == 1) /* show the Cursor */
	{
		if (Cursor.CurStatus == 1)
		{
			return 0;
		}

		if (Cursor.CurStatus == 0)
		{
			Cursor.CurStatus = 1;					
			/* return */
			return 0;
		}
		return -1;
	}
	return -1;
}

/* -------------------------------- */
/* Function:                        */
/*   CrsrPut                        */
/* Parameter:                       */
/*   int xPos(0  -> 25)             */
/*   int yPos(-1 -> 2 )             */
/* Return Value                     */
/*   int							*/
/*      0---- success               */
/*     -1---- failure               */
/* Author:                          */
/*   Yuan Kexin                     */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int CrsrPut(int xPos, int yPos)
{
	int nflg = 0;

	if ((xPos < 0) || (xPos > 25) || (-1 > yPos) || (2 < yPos))
	{
		return -1;
	}

	/* if the Cursor is on */
	if (Cursor.CurStatus == 1)
	{
		CrsrMake(0);
		nflg = 1;
		DispCurPosCr(xPos, yPos, 1);
	}

	Cursor.x = xPos;
	Cursor.y = yPos + 1 ;

	if (nflg == 1)
	{
		CrsrMake(1);
	}
	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   Delay                          */
/* Parameter:                       */
/*   int i                          */
/*       the number of millisecond  */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   Yuan Kexin                     */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int Delay(int i)
{
	Sleep(10 * i);
	return 0;
}

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

	g_hPms = CreateFile(L"PMS1:", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
	BackLite(0);

	if (g_hPms == INVALID_HANDLE_VALUE)
	{
		Beep(4);
		SetLine(0);
		printX("Error Open PMS Port!");
		return -1;
	}
	
	rtAPI = WriteFile(g_hPms, szLiteOn, 3, &nByte, NULL);

	if (!rtAPI)
	{
		return -1;
	}

	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   ClosePws                       */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   Yuan Kexin                     */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int ClosePms()
{
	CloseHandle(g_hPms);
	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   WINAPI bThread                 */
/* Parameter:                       */
/*   PVOID pvoid                    */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   ZhangJun                       */
/* Date:                            */
/*   2005.7.25                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
/*DWORD WINAPI bThread(PVOID pvoid)
{
	int i;
	DWORD nByte = 0;
	char pszSetOn[]  = "SetSpeakerOn";
	char pszSetOff[] = "SetSpeakerOff";

	while(1)
	{		
		if(g_bpflg > 0)
		{
			for(i = 0; i<g_bpflg; i++)
			{
				WriteFile(g_hPms, pszSetOn, dim(pszSetOn), &nByte, NULL);
				Sleep(temp[i]);
				WriteFile(g_hPms, pszSetOff, dim(pszSetOff), &nByte, NULL);
				Sleep(70);	
			}
			g_bpflg = 0;
			memset(temp, 0x20, 1000);
		}
		else
		{
			Sleep(1);
		}						
	}//end while

}*/
DWORD WINAPI bThread(PVOID pvoid)
{
	int i;
	int j;
	DWORD nByte = 0;
//	char pszSetOn[]  = "SetSpeakerOn";
//	char pszSetOff[] = "SetSpeakerOff";
	int pszSet[5];
	pszSet[0] = 3;
	pszSet[3] = 0x00;

	while(1)
	{	
		if(g_bpflg > 0)

⌨️ 快捷键说明

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