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

📄 wio.c

📁 基于WinCE操作系统、SMDK2410硬件开发平台下的WIO
💻 C
📖 第 1 页 / 共 5 页
字号:
	SysTime.wMinute   = (*time).minute;
	SysTime.wSecond   = (*time).second;

	SetSystemTime(&SysTime);

	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   EnterInteger                   */
/* Parameter:                       */
/*   int x       column position    */
/*   int y       row position       */
/*   int min                        */
/*          the minimum accepted    */
/*   int max                        */
/*          the maximum accepted
/*   int *value                     */
/*          integer value to edit   */
/*          or enter( >0 )          */
/*   char paramlist[]               */
/*       parameter list for entry   */
/* Return Value                     */
/*   int							*/
/*      0---- success               */
/*     -1---- failure               */
/* Author:                          */
/*   Zhang Jun                      */
/* Date:                            */
/*   2005.7.13                      */
/* Last Edit:						*/
/*	 2006.12.13			            */
/* -------------------------------- */
#define ESC		0x74
#define RETURN	0x0d
#define LEFT	0x7d
#define	CLEAR	0x73
/*int EnterInteger(int x, int y, int min, int max, int *value, char paramlist[])

{   
	int  cx;	
	int  rtc;
	int  len;
	int  loop;
	int  reng;
	int  state;
	int  inputflg;
	char edit[26];
	char wok[4];
	char rdchr;

	inputflg = 0;
	reng  =0;
	loop = 0;
	*value = 0;

	memset(edit, 0x20, 26);
	edit[25] = 0x00;
	strncpy(edit, paramlist, 24);
	memset(wok, 0x20, 4);
	wok[4] = 0x00;

//	rtc = strncmp(paramlist, "  Year = [    ]         ",24);

	if (min > 999)
	{
		rtc = 0;
	}
	
	cx = x;

	CrsrPut(x, y);
	CrsrMake(1);

	while(loop == 0)
	{
		rdchr = KbdRead();
		switch (rdchr)
		{
		case ESC:
			CrsrMake(0);
			return 0;
			break;
		case RETURN:
			if(inputflg == 0)
			{
				Beep(3);
			}
			else
			{
				strncpy(wok, &edit[x-reng+1], reng);

				if(reng!=0 && reng >= 1)
				{ 
					state = atoi(wok);

					if(state >= min && state <= max)
					{
						*value = state;	
						loop=1;
					}
					else
					{
						Beep(3);
					}
				}
			}
			break;		
		case LEFT:
			if(cx < x)
			{
				reng = reng - 1;
				wok[reng] = 0x20;
				cx++;
				memset(edit, 0x20, 26);
				strncpy(edit, paramlist, 24);
				strncpy(&edit[cx+1], wok, reng); 
			}
			else
			{
				Beep(3);
			}
			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;
}*/
int EnterInteger(int x, int y, int min, int max, int *value, char paramlist[])

{   
	int  cx;	
	int  len;
	int  loop;
	int  reng;
	int  state;
	int  ilength;
	int  inputflg;
	char edit[26];
	char wok[10];
	char rdchr;
	char buffer[20];

	inputflg = 0;
	reng  =0;
	loop = 0;
	*value = 0;

	if ((min < 0) || (max < 0) || (max < min))
	{
		return -1;
	}

	memset(edit, 0x20, 26);
	edit[25] = 0x00;
	strncpy(edit, paramlist, 24);
	memset(wok, 0x00, 10);

	
	cx = x;

	CrsrPut(x, y);
	CrsrMake(1);

	memset(buffer, 0x00, 20);
	_itoa (max, buffer, 10);

	ilength = strlen(buffer);

	while(loop == 0)
	{
		rdchr = KbdRead();
		switch (rdchr)
		{
		case ESC:
			CrsrMake(0);
			return 0;
			break;
		case RETURN:
			if(inputflg == 0)
			{
				Beep(3);
			}
			else
			{
				strncpy(wok, &edit[x-reng+1], reng);

				if(reng!=0 && reng >= 1)
				{ 
					state = atoi(wok);

					if(state >= min && state <= max)
					{
						*value = state;	
						loop=1;
					}
					else
					{
						Beep(3);
					}
				}
			}
			break;		
		case LEFT:
			if(cx < x)
			{
				reng = reng - 1;
				wok[reng] = 0x20;
				cx++;
				memset(edit, 0x20, 26);
				strncpy(edit, paramlist, 24);
				strncpy(&edit[cx+1], wok, reng); 
			}
			else
			{
				Beep(3);
			}
			break;		
		case CLEAR:
			if (inputflg == 0)
			{
				Beep(3);
			}
			else
			{
				inputflg = 0;
				reng = 0;
				cx = x;
				memset(edit, 0x20, 26);
				strncpy(edit, paramlist, 24);
				memset(wok, 0x00, 10);
			}
			break;
	//	case NUM:			
		default:

			len = x - ilength;

			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);
				}
			}
			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()
{
	PmsInit();
	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)
int BLsleepSet(int n)
{
	g_bltime = n;
	ResetTimer();
	return 0;
}

/* -------------------------------- */
/* Function:                        */
/*   PowerSet                       */
/* Parameter:                       */
/*   int n                          */
/* Return Value                     */
/*   int							*/
/*      0---- success               */
/*     -1---- failure               */
/* 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; // 0: Limit  1: Allow

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

	if (!rtAPI)
	{
		SetLine(3);
		printX("PowerSet error!");
		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];
	int rtAPI;
	DWORD nNumber = 0;

	ch[0] = 2;
	ch[1] = 0x00;
	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
		{
			rtAPI = ReadFile(hPower, ch, 1, &nNumber, NULL);
//			rtAPI = WriteFile(hPower, ch, 1,&nNumber, NULL);

/*			if (!rtAPI)
			{
				Beep(4);
				SetLine(0);
				printX("POWER DOWN ERROR!!!");
			}*/

			SleepTime = g_time;
		}

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

		LeaveCriticalSection (&slSection);
	}
}
/* -------------------------------- */
/* Function:                        */
/*   WINAPI PtnCheck                */
/* Parameter:                       */
/*   PVOID pvoid                    */
/* Return Value                     */
/*   int                            */
/* Author:                          */
/*    ZhangJun                      */
/* Date:                            */
/*   2006.8.15                      */
/* Last Edit By  Zhang Jun          */
/* -------------------------------- */
/*DWORD WINAPI PtnCheck(PVOID pvoid)
{
	int sflg = 0;
	int ch[2];
	int pwrd[2];
	int rtAPI;
	DWORD nRead = 0;
	DWORD nNumber = 0;

	ch[0] = 0;
	ch[1] = 0x00;
	pwrd[0] = 2; 
	pwrd[1] = 0x00;

	while(1)
	{

		ReadFile(hPower, ch, 1, &nRead, NULL);

		switch (ch[0])
		{
		case 0:		//Power Up
			if (cf_flg == 1)
			{
				PowerSet(0);

				if (sbar_flg == 1)
				{
//					sbar_off();
					sflg = 1;
				}
				Sleep(5500);
				ResetTimer();
				PowerSet(1);
				if (sflg == 1)
				{
//					sbar_init();
					sflg = 0;
				}
				Beep(1);
			}
			break;
		case 1:		//Power Down
			
			rtAPI = WriteFile(hPower, pwrd, 1,&nNumber, NULL);
			
			if (!rtAPI)
			{
				Beep(4);
				SetLine(0);
				printX("POWER DOWN ERROR!!!");
			}
			break;
		default:			
			break;
		}
	}

	return 0;
}*/

/* -------------------------------- */
/* Function:                        */
/*   PtnpInit                       */
/* Parameter:                       */
/*   NULL                           */
/* Return Value                     */
/*   int							*/
/*      0---- success               */
/*     -1---- failure               */
/* Author:                          */
/*    ZhangJun                      */
/* Date

⌨️ 快捷键说明

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