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

📄 wio.c.bak

📁 基于WinCE操作系统、SMDK2410硬件开发平台下的WIO
💻 BAK
📖 第 1 页 / 共 5 页
字号:
			}
			break;		
		case CLEAR:
			inputflg = 0;
			reng = 0;
			cx = x;
			memset(edit, 0x20, 26);
			strncpy(edit, paramlist, 24);
			memset(wok, 0x20, 4);
			wok[4] = 0x00;
			break;
	//	case NUM:			
		default:
			if(rtc == 0)
			{
				len = x - 4;
			}
			else
			{
				len = x - 2;
			}
			if(cx > len )
			{
				if(rdchr >= 0x30 && rdchr <= 0x39)
				{						
					wok[reng] = rdchr;
					state = atoi(wok);
					if((state < min || state > max) && (cx == len + 1))
					{
						wok[reng] = 0x20;
						Beep(3);							
					}
					else
					{
						reng = reng + 1;
						strncpy(&edit[cx], wok, reng);
						cx--;						
						inputflg = 1;							
					} 	
					break;
				}
			}
			else
			{
				Beep(3);
			}
		}/*switch end*/
		SetLine(y + 1);
		printX("%s", edit);
	}/*while end*/
	
	CrsrMake(0);
	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   AdInit                         */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*    ZhangJun                      */
/* Date:                            */
/*   2005.3.29                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int AdInit()
{
	InitPws();
	DspOn();
	KbdInit();
	CrsrInit();
	BeepInit();
	SleepInit();

	return 0;
}
/* -------------------------------- */
/* Function:                        */
/*   SleepSet                       */
/* Parameter:                       */
/*   int n                          */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*    ZhangJun                      */
/* Date:                            */
/*   2005.9.27                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int SleepSet(int n)
{
	g_time = n;
	ResetTimer();
	return 0;
}
/* -------------------------------- */
/* Function:                        */
/*   BackLightSet                   */
/* Parameter:                       */
/*   int n                          */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*    ZhangJun                      */
/* Date:                            */
/*   2005.9.27                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int BackLightSet(int n)
{
	g_bltime = n;
	ResetTimer();
	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   PowerSet                       */
/* Parameter:                       */
/*   int n                          */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*    ZhangJun                      */
/* Date:                            */
/*   2005.10.12                     */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int PowerSet(int n)
{
	int ch[2];
	int rtAPI;
	DWORD nRead = 0;

	ch[0] = n;

	rtAPI = WriteFile(hPower, ch, 1, &nRead, NULL);

	if (!rtAPI)
	{
		return -1;
	}

	return 0;
}
/* -------------------------------- */
/* Function:                        */
/*   ResetTimer                     */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*    ZhangJun                      */
/* Date:                            */
/*   2005.9.27                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int ResetTimer()
{
	EnterCriticalSection (&slSection);
	SleepTime = g_time;
	BackLightTime = g_bltime;
	LeaveCriticalSection (&slSection);

	return 0;
}
/* -------------------------------- */
/* Function:                        */
/*   WINAPI sThread                 */
/* Parameter:                       */
/*   PVOID pvoid                    */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*    ZhangJun                      */
/* Date:                            */
/*   2005.9.27                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
DWORD WINAPI sThread(PVOID pvoid)
{
	int ch[2];
	DWORD nRead = 0;

	ch[0] = 0;
	SleepTime = g_time;

	while(1)
	{
		Sleep(1000);
		if(BackLightTime>0 && backliteflg == 1)
		{
			BackLite(1);
			backliteflg = 0;
		}
		EnterCriticalSection (&slSection);
		
		if((BackLightTime==0) && (g_LiteStatus==1))//backlight sleep
		{
			BackLite(0);
			backliteflg = 1;
		}		
		if (SleepTime == 0)//sleep
		{
			ReadFile(hPower, ch, 1, &nRead, NULL);
			SleepTime = g_time;
		}

		if (SleepTime > 0)
		{
			SleepTime--;
		}
		if (BackLightTime > 0)
		{
			BackLightTime--;
		}
//		SetLine(0);
//		printX("SleepTime = %d,BLTime = %d", SleepTime,BackLightTime);

		LeaveCriticalSection (&slSection);
	}
}
/* -------------------------------- */
/* Function:                        */
/*   SleepInit                      */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*    ZhangJun                      */
/* Date:                            */
/*   2005.9.27                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int SleepInit()
{
	hPower = CreateFile(L"PTN2:", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

	if (hPower == INVALID_HANDLE_VALUE)
	{
		Beep(4);
		SetLine(0);
		printX("Error Open PTN Port!");
		return -1;
	}
	
	hSThread = CreateThread(NULL, 0, sThread, 0, 0, NULL);
	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   CloseSleep                     */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*    ZhangJun                      */
/* Date:                            */
/*   2005.9.27                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int CloseSleep()
{
	TerminateThread(hSThread, 1);

	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   CloseBeep                      */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*    ZhangJun                      */
/* Date:                            */
/*   2005.10.28                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int CloseBeep()
{
	TerminateThread(BeepThread, 1);

	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   cf_state                       */
/* Parameter:                       */
/*   int n                          */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*    ZhangJun                      */
/* Date:                            */
/*   2005.10.17                     */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int cf_state()
{
	WaitForSingleObject(hEvent, INFINITE);
	return g_cfstate;
}

/* -------------------------------- */
/* Function:                        */
/*   wake                           */
/* Parameter:                       */
/*   int n                          */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*    ZhangJun                      */
/* Date:                            */
/*   2005.11.3                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
/*int wake(int n)
{
	wake_flg = n;

	return 0;
}*/

/* -------------------------------- */
/* Function:                        */
/*   Ver_Wio                        */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   char                           */
/* Author:                          */
/*   ZhangJun                       */
/* Date:                            */
/*   2006.5.8                       */
/* Update:                          */
/*   2006.5.16                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
char *Ver_Wio()
{
	char *info;

	info = VERWIO;

	return info;
}
//test
/* -------------------------------- */
/* Function:                        */
/*   WINAPI CFcheck                 */
/* Parameter:                       */
/*   PVOID pvoid                    */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*    ZhangJun                      */
/* Date:                            */
/*   2006.5.17                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
DWORD WINAPI CFcheck(PVOID pvoid)
{
	int    ch[2];
	int    j = 1;
	int    iBeep = 1;

	HANDLE hCf;
	DWORD  nNumber = 0;
		
	hCf = CreateFile(TEXT("CFT1:"),
					 GENERIC_READ, 
					 0, 
					 NULL, 
					 OPEN_EXISTING, 
					 0, 
					 NULL);

	ch[0] = 0;
	ch[1] = 0x00;
	
	if (hCf == INVALID_HANDLE_VALUE)
	{
		Beep(4);
		SetLine(0);
		printX("Error Open CFT Port");
		return -1;
	}
	while (1)
	{
		Sleep(200);
		ReadFile(hCf, ch, 1, &nNumber, NULL);

//		SetLine(3);
//		printX("1case=%d",ch[0]);

		switch (ch[0])
		{
		case 0:
			if (iBeep == 1)
			{
//				Beep(5);
				iBeep = 0;
				SBar_Close();
			}
//			SetLine(0);
//			printX("CF Card Error!!!");*/
			
			cf_flg = 0;
			j = 0;		
			g_cfstate = 0;
			SetEvent(hEvent);
			break;
		case 1:
			cf_flg = 1;
			iBeep = 1;			
			if (j == 0)
			{
				Sleep(100);
				SBar_Open();
				j = 1;
				g_cfstate = 1;
				SetEvent(hEvent);
			}
			break;
		case 2:			
			PowerSet(0);
			cf_flg = 2;
			SBar_Close();
			iBeep = 1;
			Sleep(5500);
			ResetTimer();
			PowerSet(1);
			cf_flg = 1;
			SBar_Open();
			Beep(1);

			g_cfstate = 2;
			SetEvent(hEvent);

			break;
		default:
			break;
		}
	}
}

/* -------------------------------- */
/* Function:                        */
/*   CFcardInit                     */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   ZhangJun                       */
/* Date:                            */
/*   200.5.17                       */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int CFcardInit()
{
	hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
	hCfCard = CreateThread(NULL, 0, CFcheck, 0, 0, NULL);
	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   PowerInit                      */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   ZhangJun                       */
/* Date:                            */
/*   200.5.17                       */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int PowerInit()
{
	hPchk = CreateFile(TEXT("PCK1:"),
		GENERIC_READ,
		0, NULL, OPEN_EXISTING, 0, NULL);

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

	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   Power                          */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*   ZhangJun                       */
/* Date:                            */
/*   200.5.17                       */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
int Power()
{
	char    ch[2];
	DWORD   nNumber;

	int     i;

		ReadFile(hPchk, ch, 1, &nNumber, NULL);		
		i = ch[0];

		if (g_iPowerFlag == 0)
		{
			if (i == 7)
			{
				g_iPowerDsp = i;
			}
			else if ((i < 7) && (i > 2))
			{
				g_iPowerDsp = i + 1;
			}
			else if (i <= 2)
			{
				g_iPowerDsp = i;
			}
			g_iPowerFlag = 1;			
		}
		else if ((g_iPowerFlag == 1) || (g_iPowerFlag == 2))
		{
			if ((i > 2) && (i <= 7))
			{
				if (i < g_iPowerDsp)
				{
					g_iPowerTime++;
					if (g_iPowerTime == 2)
					{
						g_iPowerDsp = i;
					}
				}
				else if (i >= g_iPowerDsp)
				{
					g_iPowerTime = 0;
				}
			}
			else if (i <= 2)
			{
				if (g_iPowerFlag == 1)
				{
					if (i < g_iPowerDsp)
					{
						g_iPowerDsp = i;
						if (g_iPowerDsp < 0)
						{
							g_iPowerDsp = 0;
						}
					}
					g_iPowerFlag = 2;
				}
				else if (g_iPowerFlag == 2)
				{
//					Be

⌨️ 快捷键说明

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