📄 tele_control.lst
字号:
784: else{timedelay0=0x00;}
785: if(key.b.lk1) //if keytimer>=1s,then set time
786: {
787: timedelay1++;
788: if(timedelay1==0xfa)
789: {
790: ANALOGUP=1; //
791: voice(0xa1);
792: password_buf[0]=0xaa;
793: password_buf[1]=0xaa;
794: password_buf[2]=0xaa;
795: password_buf[3]=0xaa;
796: password_buf[4]=0xaa;
797: password_buf[5]=0xaa;
798: password_buf[6]=0xaa;
799: password_buf[7]=0x00;
800: Tel_num_change=0;
801: STA=0X04;
802: }
803: }
804: else{timedelay1=0x00;}
805: if(key.b.lk2) //if keytimer>=1s,then set time
806: {
807: timedelay2++;
808: if(timedelay2==0xfa)
809: {
810: ANALOGUP=1; //
811: voice(0xa1);
812: password_buf[0]=0xaa;
813: password_buf[1]=0xaa;
814: password_buf[2]=0xaa;
815: password_buf[3]=0xaa;
816: password_buf[4]=0xaa;
817: password_buf[5]=0xaa;
818: password_buf[6]=0xaa;
819: password_buf[7]=0x00;
820: Tel_num_change=0;
821: STA=0X04;
822: }
823: }
824: else{timedelay2=0x00;}
825: if(key.b.lk3) //if keytimer>=1s,then reset all data
826: {
827: timedelay3++;
828: if(timedelay3==0xfa)
829: {
830: dsbuf[0]=0xff;
831: dsbuf[1]=0xff;
832: dsbuf[2]=0xff;
833: dsbuf[3]=0xf0;
834: dot=0x00;
835: STA=0X02;
836: }
837: }
838: else{timedelay3=0x00;}
839: }
840: i=ds1302_read(adr_jdqsta);
841: dsbuf[3]=(dsbuf[3]&0xf0)|(i&0x0f);
842: i&=0x0f;
843: PORTB=(LED4[i])|(PORTB&0x0f);
844: }
845: //************************
846: //2ms Timer
847: //************************
848: void Time(void)
849: {
850: while(!TMR0IF); //2mS out?
851: TMR0=0x07; //249*8+6=1998
852: asm("clrwdt");
853: while(TMR0IF==1) //clear TMR0IF
854: {TMR0IF=0;}
855: }
856: //******************
857: //set when power up
858: //******************
859: void Initial(void)
860: {
861: if(POR==0)
862: {
863: PORTA=0x00;
864: PORTB=0x00;
865: PORTC=0x80;
866: password1_buf[0]=0xaa; //reload
867: password1_buf[1]=0xaa;
868: password1_buf[2]=0xaa;
869: password1_buf[3]=0xaa;
870: password1_buf[4]=0xaa;
871: password1_buf[5]=0xaa;
872: password1_buf[6]=0xaa;
873: password_buf[0]=0xaa; //reload
874: password_buf[1]=0xaa;
875: password_buf[2]=0xaa;
876: password_buf[3]=0xaa;
877: password_buf[4]=0xaa;
878: password_buf[5]=0xaa;
879: password_buf[6]=0xaa;
880: password_buf[7]=0x00;
881: }
882: while(POR==0){POR=1;}
883: }
884: //***************************
885: //reset special function registers
886: //***************************
887: void SFRSET(void)
888: {
889: TRISA=0x13; //
890: TRISB=0x01;
891: TRISC=0x0F; //
892: PIE1=0x00;
893: ADCON1=0x06; //shut down all AD
894: PCLATH=0x00;
895: OPTION=0xc2; //timer0,RBPU=1,Interrupt on rising edge of RB0/INT pin
896: INTE=1; //enable INT
897: PEIE=1; //enable peie
898: GIE=1;
899: T2CON=0X25; //timer2 /(5*4)
900: PIR1=0x00;
901: ADCON0=0x00;
902: TMR0=0x06; //2mS Timer 250*8
903: STA=0X00;
904: STA1=0X00;
905: STA2=0X00;
906: }
907: //****************************
908: //reset system
909: //****************************
910: void system_reset(void)
911: {
912: ds1302_write(ds1302_control,0x00); //close write protect
913: ds1302_write(ds1302_charger,0xa9); //trickle charger
914: ds1302_write(adr_ringtimes,0x04); //ring times,4 times
915: ds1302_write(adr_jdqsta,0x00); //jdq state,all close
916: ds1302_write(adr_password,0x31); //password0,31
917: ds1302_write(adr_password+2,0x5f); //password1,5#
918: ds1302_write(adr_password+4,0xaa); //password2,aa
919: ds1302_write(adr_password+6,0xaa); //password3,aa
920: ds1302_write(adr_password+8,0xaa); //password4,aa
921: ds1302_write(adr_password+10,0xaa); //password5,aa
922: ds1302_write(adr_password+12,0xaa); //password6,aa
923: ds1302_write(ds1302_control,0x80); //open write protect
924: }
925: //****************************
926: //Display program
927: //****************************
928: void Display(void)
929: {
930: unsigned char i,j,k;
931: k=Bit_Select>>1;
932: j=dsbuf[k];
933: if(Bit_Select^0x07) //
934: {if(Bit_Select&0x01) //btfsc Bit_Select,0
935: {j&=0X0f;} //get low 4 bit
936: else{j=j>>4&0X0f;} //get high 4 bit
937: k=LED7[j];
938: } //get ledcode
939: else{k=j&0x0f;} //get ledscode
940: if(flash&0x80)
941: {
942: if(Bit_Select==(flash&0x07))
943: {if(inc4ms&0x80){k=0x00;}}
944: }
945: if(dot<<Bit_Select&0x80){k|=0x02;}
946: j=bitcode[Bit_Select&0x07];
947: Bit_Select++;
948: if(Bit_Select==0x08){Bit_Select=0x00;}
949: RCK595=0; //put out 2*8 bit data
950: i=0x08;
951: do{
952: SCK595=0;
953: SEC595=0;
954: if(j&0x01)SEC595=1; //put out the lowest bit of ledbit
955: j>>=1;
956: SCK595=1;
957: }while(--i);
958: i=0x08;
959: do{
960: SCK595=0;
961: SEC595=0;
962: if(k&0x01)SEC595=1; //put out the lowest bit of ledcode
963: k>>=1;
964: SCK595=1;
965: }while(--i);
966: RCK595=1;
967: }
968: //*****************************
969: //Keyscan program
970: //*****************************
971: void KEYScan(void)
972: {
973: unsigned char i,j,k;
974: //blow is key scan
975: HANG1=0; //
976: i=0x05;while(i--){;} //8+3*(i-1)=delay 20uS
977: k=(PORTC^0X0f)&0x0f;
978: HANG1=1;
979: k=k|(key.halfkey[0]&0xf0);
980: //blow is cut the key vibration
981: for(i=0;i<4;i++)
982: {
983: kcap[i]+=(kcap[i]<<1)+(kcap[i]<<2);
984: if(k&0x01){kcap[i]+=0x10;}
985: kcap[i]>>=3;
986: k>>=1;
987: if(kcap[i]>=6){k|=0x80;} //set
988: else{k&=0x7f;} //clear
989: }
990: j=k;
991: k=(k<<4)|(k>>4); //==swap k
992: //blow is border test,before border=Key
993: key.halfkey[0]=(((j^k)&k)&0x0f)|(j&0xf0);
994: key.halfkey[1]=((j^k)&j)&0x0f;
995: }
996: //*****************************
997: //
998: //*****************************
999: void jdq_indect(void)
1000: {
1001: if(Tel_num_change)
1002: {
1003: unsigned char i;
1004: i=ds1302_read(adr_jdqsta);
1005: Tel_num_change=0;
1006: voice(0x7c);
1007: if(Tel_num==0x01)
1008: {
1009: jdq_delay=1;
1010: if(i&0x01){i&=0xfe;voice(0x58);}
1011: else{i|=0x01;voice(0x40);}
1012: }
1013: if(Tel_num==0x02)
1014: {
1015: jdq_delay=1;
1016: if(i&0x02){i&=0xfd;voice(0x58);}
1017: else{i|=0x02;voice(0x40);}
1018: }
1019: if(Tel_num==0x03)
1020: {
1021: jdq_delay=1;
1022: if(i&0x04){i&=0xfb;voice(0x58);}
1023: else{i|=0x04;voice(0x40);}
1024: }
1025: if(Tel_num==0x04)
1026: {
1027: jdq_delay=1;
1028: if(i&0x08){i&=0xf7;voice(0x58);}
1029: else{i|=0x08;voice(0x40);}
1030: }
1031: if(Tel_num==0x0e)
1032: {
1033: VOICE=0;
1034: voice(0x60);
1035: jdq_delay=0;
1036: INTE=1;
1037: STA=0x01;
1038: }
1039: if(jdq_delay)
1040: {
1041: ds1302_write(ds1302_control,0x00); //close write protect
1042: ds1302_write(adr_jdqsta,i); //jdq indect control
1043: ds1302_write(ds1302_control,0x80); //open write protect
1044: i&=0x0f;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -