verv1.h

来自「finger print based security system」· C头文件 代码 · 共 117 行

H
117
字号
/*******************************************************************************************
	Module     :	UtilV1  -- Utilities Module .
	Version    :	1.0
	Author     :	K. KARTHIKEYAN , S.R.Labs, Hyd.,India.
			All rights reserved with the author.
	
	Description:    This module is to handle general utilities.
			Any miscallaneous modules can be added in this header.
*******************************************************************************************/
# include <8052.h>

# ifndef __UTIL_V1__
# define __UTIL_V1__

/* ***************************************************************************Prototypes* */
void DisplayVersion();
void ToAsciiDecimal(unsigned char ucValue, unsigned char *ucAscii);
void ToAsciiHex(unsigned char ucValue, unsigned char *ucAscii);

/* ************************************************************************************** */
void DisplayVersion()
{
	LcdInit();
	LcdPuts("FingrPrint based");
	LcdCmd(NEW_LINE);	
	LcdPuts("Access Control.");
}
/* ************************************************************************************** */
void ToAsciiDecimal(unsigned char ucValue, unsigned char *ucAscii)
{
	unsigned char ucNum,ucRem;
	unsigned char ucCounter = 0,ucTemp1 = 0,ucTemp2 = 0;
	unsigned char ucResult[6];
	
	ucNum = ucValue;
	while(ucNum > 0)
	{
		ucRem = ucNum % 10;
		ucNum = ucNum / 10;
		ucResult[ucCounter] = ucRem;
		ucResult[ucCounter] = ucResult[ucCounter] + '0';
		ucCounter++;
	}
	
	ucTemp2 = ucCounter-1;
	for(ucTemp1 = 0; ucTemp1 < ucCounter; ucTemp1++,ucTemp2--)
	{
		*(ucAscii + ucTemp2) = ucResult[ucTemp1];
	}
	*(ucAscii + ucTemp1) = 0;
}

/* ************************************************************************************** */
void ToAsciiHex(unsigned char ucValue, unsigned char *ucAscii)
{
	unsigned char ch1,ch2;

	ucAscii[0] = '0';
	ucAscii[1] = 'X';
	
	ch1 = ((ucValue & 0xf0) >> 4);

	switch(ch1)
	{
		case 0x0a:
			 ucAscii[2] = 'A';
			 break;
		case 0x0b:
			 ucAscii[2] = 'B';		
			break;
		case 0x0c:
		        ucAscii[2] = 'C';		
			break;
		case 0x0d:
			ucAscii[2] = 'D';		
			break;
		case 0x0e:
			ucAscii[2] = 'E';		
			break;
		case 0x0f:
		 	ucAscii[2] = 'F';		
			break;
		default:
		        ucAscii[2] = (ch1 + '0');		
			break;
	}

	ch2 = (ucValue & 0x0f);
	switch(ch2)
	{
		case 0x0a:
		        ucAscii[3] = 'A';
			 break;
		case 0x0b:
		        ucAscii[3] = 'B';		
			break;
		case 0x0c:
		        ucAscii[3] = 'C';		
			break;
		case 0x0d:
		        ucAscii[3] = 'D';		
			break;
		case 0x0e:
		        ucAscii[3] = 'E';		
			break;
		case 0x0f:
		        ucAscii[3] = 'F';		
			break;
		default:
		        ucAscii[3] = (ch2 + '0');		
			break;
	}
}

/* ************************************************************************************** */
# endif

⌨️ 快捷键说明

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