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

📄 t_contractless.c

📁 RFID手持设备的读写代码,具有读RFID卡和进行数据管理的代码,同时还包含串口通讯的代码
💻 C
字号:
#include <stdio.h>
#include <stdlib.h>
#include <api.h>
#include <ExEH0218.h>
#include <contactless.h> 
#include "common.h" 

//Language option: LANG_CHN LANG_ENG
unsigned char	g_lang = LANG_CHN;	

/*
声音提示
参数	i	发声类型
i=1:	连续三声嘀嘀嘀
其它:	一声嘀
无返回值
*/
//beep
int warning_beep(int i)
{
	int count,j;
	if(i==1)
	{		
		for(count=0;count<3;count++)
		{	
			for(j=0;j<20;j++)
				BEEPER_sound(0xfF0B);
			delay_ms(200);
			BEEPER_sound(0x7F0B);	
			delay_ms(50);
		}		
	}
	else
	{	
		for(j=0;j<1000;j++)
				BEEPER_sound(0xfF0B);
		delay_ms(200);		
		BEEPER_sound(0x7F0B);
	}
}
/***************************************************
Refresh power icon if charger power plugged in
***************************************************/
void  dump_memory(unsigned char * buf,short int cnt,short line) 
{
      unsigned short cntr;
      unsigned char stmp[200];
      for (cntr = 0; cntr < cnt; cntr ++) {
		sprintf( stmp+2*cntr,"%02X", buf[cntr]);
	      }
      stmp[cnt*2] = 0;
      ClearLine(line,DISP_5x7);	 
      DispStr_E(0,line,stmp,DISP_POSITION|DISP_5x7);
}


//input block number
short input_block_num(unsigned short minnum,unsigned short maxnum,unsigned char *retno)
{
	GETSTR_PARAM 	gs;
	unsigned char 	str1[30];
	unsigned char 	tmpbuf[30];

	if(Get_Language()==LANG_CHN)
	{
		sprintf(str1,"块号(%d-%d)",minnum,maxnum);
	}
	else
	{
		sprintf(str1,"BlockNO(%d-%d)",minnum,maxnum);
	}
		
	clr_scr();
	sprintf(tmpbuf,"%d",*retno);
	gs.qx = 0;
	gs.qy = 0;
	gs.pPrompt = str1;
	gs.sFont = 0;
	gs.alpha = 0;
	gs.nullEnable = 0;
	gs.csChar = '_';
	gs.pwChar = 0;
	gs.spChar = 0;
	gs.pStr = tmpbuf;
	gs.maxNum = 3;
	gs.minNum = 1;
	gs.minValue = minnum;
	gs.maxValue = maxnum;
	gs.retNum = strlen(tmpbuf);
	gs.qEvent = EXIT_KEY_F1;
	if ( !huGetStr_E(&gs) )
	{
		*retno = gs.retValue;	//>=0
		return 0;
	}
	
	return -1;
}

//input card block content 
short input_block_content(unsigned char *inbuf)
{
	GETSTR_PARAM 	gs;
	unsigned char 	str1[30];
	unsigned char 	str2[30];
	unsigned char	str3[30];
	
	if(Get_Language()==LANG_CHN)
	{
		sprintf(str1,"块数值:");
		strcpy(str2,"按16进制输入");
		strcpy(str3,"8个数字");
	}
	else
	{
		sprintf(str1,"Value:");
		strcpy(str2,"input in hex");
		strcpy(str3,"8 characters");
	}
		
	clr_scr();
	DispStr_CE(0,4,str2,DISP_POSITION);
	DispStr_CE(0,6,str3,DISP_POSITION);
	gs.qx = 0;
	gs.qy = 0;
	gs.pPrompt = str1;
	gs.sFont = 0;
	gs.alpha = 0;
	gs.nullEnable = 0;
	gs.csChar = '_';
	gs.pwChar = 0;
	gs.spChar = 0;
	gs.pStr = inbuf;
	gs.maxNum = 8;
	gs.minNum = 8;
	gs.minValue = 0;
	gs.maxValue = -1;
	gs.retNum = 0;
	gs.qEvent = EXIT_KEY_F1;
	
	return huGetStr_E(&gs);
}

//input strings by ASCII
short input_block_content_ascii(unsigned char *inbuf)
{
	GETCSTR_PARAM 	G_gs;
	unsigned char 	str1[30];
	unsigned char 	str2[30];
	//unsigned char	str3[30];
	
#ifndef VER_ENG	
	sprintf(str1,"块数值:");
	strcpy(str2,"输入4字符");
	//strcpy(str3,"8个数字");
#else
	sprintf(str1,"Value:");
	strcpy(str2,"input 4 char");
	//strcpy(str3,"8 characters");
#endif
		
	clr_scr();
	DispStr_CE(0,4,str2,DISP_POSITION);
	//DispStr_CE(0,6,str3,DISP_POSITION);
		
	G_gs.qx = 0;
	G_gs.qy = 0;
	G_gs.line = 0;
//	G_gs.pPrompt = str1;		
	G_gs.defaultMode = 1;
	G_gs.eDisable = 0;		
	G_gs.nullEnable = 0;		
	G_gs.csChar = '_';
	G_gs.pStr = inbuf;		
	G_gs.maxNum = 4;
	G_gs.minNum = 4;
	G_gs.retNum = 0;
	G_gs.autoexit = 0;
	G_gs.qEvent = EXIT_KEY_F1;
	
	return huGetStr_CEX(&G_gs);
}

//Hex strings to ASCII strings 
short ASCIIHex2Char(unsigned char *databuf,unsigned char hexnum)
{
	unsigned char tmpbuf[256];
	unsigned char loopidx;
	
	memcpy(tmpbuf,databuf,hexnum);
	for(loopidx=0;loopidx<hexnum/2;loopidx++)
	{
		databuf[loopidx] = (tmpbuf[loopidx*2]-0x30)*16+(tmpbuf[loopidx*2+1]-0x30);
	}
	return 0;
}


short Set_Language(unsigned short lang)
{
	g_lang = lang;
}

//get the current language type
unsigned short	Get_Language(void)
{
	return g_lang;
}

//the menu for select the language
short Select_Language(void)
{
	SELE_INLINE	s_lan;
	int		ret;
	
	DispStr_CE(0,0,"请选择语言",DISP_CENTER|DISP_CLRSCR);
	DispStr_CE(0,2,"Select Language",DISP_CENTER);
	
	s_lan.count = 2;
	s_lan.line = 5;
	s_lan.enable46 = 1;
	s_lan.flagch = 0;
	s_lan.defsele = 0;
	s_lan.selepstr[0].xx = 18;
	s_lan.selepstr[1].xx = 60;
	strcpy(s_lan.selepstr[0].pstr,"中文");
	strcpy(s_lan.selepstr[1].pstr,"English");
	s_lan.qEvent = 0;
	
	ret = select_in_line(&s_lan);
	if(ret==0)
	{
		Set_Language(LANG_CHN);
	}
	else
	{
		Set_Language(LANG_ENG);
	}	
	
	return 0;	
}

⌨️ 快捷键说明

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