lockbell.c
上传用户:shyuanyi
上传日期:2008-05-24
资源大小:69k
文件大小:4k
- #include "my_head.h"
- #define IIC_SCL P4_1
- #define IIC_SDA P4_0
- #define LOCK_CTRL P4_3
- #define BELL_CTRL P4_2
- #define SUCCESS_LED P4_3
- #define FAILURE_LED P4_2
- //===============================================
- void Init_LockBell(void)
- {
- P4 = 0xFF;
- // IIC_SCL = OFF;
- // IIC_SDA = OFF;
- LOCK_CTRL = OFF;
- BELL_CTRL = OFF;
- }
- //================================================
- void Dis_Err_Led(bit bOnOff) //0-close;1--open.
- {
- FAILURE_LED = !bOnOff;
- if(bOnOff)SUCCESS_LED=OFF;
- }
- //bit success_led_flag = FALSE;
- void Dis_Con_Led(bit bOnOff) //0-close;1--open.
- {
- //success_led_flag=
- SUCCESS_LED = !bOnOff;
- if(bOnOff)FAILURE_LED=OFF;
- }
- /*
- void Dis_Comming_Led(bit bOnOff)//0-close;1--open. //LCD考勤机上专用
- {
- COMMING_LED = !bOnOff;
- }
- void Lock_OnOff(bit bOnOff) //0-close;1--open.
- {
- LOCK_CTRL = !bOnOff;
- OUTPUT373_CTLR = ON;
- do_nop(2);
- OUTPUT373_CTLR = OFF;
- }
- void Bell_OnOff(bit bOnOff) //0-close;1--open.
- {
- BELL_CTRL = !bOnOff;
- OUTPUT373_CTLR = ON;
- do_nop(2);
- OUTPUT373_CTLR = OFF;
- }
- */
- //=================================================
- /*************************************************/
- #define DATAFULL_LED 0x01
- #define COMMING_LED 0x02
- #define CELL_POWER_LED 0x04
- #define CON_MODE_LED1 0x08
- #define CON_MODE_LED2 0x10
- #define CON_MODE_LED3 0x20
- #define CUR_ERR_LED 0x40
- #define CUR_CON_LED 0x80
- //===================================
- BYTE bdata Led_Save = 0xFF;
- sbit led_0 = Led_Save^0;
- sbit led_1 = Led_Save^1;
- sbit led_2 = Led_Save^2;
- sbit led_3 = Led_Save^3;
- sbit led_4 = Led_Save^4;
- sbit led_5 = Led_Save^5;
- sbit led_6 = Led_Save^6;
- sbit led_7 = Led_Save^7;
- void Init_Led_Save(void)
- {
- Led_Save &= ~(CUR_ERR_LED|CUR_CON_LED|COMMING_LED|DATAFULL_LED);
- }
- /*
- void Dis_Balance_Led(bit ledflag) //0-close;1--open.
- {
- ledflag? (Led_Save |= CUR_ERR_LED) : (Led_Save &= ~CUR_ERR_LED);
- Do_Led(Led_Save);
- }
- */
- void Dis_Consume_Led(bit ledflag) //0-close;1--open.
- {
- ledflag? (Led_Save |= CUR_CON_LED) : (Led_Save &= ~CUR_CON_LED);
- Do_Led(Led_Save);
- }
- void Dis_Comming_Led(bit ledflag) //0-close;1--open.
- {
- ledflag? (Led_Save |= COMMING_LED) : (Led_Save &= ~COMMING_LED);
- Do_Led(Led_Save);
- }
- void Dis_Cellpower_Led(bit ledflag) //0-close;1--open.
- {
- ledflag? (Led_Save |= CELL_POWER_LED) : (Led_Save &= ~CELL_POWER_LED);
- Do_Led(Led_Save);
- }
- void Dis_DataFull_Led(bit ledflag) //0--close;1--open.
- {
- ledflag? (Led_Save |= DATAFULL_LED) : (Led_Save &= ~DATAFULL_LED);
- Do_Led(Led_Save);
- }
- /*
- void Dis_ConMode(void)
- {
- BYTE mode= con_param_info.con_mode;
- Led_Save &= 0xC7;
- if(mode>0 && mode<4)
- {
- Led_Save |= (mode<<3);
- }
- else if(mode==4)
- {
- Led_Save |= (CON_MODE_LED1 | CON_MODE_LED3);
- }
- else if(mode==5)
- {
- Led_Save |= (CON_MODE_LED2 | CON_MODE_LED3);
- }
- else if(mode==6)
- {
- Led_Save |= (CON_MODE_LED1 | CON_MODE_LED2 | CON_MODE_LED3);
- }
- Do_Led(Led_Save);
- }
- */
- void CounterAndfillBuf(BYTE buf[],BYTE lens,LWORD dat,bit fill0_flag)//1-前面补零,0-不补零
- {
- BYTE ii;
- LWORD LL; //mustn't LL=0L;
- for(LL=1,ii=1;ii<lens;ii++)LL *= 10;
- for(ii=0;ii<lens;ii++)
- {
- buf[ii] = ~D_DISPLAY[dat/LL];
- if((buf[ii]==(BYTE)~D_DISPLAY[0]) && !fill0_flag)buf[ii]=~D_DISPLAY[18];
- else fill0_flag=TRUE;
- dat %= LL;
- LL /= 10;
- }
- }
- void Dis_Equip_Code(void)
- {
- BYTE idata buf[8];
- CounterAndfillBuf(&buf[0],2,equip_addr.ntype,TRUE);
- buf[2]= ~D_DISPLAY[16];
- CounterAndfillBuf(&buf[3],5,equip_addr.number_addr,TRUE);
- Display_str(buf);
- }
- /*
- void Dis_cNumber(BYTE cNumber[3])
- {
- BYTE idata buf[8],i;
- i=cNumber[0];
-
- buf[0]=buf[1]=~D_DISPLAY[18];
- buf[2]=~D_DISPLAY[(cNumber[0]>>4)];
- buf[3]=~D_DISPLAY[(cNumber[0]&0xf)];
- buf[4]=~D_DISPLAY[(cNumber[1]>>4)];
- buf[5]=~D_DISPLAY[(cNumber[1]&0xf)];
- buf[6]=~D_DISPLAY[(cNumber[2]>>4)];
- buf[7]=~D_DISPLAY[(cNumber[2]&0xf)];
- Display_str(buf);
- }
- */