📄 rfid_writemenu.c
字号:
Target_Tag_ID[(unsigned char)(4+i)] = cBlockDat2[i];
Target_Tag_ID[(unsigned char)(8+i)] = cBlockDat3[i];
}
message_1sDisplay(PSTR("Write Successful"));
}
else {message_1sDisplay(PSTR("Write Failed"));}
}
else if(cButton == IO_UP && cBlockSel > 56)
{
cBlockSel--;
if(cBlockSel == 56){for(i=0; i<4; i++){cBlockDat[i] = cBlockDat1[i];}}
else if(cBlockSel == 57){for(i=0; i<4; i++){cBlockDat[i] = cBlockDat2[i];}}
else if(cBlockSel == 58){for(i=0; i<4; i++){cBlockDat[i] = cBlockDat3[i];}}
upDate = 0;
}
else if(cButton == IO_DOWN && cBlockSel < 58)
{
cBlockSel++;
if(cBlockSel == 56){for(i=0; i<4; i++){cBlockDat[i] = cBlockDat1[i];}}
else if(cBlockSel == 57){for(i=0; i<4; i++){cBlockDat[i] = cBlockDat2[i];}}
else if(cBlockSel == 58){for(i=0; i<4; i++){cBlockDat[i] = cBlockDat3[i];}}
upDate = 0;
}
break;
case BLOCKDAT1:
case BLOCKDAT3:
case BLOCKDAT5:
case BLOCKDAT7:
if(cButton == IO_RIGHT && currentPos < BLOCKDAT8){nextPos++;}
else if(cButton == IO_LEFT && currentPos > BLOCKDAT1){nextPos--;}
else if(cButton == IO_ENTER){nextPos = BLOCKSEL;}
else if(cButton == IO_UP)
{
cBlockDat[currentPos>>1] += 16;
upDate = 0;
}
else if(cButton == IO_DOWN)
{
cBlockDat[currentPos>>1] -= 16;
upDate = 0;
}
break;
case BLOCKDAT2:
case BLOCKDAT4:
case BLOCKDAT6:
case BLOCKDAT8:
if(cButton == IO_RIGHT && currentPos < BLOCKDAT8){nextPos++;}
else if(cButton == IO_LEFT && currentPos > BLOCKDAT1){nextPos--;}
else if(cButton == IO_ENTER){nextPos = BLOCKSEL;}
else if(cButton == IO_UP)
{
i=cBlockDat[currentPos>>1];
i = (i+1)&0x0F;
cBlockDat[currentPos>>1] = ((cBlockDat[currentPos>>1]&0xF0) | i);
upDate = 0;
}
else if(cButton == IO_DOWN)
{
i=cBlockDat[currentPos>>1];
i = (i-1)&0x0F;
cBlockDat[currentPos>>1] = ((cBlockDat[currentPos>>1]&0xF0) | i);
cBlockDat[currentPos>>1] = (cBlockDat[currentPos>>1] | i);
upDate = 0;
}
break;
default:
break;
}
if(cButton>0 && cButton<6){uio_Release();}
if(cBlockSel == 56){for(i=0; i<4; i++){cBlockDat1[i] = cBlockDat[i];}}
else if(cBlockSel == 57){for(i=0; i<4; i++){cBlockDat2[i] = cBlockDat[i];}}
else if(cBlockSel == 58){for(i=0; i<4; i++){cBlockDat3[i] = cBlockDat[i];}}
}
uio_Release();
}
void rfid_WriteMenu_x5577AFEReg(unsigned char Target_Tag, unsigned char Target_Reader)
{
unsigned char i;//, end, cBlockSel=56;
unsigned char sBlockDat[9] = "00000000";
unsigned char tmpReg[4]={0};
unsigned char *sBlockDatPtr;
nextPos = BLOCKSEL;
upDate = 0;
x5577_Get_AFEReg(&tmpReg[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(" AFE Options"));
lcd_horz_line(SCRN_LEFT,SCRN_RIGHT,11); // First Row Separator
lcd_vert_line(12,SCRN_BOTTOM-1,37); // First Col Separator
lcd_put_fString(5,16,PSTR("Block"));
lcd_put_fString(53,16,PSTR("Data"));
// Insert more display code here
sBlockDatPtr = &sBlockDat[0];
for(i=0; i<4; i++)
{
conv_Char2HexStr2(sBlockDatPtr, tmpReg[i]);
sBlockDatPtr += 2;
}
sBlockDatPtr = &sBlockDat[0];
lcd_put_fString(17,26,sNumPtr[3]);
lcd_put_String(41,26,sBlockDatPtr);
if(currentPos == BLOCKSEL )
{
if(Target_Tag == 58){lcd_invert_area(16,25,28,33);}
else{lcd_invert_area(16,25,22,33);}
}
else {lcd_invert_area(40+(currentPos*6),25,46+(currentPos*6),33);}
lcd_update(SCRN_TOP,SCRN_BOTTOM);
upDate = 1;
}
// end display
uio_Get();
switch(currentPos){
case BLOCKSEL:
if(cButton == IO_ENTER)
{
ioActive = 0;
x5577_WriteAFEReg(Target_Reader);
message_1sDisplay(PSTR("Write Attempted"));
ioActive = 1;
}
else if(cButton == IO_RIGHT){nextPos = BLOCKDAT1;}
break;
case BLOCKDAT1:
case BLOCKDAT3:
case BLOCKDAT5:
case BLOCKDAT7:
if(cButton == IO_RIGHT && currentPos < BLOCKDAT8){nextPos++;}
else if(cButton == IO_LEFT && currentPos > BLOCKDAT1){nextPos--;}
else if(cButton == IO_ENTER){nextPos = BLOCKSEL;}
else if(cButton == IO_UP)
{
tmpReg[currentPos>>1] += 16;
x5577_Set_AFEReg(&tmpReg[0]);
upDate = 0;
}
else if(cButton == IO_DOWN)
{
tmpReg[currentPos>>1] -= 16;
x5577_Set_AFEReg(&tmpReg[0]);
upDate = 0;
}
break;
case BLOCKDAT2:
case BLOCKDAT4:
case BLOCKDAT6:
case BLOCKDAT8:
if(cButton == IO_RIGHT && currentPos < BLOCKDAT8){nextPos++;}
else if(cButton == IO_LEFT && currentPos > BLOCKDAT1){nextPos--;}
else if(cButton == IO_ENTER){nextPos = BLOCKSEL;}
else if(cButton == IO_UP)
{
i=tmpReg[currentPos>>1];
i = (i+1)&0x0F;
tmpReg[currentPos>>1] = ((tmpReg[currentPos>>1]&0xF0) | i);
x5577_Set_AFEReg(&tmpReg[0]);
upDate = 0;
}
else if(cButton == IO_DOWN)
{
i=tmpReg[currentPos>>1];
i = (i-1)&0x0F;
tmpReg[currentPos>>1] = ((tmpReg[currentPos>>1]&0xF0) | i);
tmpReg[currentPos>>1] = (tmpReg[currentPos>>1] | i);
x5577_Set_AFEReg(&tmpReg[0]);
upDate = 0;
}
break;
default:
break;
}
if(cButton>0 && cButton<6){uio_Release();}
}
uio_Release();
}
// *******************************************************************************
// Menu that allows the ATA5558 to be erased
// ******************************************************************************/
void Display_T5558Clear(unsigned char Target_Reader)
{
unsigned char cQuit = 0;
nextPos = 1;
upDate = 0;
uio_Release();
while(cButton != IO_F1 && cButton != IO_F2 && cButton != IO_F3 && cButton != IO_F4 && cQuit == 0)
{
// Menu navigation with scroll
if(currentPos != nextPos || upDate == 0)
{
currentPos = nextPos;
lcd_clear_area(SCRN_LEFT+1,SCRN_TOP+1,SCRN_RIGHT-1,SCRN_BOTTOM-1);
lcd_put_fString(4, 2, sRFIDTAGPtr[7]);
lcd_put_fString(32, 2, PSTR(" Clear Tag"));
lcd_horz_line(SCRN_LEFT,SCRN_RIGHT,11); // First Row Separator
// Insert more display code here
lcd_put_fString(4, 13, PSTR("This will CLEAR the "));
lcd_put_fString(4, 21, PSTR("entire Tag contents."));
lcd_put_fString(4, 29, PSTR("Is this ok?"));
lcd_horz_line(SCRN_LEFT,SCRN_RIGHT,SCRN_BOTTOM-11); // Bottom Row Separator
lcd_vert_line(SCRN_BOTTOM-11,SCRN_BOTTOM-1,63);
lcd_put_fString(lcd_fcenter(PSTR("Yes"))-31, SCRN_BOTTOM-9, PSTR("Yes"));
lcd_put_fString(lcd_fcenter(PSTR("No"))+31, SCRN_BOTTOM-9, PSTR("No"));
lcd_invert_area((3+((currentPos-1)*63)), SCRN_BOTTOM-10, (60+((currentPos-1)*63)), SCRN_BOTTOM-2);
lcd_update(SCRN_TOP,SCRN_BOTTOM);
upDate = 1;
}
// end navigation
uio_Get();
switch(currentPos){
case 1:
if(cButton == IO_ENTER)
{
if(Target_Reader == 70)
{
x5558_SelectTagID(Target_Reader, &Target_Tag_ID[0]);
Timer_delay_ms(15);
x5558_LoginWrite(Target_Reader, &Target_Tag_PWD[0]);
Timer_delay_ms(10);
x5558_ArmClear(Target_Reader);
Timer_delay_ms(10);
x5558_ClearAll(Target_Reader);
Timer_delay_ms(15);
x5558_WriteConfigReg(Target_Reader);
uio_Release();
}
}
else if(cButton == IO_LEFT){;}
else if(cButton == IO_RIGHT)
{
nextPos = 2;
uio_Release();
}
break;
case 2:
if(cButton == IO_ENTER){cQuit = 1;}
else if(cButton == IO_LEFT)
{
nextPos = 1;
uio_Release();
}
else if(cButton == IO_RIGHT){;}
break;
default:
break;
}
}
uio_Release();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -