do_keyeven.c
上传用户:shyuanyi
上传日期:2008-05-24
资源大小:69k
文件大小:4k
- #include "my_head.h"
- #include "key.h"
- #include "carddef.h"
- /***************************************************/
- //data shows;
- BYTE code D_DISPLAY[]=
- {
- 0XC0,//0
- 0XF9,//1
- 0XA4,//2
- 0XB0,//3
- 0X99,//4
- 0X92,//5
- 0X82,//6
- 0XF8,//7
- 0X80,//8
- 0X90,//9
- 0X88,//a
- 0x83,//b
- 0xc6,//c
- 0xa1,//d
- 0x86,//e
- 0x8e,//f
- //status shows;
- 0xBF,//- --16
- 0x11,//y --17
- 0xFF,// --18
- 0xE7,//< --19
- 0xAF,//r --20
- 0xCF,//I --21
- 0xAB,//n --22
- 0xA3,//o --23
- 0x0C,//p.--24
- 0X12,//s.--25
- 0xF3,//> --26
- 0xF7,//_ --27
- };
- void Dis_Err(BYTE cod)
- {
- BYTE buf[8];
- Sound_Err(cod);
- buf[0]=~D_DISPLAY[21];
- buf[1]=~D_DISPLAY[22];
- buf[2]=~D_DISPLAY[0xf];
- buf[3]=~D_DISPLAY[23];
- buf[4]=~D_DISPLAY[18];
- buf[5]=~D_DISPLAY[cod/100];cod%=100;
- buf[6]=~D_DISPLAY[cod/10];cod%=10;
- buf[7]=~D_DISPLAY[cod];
- Display_str(buf);
- }
- KEY_STR idata thekey;
- bit bdata save_op_flag = FALSE;
- void KeyBuf_Clear(bit val_flag)
- {
- memset(thekey.key_buf,0,KEY_SIZE);
- thekey.key_count=6;
- thekey.dot_count=0;
- save_op_flag = FALSE;
- if(!val_flag)
- {
- thekey.key_val=0L;
- thekey.KEY_OP =0;
- }
- }
- void Dis_KeyBuf(void)
- {
- BYTE i,j,buf[8];
- j= (thekey.key_count==6)? 5:thekey.key_count;
- for(i=0;i<j;i++)buf[i]=~D_DISPLAY[18];
- for(;i<8;i++)
- {
- buf[i]=~D_DISPLAY[thekey.key_buf[i]];
- }
- buf[5] |= 0x80;
- Display_str(buf);//Do_Led(buf[0]);
- }
- /*
- //规定:金额数据不能大于等于十万元!
- bit Count_KeyVal(void)
- {
- BYTE i;
- long val=0L;
- for(i=thekey.key_count;i<8;i++)
- {
- val *= 10;
- val += thekey.key_buf[i];
- }
- if((val<0L)||(val>9999900L))return(FALSE);
- switch(thekey.KEY_OP)
- {
- case KEY_INC :thekey.key_val += val;break;
- //case KEY_DEC :thekey.key_val -= val;break;
- case KEY_MUL :thekey.key_val *= val;
- thekey.key_val /= 100;
- break;
- //case 0:
- default:thekey.key_val = val;break;
- }
- if((thekey.key_val<0L)||(thekey.key_val>9999900L))return(FALSE);
- return(TRUE);
- }
- */
- void KeyVal_Tobuf(void)
- {
- BYTE i;
- long val=0L;
- for(val=thekey.key_val,i=8;i--;)
- {
- thekey.key_buf[i] = val%10;
- if(!(val /= 10) && (i<6))break;
- }
- thekey.dot_count = 8;
- thekey.key_count = i>5?6:i;
- }
- /*
- BYTE Do_FirstKey_Even_1(BYTE Key)
- {
- return(Key);
- }
- extern bit Dj_Into_Consume(void);
- extern void DoTest_ArrayRead_Memory(WORD pageaddr);
- BYTE Do_NextKey_Even_2(BYTE Key) //单价消费用
- {
- return(Key);
- }
- /*
- bit Dj_Into_Consume(void)
- {
- if(!Count_KeyVal())KeyBuf_Clear(0);
- KeyVal_Tobuf();
- Dis_KeyBuf();
- if(thekey.key_val<1)
- {
- do_buzzer(BUZZER_ERROR);
- return(FALSE);
- }
- Dis_consume_Led(TRUE);
- Do_DisLed_Flash(0xff,0x00,25);
- //Stop_Timer(DIS_CLOCKEVENT_Tevent);
- Set_TimerEvent(WAIT_CARD_Tevent,WAIT_CARDCONSUME_TIME);
- Stop_Timer(WAIT_EXIT_Tevent);
- Set_TimerEvent(WAIT_EXIT_Tevent,WAIT_EXIT_TIME);
- SetCurState(CONSUME_STATUS);
- return(TRUE);
- }
- /*
- bit Dj_Into_TestCardWrite(void)
- {
- if(!Count_KeyVal())KeyBuf_Clear(0);
- KeyVal_Tobuf();
- Dis_KeyBuf();
- if(thekey.key_val<1)
- {
- do_buzzer(BUZZER_ERROR);
- return(FALSE);
- }
- Dis_consume_Led(TRUE);
- Do_DisLed_Flash(0xff,0x00,25);
- //Stop_Timer(DIS_CLOCKEVENT_Tevent);
- Set_TimerEvent(WAIT_CARD_Tevent,WAIT_CARDCONSUME_TIME);
- Stop_Timer(WAIT_EXIT_Tevent);
- Set_TimerEvent(WAIT_EXIT_Tevent,WAIT_EXIT_TIME);
- SetCurState(MY_TEST_STATUS);
- return(TRUE);
- }
- bit Dj_Into_Increment(void)
- {
- if(!Count_KeyVal())KeyBuf_Clear(0);
- KeyVal_Tobuf();
- Dis_KeyBuf();
- if(thekey.key_val<1)
- {
- do_buzzer(BUZZER_ERROR);
- return(FALSE);
- }
- Dis_consume_Led(TRUE);
- Do_DisLed_Flash(0xff,0x00,25);
- //Stop_Timer(DIS_CLOCKEVENT_Tevent);
- Set_TimerEvent(WAIT_CARD_Tevent,WAIT_CARDCONSUME_TIME);
- Stop_Timer(WAIT_EXIT_Tevent);
- Set_TimerEvent(WAIT_EXIT_Tevent,WAIT_EXIT_TIME);
- SetCurState(INCREMENT_STATUS);
- return(TRUE);
- }
- */
- BYTE Do_WaitCardKey_Even_4(BYTE Key)
- {
- //SendStr(&Key,1);//for test!
- //Do_Led(0x1<<(Key%8));//for test.
- if(Key > KEY_MAX-1)return(Key);
- if(Key==KEY_CANCEL)
- {
- Renew_To_AllInit();
- return(0);
- }
- return(Key);
- }