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

📄 rfid_timingmenu.c

📁 找的一个用U2270B开发的射频卡项目文件
💻 C
📖 第 1 页 / 共 2 页
字号:
// $Id: rfid_TimingMenu.c,v 1.6 2007/01/24 21:44:15 tprescott Exp $
/*************************************************************
Project : rfid_TimingMenu.c
Date    : 9/08/2006
Author  : Toby Prescott                   
Company : Atmel                           
Comments: AVR Studio GCC

Revisions: 
	v1.0 - Started
	v2.1 - 1/20/06 Changed to work with new LCD drive
	v2.2 - 3/8/06 Changed to Flash Srings to save SRAM
	v2.3 - 3/14/06 Fixing 5558 read/write routines
	       3/15/06 Adding 5530 Support  
	v2.4 - 4/6/06  Add new working 5558 R/W routines
	       5/19/06 Fixed mfg. ID error and display as dec
	v2.5 - 6/20/06 Add Animal ID section with Read and Write
	v2.6 - 9/19/06 Clean for WinAVR
*************************************************************/

#include "rfid_TimingMenu.h" 

// Declare your global variables here

static const char sRFIDTAG1[] PROGMEM = "x5530";
static const char sRFIDTAG2[] PROGMEM = "x5551";
static const char sRFIDTAG3[] PROGMEM = "x5552";
static const char sRFIDTAG4[] PROGMEM = "x5557";
static const char sRFIDTAG5[] PROGMEM = "x5567";
static const char sRFIDTAG6[] PROGMEM = "x5577";
static const char sRFIDTAG7[] PROGMEM = "x5570";
static const char sRFIDTAG8[] PROGMEM = "x5558"; 
static PGM_P sRFIDTAGPtr[8] = {sRFIDTAG1,sRFIDTAG2,sRFIDTAG3,sRFIDTAG4,sRFIDTAG5,sRFIDTAG6,sRFIDTAG7,sRFIDTAG8};
 
static unsigned char currentPos, nextPos=0;

// *******************************************************************************
// Menu that lists the Tag Timing Choices available
// ******************************************************************************/
#define SGAP_FIELD	1
#define GAP_FIELD	2
#define WONE_FIELD	3 
#define WZERO_FIELD	4
#define REF_FIELD	5

#define RSHORT		1
#define RSHORTL_FIELD	2
#define RSHORTH_FIELD	3
#define RLONG		4
#define RLONGL_FIELD	5
#define RLONGH_FIELD	6
#define TERM		7
#define TERML_FIELD	8
#define TERMH_FIELD	9

void rfidTimingMenu_Configure(unsigned char Target_Tag, unsigned char Target_Reader)
{
    nextPos = 0;
    upDate = 0;

	uio_Release();
	while(cButton != IO_F1 && cButton != IO_F2 && cButton != IO_F3 && cButton != IO_F4)
	{                                             
        // Menu Display 
		if(currentPos != nextPos || upDate == 0)
		{
			currentPos = nextPos;
			lcd_clear_area(SCRN_LEFT+1,SCRN_TOP+1,SCRN_RIGHT-1,SCRN_BOTTOM-1);
				
			if(Target_Tag == 30){lcd_put_fString(4, 2, sRFIDTAGPtr[0]);}
			else if(Target_Tag == 51){lcd_put_fString(4, 2, sRFIDTAGPtr[1]);}
			else if(Target_Tag == 52){lcd_put_fString(4, 2, sRFIDTAGPtr[2]);}
			else if(Target_Tag == 57){lcd_put_fString(4, 2, sRFIDTAGPtr[3]);}
			else if(Target_Tag == 67){lcd_put_fString(4, 2, sRFIDTAGPtr[4]);}
			else if(Target_Tag == 77){lcd_put_fString(4, 2, sRFIDTAGPtr[5]);}
			else if(Target_Tag == 70){lcd_put_fString(4, 2, sRFIDTAGPtr[6]);}
			else if(Target_Tag == 58){lcd_put_fString(4, 2, sRFIDTAGPtr[7]);}	 		
			
			lcd_put_fString(32, 2, PSTR(" Timing Options"));
			lcd_box(SCRN_LEFT,10,SCRN_RIGHT,22);
	 		lcd_vert_line(10,21,63);
	 		lcd_put_fString(lcd_fcenter(PSTR("Write"))-31, 13, PSTR("Write"));
	 		lcd_put_fString(lcd_fcenter(PSTR("Read"))+31, 13, PSTR("Read"));
			
			lcd_invert_area((3+(currentPos*63)), 12, (60+(currentPos*63)), 20);
			lcd_update(SCRN_TOP,SCRN_BOTTOM);
			upDate = 1; 
		}
		// end display  
	    
		uio_Get();    
        switch(currentPos){
		case 0:
            if(cButton == IO_ENTER || cButton == IO_DOWN)
            {
            	if(Target_Tag != 30){rfidTimingMenu_WriteTiming(Target_Tag, Target_Reader);}
            	nextPos = 0;
				upDate = 0;
            }
            else if(cButton == IO_UP){;}
            else if(cButton == IO_RIGHT){nextPos = 1;}
			break;
		case 1:
            if(cButton == IO_ENTER || cButton == IO_DOWN)
            {
				rfidTimingMenu_ReadTiming(Target_Tag, Target_Reader);
            	nextPos = 1;
				upDate = 0;
            }
            else if(cButton == IO_LEFT){nextPos = 0;}
            else if(cButton == IO_RIGHT){;}
			break;
		default:
			break;
		}
        if(cButton>0 && cButton<6){uio_Release();}
	}
    uio_Release();
}

// *******************************************************************************
// Tag timings specific to the Write mode
// ******************************************************************************/
void rfidTimingMenu_WriteTiming(unsigned char Target_Tag, unsigned char Target_Reader)
{        
	unsigned char *cString9 = "   "; 
	
    //**** Create Temp Timing Vars ****//
    unsigned int iSGap=0;
    unsigned int iGap=0;
    unsigned int iWZero=0;
    unsigned int iWOne=0;
    unsigned int iRef=0;
    
    nextPos = SGAP_FIELD;
    upDate = 0;

	//**** Read in the appropriate Saved Tag Timing Vars ****//
    if(Target_Tag == 51)
    {
        iSGap = x5551_Get_SGap();
        iGap = x5551_Get_Gap();
        iWZero = x5551_Get_Zero();
        iWOne = x5551_Get_One();
	}
    else if(Target_Tag == 57)
    {
        iSGap = x5557_Get_SGap();
        iGap = x5557_Get_Gap();
        iWZero = x5557_Get_Zero();
        iWOne = x5557_Get_One();
	}
	else if(Target_Tag == 67)
	{
        iSGap = x5567_Get_SGap();
        iGap = x5567_Get_Gap();
        iWZero = x5567_Get_Zero();
        iWOne = x5567_Get_One();
	}
	else if(Target_Tag == 77)
	{
        iSGap = x5577_Get_SGap();
        iGap = x5577_Get_Gap();
        iWZero = x5577_Get_Zero();
        iWOne = x5577_Get_One();
	}
	else if(Target_Tag == 70)
	{
        iSGap = x5570_Get_SGap();
        iGap = x5570_Get_Gap();
        iWZero = x5570_Get_Zero();
        iWOne = x5570_Get_One();
	}
	else if(Target_Tag == 58)
	{
	    iSGap = x5558_Get_SGap();
	    iGap = x5558_Get_Gap();
	    iRef = x5558_Get_Ref();
	}

	uio_Release();
	while(cButton != IO_F1 && cButton != IO_F2 && cButton != IO_F3 && cButton != IO_F4)
	{                                             
		// Menu Display
		if(currentPos != nextPos || upDate == 0)
		{
			currentPos = nextPos;
			lcd_clear_area(SCRN_LEFT+1,22+2,SCRN_RIGHT-1,SCRN_BOTTOM-1);
			
			lcd_put_fString(4,25, PSTR("SGap Time = "));
			lcd_put_fString(4,34, PSTR("Gap Time  = "));
			if(Target_Tag != 58)
			{
				lcd_put_fString(4,43, PSTR("One Time  = "));
				lcd_put_fString(4,52, PSTR("Zero Time = "));
			}
			else
			{
				lcd_put_fString(4,43, PSTR("Ref Time  = "));
			}
			 	
		 	// Insert more display code here
			itoa(iSGap, cString9,10);
			lcd_put_String(end_fString_Pos(4,PSTR("SGap Time = ")),25, cString9);	        
			
			itoa(iGap, cString9,10);
			lcd_put_String(end_fString_Pos(4,PSTR("SGap Time = ")),34, cString9);	        
		        
			if(Target_Tag != 58)
			{
				itoa(iWOne, cString9,10);
				lcd_put_String(end_fString_Pos(4,PSTR("SGap Time = ")),43, cString9);	        
			
				itoa(iWZero, cString9,10);
				lcd_put_String(end_fString_Pos(4,PSTR("SGap Time = ")),52, cString9);	        
			}
			else
			{
				itoa(iRef, cString9,10);
				lcd_put_String(end_fString_Pos(4,PSTR("SGap Time = ")),43, cString9);	        
			}
			if(currentPos == 5)
			{
			    lcd_invert_area(end_fString_Pos(4,PSTR("SGap Time = "))-1, (24+((3-1)*9)), end_fString_Pos(4,PSTR("SGap Time = "))+17, (32+((3-1)*9)));
			}
            else{lcd_invert_area(end_fString_Pos(4,PSTR("SGap Time = "))-1, (24+((currentPos-1)*9)), end_fString_Pos(4,PSTR("SGap Time = "))+17, (32+((currentPos-1)*9)));}
               	
			lcd_update(SCRN_TOP,SCRN_BOTTOM);
			upDate = 1;
		}
		// end display  
	
        uio_Get();
		switch(currentPos){
        case SGAP_FIELD:
            if(cButton == IO_ENTER){;}
            else if(cButton == IO_UP){;}
            else if(cButton == IO_DOWN)
            {
                nextPos = GAP_FIELD;
                uio_Release();
            }
            else if(cButton == IO_LEFT && iSGap > 300)
            {
            	iSGap--;
            	upDate = 0;
            }
            else if(cButton == IO_RIGHT && iSGap < 600)
            {
            	iSGap++;
            	upDate = 0;
            }
            break;
		case GAP_FIELD:
            if(cButton == IO_ENTER){;}
            else if(cButton == IO_UP)
            {
                nextPos = SGAP_FIELD;
                uio_Release();
            }
            else if(cButton == IO_DOWN)
            {
            	if(Target_Tag != 58){nextPos = WONE_FIELD;}
				else{nextPos = REF_FIELD;}
                uio_Release();
            }
            else if(cButton == IO_LEFT && iGap > 100)
            {
            	iGap--;
            	upDate = 0;
            }
            else if(cButton == IO_RIGHT && iGap < 300)
            {
            	iGap++;
            	upDate = 0;
            }
            break;
    	case WONE_FIELD:
            if(cButton == IO_ENTER){;}
            else if(cButton == IO_UP)
            {
                nextPos = GAP_FIELD;
                uio_Release();
            }
            else if(cButton == IO_DOWN)
            {
                nextPos = WZERO_FIELD;
                uio_Release();
            }
            else if(cButton == IO_LEFT && iWOne > 300)
            {
            	iWOne--;
            	upDate = 0;
            }
            else if(cButton == IO_RIGHT && iWOne < 500)
            {
            	iWOne++;
            	upDate = 0;
            }
            break;
        case WZERO_FIELD:
            if(cButton == IO_ENTER){;}
            else if(cButton == IO_UP)
            {
                nextPos = WONE_FIELD;
                uio_Release();
            }
            else if(cButton == IO_DOWN){;}
            else if(cButton == IO_LEFT && iWZero > 80)
            {
            	iWZero--;
            	upDate = 0;
            }
            else if(cButton == IO_RIGHT && iWZero < 250)
            {
            	iWZero++;
            	upDate = 0;
            }
            break;
        case REF_FIELD:
            if(cButton == IO_ENTER){;}
            else if(cButton == IO_UP)
            {
                nextPos = GAP_FIELD;
                uio_Release();
            }
            else if(cButton == IO_DOWN){;}
            else if(cButton == IO_LEFT && iRef > 104)
            {
            	iRef--;
            	upDate = 0;
            }
            else if(cButton == IO_RIGHT && iRef < 576)
            {
            	iRef++;
            	upDate = 0;
            }
            break;
		default:
     		break;
		}  
        //if(cButton>0 && cButton<6){uio_Release();}
	}
    //uio_Release();    
	//**** Write the new Tag Timing Vars to appropriate tag ****//
    if(Target_Tag == 51)
    {
		x5551_Set_SGap(iSGap);
		x5551_Set_Gap(iGap);
		x5551_Set_Zero(iWZero);
		x5551_Set_One(iWOne);  
	}
    else if(Target_Tag == 57)
    {
		x5557_Set_SGap(iSGap);
		x5557_Set_Gap(iGap);
		x5557_Set_Zero(iWZero);
		x5557_Set_One(iWOne);  
	}
	else if(Target_Tag == 67)
	{
		x5567_Set_SGap(iSGap);
		x5567_Set_Gap(iGap);
		x5567_Set_Zero(iWZero);
		x5567_Set_One(iWOne);  
	}
	else if(Target_Tag == 77)
	{
		x5577_Set_SGap(iSGap);
		x5577_Set_Gap(iGap);
		x5577_Set_Zero(iWZero);
		x5577_Set_One(iWOne);  
	}
	else if(Target_Tag == 70)
	{
		x5570_Set_SGap(iSGap);
		x5570_Set_Gap(iGap);
		x5570_Set_Zero(iWZero);
		x5570_Set_One(iWOne);  

⌨️ 快捷键说明

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