do_pwd.c
上传用户:shyuanyi
上传日期:2008-05-24
资源大小:69k
文件大小:2k
- #include "My_head.h"
- #include "key.h"
- /*************************************************/
- void Clear_PassWord(void)
- {
- memset(thekey.key_buf,0,KEY_SIZE);
- thekey.key_count=0;
- }
- void Dis_PassWord(void)
- {
- BYTE buf[8],flash,i;
- buf[0]=~D_DISPLAY[24];
- buf[1]=~D_DISPLAY[25];
- flash = 0xFC;
- for(i=0;(i<thekey.key_count)&&(i<6);i++)
- {
- buf[i+2]=~D_DISPLAY[16];
- flash <<= 1;
- }
- for(;(i<6);i++)
- {
- buf[i+2]=~D_DISPLAY[27];
- }
- Display_str(buf);
- Do_DisLed_Flash(flash,0x00,25);
- }
- BYTE Pwd_Into_Consume(void)
- {
- if( (thekey.key_count != 6)
- ||(thekey.key_buf[0] != (mycard.password[0]>>4))
- ||(thekey.key_buf[1] != (mycard.password[0]&0x0f))
- ||(thekey.key_buf[2] != (mycard.password[1]>>4))
- ||(thekey.key_buf[3] != (mycard.password[1]&0x0f))
- ||(thekey.key_buf[4] != (mycard.password[2]>>4))
- ||(thekey.key_buf[5] != (mycard.password[2]&0x0f))
- )return(PWDPOWER_ERR_CODE); //操作人员密码错误;
- KeyVal_Tobuf();//must!!
- //Dis_KeyBuf();
- PostMessage(CARD_CONSUME_EVENT,0);
- return(SUCCESS);
- }
- BYTE Do_PassWordKey_Even_13(BYTE Key)
- {
- BYTE i;
- if(Key > KEY_MAX-1)return(Key);
- Stop_Timer(WAIT_PRESSKEY_Tevent);
- Set_TimerEvent(WAIT_PRESSKEY_Tevent,WAIT_PRESSKEY_TIME);
- switch(Key)
- {
- case KEY_0 : Key = 0; break;
- case KEY_1 : Key = 1; break;
- case KEY_2 : Key = 2; break;
- case KEY_3 : Key = 3; break;
- case KEY_4 : Key = 4; break;
- case KEY_5 : Key = 5; break;
- case KEY_6 : Key = 6; break;
- case KEY_7 : Key = 7; break;
- case KEY_8 : Key = 8; break;
- case KEY_9 : Key = 9; break;
- //case KEY_FUN:Key =19;break;
- case KEY_ENTER1:
- case KEY_ENTER2:if((i=Pwd_Into_Consume())!=SUCCESS)
- {
- do_buzzer(BUZZER_ERROR);
- Dis_Err(i);
- Stop_Timer(DISPLAY_DELAYEVENT_Tevent);//msut!!
- Set_TimerEvent(DISPLAY_DELAYEVENT_Tevent,DISPLAY_DELAYEVENT_TIME);
- Set_TimerEvent(WAIT_CARD_Tevent,WAIT_CARDCONSUME_TIME);//(1)
- SetCurState(IDEL_STATUS);
- return(FAILURE);
- }
- return(0);
- case KEY_CANCEL:Renew_To_AllInit();
- return(0);
- case KEY_BACK: if(!My_Back_Key())
- {
- do_buzzer(BUZZER_ALARM);
- return(0);
- }
- Dis_PassWord();
- return(0);
- default:return(Key);
- }
- if((thekey.key_count>6)||!My_Save_Key(Key))do_buzzer(BUZZER_ALARM);
- else Dis_PassWord();
- return(SUCCESS);
- }