home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HAM Radio 1
/
HamRadio.cdr
/
control
/
homecon
/
x10.bas
< prev
next >
Wrap
BASIC Source File
|
1988-04-12
|
6KB
|
149 lines
19999 CLS:PRINT"ERROR RUNNING INTO UTILITIES......":END
20000 '*************** SETUP ROUTINE ************************
20001 '
20002 ' (C) 1986 X10 (USA) inc GD - 07/05/86
20003 '
20005 DIM CODCONV(16) , TIM( 7,128)
20008 DIM GRAPH(2,256)
20015 OPEN "COM1:600,N,8,1,CS,DS" AS #1
20020 DAYCONV(1)=64:DAYCONV(2)=1:DAYCONV(3)=2
20030 DAYCONV(4)=4:DAYCONV(5)=8:DAYCONV(6)=16:DAYCONV(7)=32
20040 HOURS=0:MINS=0
20050 CODCONV(1)=96:CODCONV(2)=224:CODCONV(3)=32:CODCONV(4)=160:CODCONV(5)=16
20060 CODCONV(6)=144:CODCONV(7)=80:CODCONV(8)=208:CODCONV(9)=112
20070 CODCONV(10)=240:CODCONV(11)=48:CODCONV(12)=176:CODCONV(13)=0
20080 CODCONV(14)=128:CODCONV(15)=64:CODCONV(16)=192
20099 RETURN
20100 '************ SET TIME IN INTERFACE *******************
20101 '
20110 GOSUB 30300
20125 A=2:GOSUB 30000
20130 A=MINS:GOSUB 30000
20140 A=HOURS:GOSUB 30100
20150 A=DAYCONV(DAY):GOSUB 30100
20160 CHKSUM=(CHKSUM AND 255):A=CHKSUM:GOSUB 30600
20170 GOTO 30200
20200 '************ SET BASE HOUSECODE **********************
20201 '
20210 GOSUB 30300
20220 A=0:GOSUB 30000
20230 A=CODCONV(BASECODE):GOSUB 30000
20240 GOTO 30200
20300 '**************** READ THE TIME ***********************
20301 '
20310 GOSUB 30300
20320 A=4:GOSUB 30000
20370 GOSUB 30500:IF STATUS = -1 THEN RETURN
20375 STATUS=A
20380 GOSUB 30400:IF STATUS=-1 THEN RETURN
20385 MINS=A:GOSUB 30400:IF STATUS=-1 THEN RETURN
20390 HOURS=A:GOSUB 30400:IF STATUS=-1 THEN RETURN
20395 BTEMP=A:GOSUB 30400:IF STATUS=-1 THEN RETURN
20396 C=A:GOSUB 30400:IF STATUS=-1 THEN RETURN
20400 FOR BASECODE=1 TO 16:IF HTEMP=CODCONV(BASECODE) THEN 20420
20410 NEXT BASECODE
20420 FOR DAY=1 TO 7:IF BTEMP=DAYCONV(DAY) THEN RETURN
20430 NEXT DAY
20440 RETURN
20500 '****************** X10 DIRECT ************************
20501 '
20510 IF FUNCTION=2 THEN FTEMP=3:GOTO 20540
20520 IF FUNCTION=3 THEN FTEMP=5+(240 AND (LEVEL*16)):GOTO 20540
20530 FTEMP=2
20540 HTEMP=CODCONV(HOUSECODE)
20560 GOSUB 30300
20570 A=1:GOSUB 30000:A=FTEMP:GOSUB 30000:A=HTEMP:GOSUB 30100:A=HIUNIT:GOSUB 30100
20580 A=LOUNIT:GOSUB 30100:A=(CHKSUM AND 255):GOSUB 30000
20590 GOSUB 30200:IF STATUS=-1 THEN RETURN
20600 GOSUB 30500:IF STATUS=-1 THEN RETURN
20610 STATUS =A
20660 GOSUB 30400:IF STATUS=-1 THEN RETURN
20670 FTEMP=A:GOSUB 30400:IF STATUS=-1 THEN RETURN
20680 HIUNIT=A:GOSUB 30400:IF STATUS=-1 THEN RETURN
20685 LOUNIT=A:GOSUB 30400:IF STATUS=-1 THEN RETURN
20690 BTEMP=A:A=(FTEMP AND 240)
20695 FOR HOUSECODE=1 TO 16
20700 IF A<>CODCONV(HOUSECODE) THEN NEXT HOUSECODE
20710 FOR BASECODE=1 TO 16
20720 IF BTEMP<>CODCONV(BASECODE) THEN NEXT BASECODE
20740 A=(FTEMP AND 15):FUNCTION=1:IF A=4 THEN FUNCTION=3
20750 IF A=3 THEN FUNCTION =2
20760 RETURN
20800 '************** DOWNLOAD TIMER EVENT ******************
20801 '
20810 ADDR1=((ADDRESS) AND 31)*8:ADDR2=((ADDRESS) AND 96)/32
20820 GOSUB 30300:A=3:GOSUB 30000
20830 A=ADDR1:GOSUB 30000:A=ADDR2:GOSUB 30000
20840 A=TIM(0,ADDRESS):GOSUB 30000
20845 FOR XTEMP=1 TO 7
20847 A=TIM(XTEMP,ADDRESS):GOSUB 30100
20848 NEXT XTEMP
20850 A=CHKSUM AND 255 :GOSUB 30000
20860 GOTO 30200
20900 '*************** UPLOAD TIMER EVENTS ******************
20901 '
20910 GOSUB 30300:A=5:GOSUB 30000
20920 GOSUB 30500:IF STATUS=-1 THEN RETURN
20925 EVENT =0
20930 GOSUB 30400:IF STATUS=-1 THEN RETURN
20935 IF A=255 THEN 20970
20940 FOR XTEMP=0 TO 6
20945 TIM(XTEMP,EVENT)=A:GOSUB 30400:IF STATUS=-1 THEN RETURN
20947 NEXT XTEMP:TIM(7,EVENT)=A
20948 EVENT=EVENT+1:IF EVENT < 128 THEN 20930
20950 GOTO 30400:IF STATUS=-1 THEN RETURN
20970 FOR XTEMP=0 TO 7:TIM(XTEMP,EVENT)=0
20980 NEXT XTEMP:GOTO 20948
21000 '************** DOWNLOAD GRAPHICS DATA ****************
21001 '
21010 ADDR1=((ADDRESS) AND 127)*2:ADDR2=4+(((ADDRESS) AND 128)/128)
21020 GOSUB 30300:A=3:GOSUB 30000
21030 A=ADDR1:GOSUB 30000:A=ADDR2:GOSUB 30000
21040 A=GRAPH(0,ADDRESS):GOSUB 30000
21050 A=GRAPH(1,ADDRESS):GOSUB 30100
21060 A=CHKSUM AND 255 :GOSUB 30000
21070 GOTO 30200
21100 '**************** UPLOAD GRAPHICS DATA ****************
21101 '
21110 GOSUB 30300:A=6:GOSUB 30000
21120 GOSUB 30500:IF STATUS=-1 THEN RETURN
21125 EVENT=0
21130 GOSUB 30400::IF STATUS=-1 THEN RETURN
21135 IF A=255 THEN GRAPH(1,EVENT)=0:GRAPH(2,EVENT)=0:GOTO 21150
21140 GRAPH(0,EVENT)=A:GOSUB 30400:IF STATUS=-1 THEN RETURN
21141 GRAPH(1,EVENT)=A
21150 EVENT=EVENT+1:IF EVENT < 256 THEN 21130
21160 GOTO 30400
30000 CHKSUM=0
30100 A1=LOF(1):CHKSUM=CHKSUM+A:GOSUB 30600
30110 IF LOF(1)<>A1 THEN 30110
30120 RETURN
30200 '***************** GET ACKN ***************************
30201 '
30220 GOSUB 30500:IF STATUS=-1 THEN RETURN
30250 STATUS=A
30270 RETURN
30300 '***************** START CODE *************************
30301 '
30310 FOR XTEMP=1 TO 16
30320 A=255:GOSUB 30600: NEXT XTEMP
30330 RETURN
30400 '***************** GET RS 232 DATA ********************
30405 COUNT=0
30410 IF COUNT> 1500 THEN STATUS=-1:RETURN
30420 IF LOF(1) = 256 THEN COUNT=COUNT+1:GOTO 30410
30430 GOSUB 30700:A=ASC(A$):RETURN
30500 '***************** GET IN SYNC ************************
30501 '
30510 STATUS=0:COUNT=0 :XTEMP =LOF(1)
30520 IF COUNT> 1500 THEN STATUS=-1:RETURN
30530 IF LOF(1) =XTEMP THEN COUNT=COUNT+1:GOTO 30520
30540 GOSUB 30700 : A=ASC(A$) : IF A=255 THEN XTEMP=XTEMP+1 : GOTO 30520
30550 RETURN
30600 ' **************** O/P TO PORT ***************
30601 '
30610 PRINT # 1,CHR$(A);:RETURN
30700 ' **************** I/P TO PORT ***************
30701 '
30710 A$=INPUT$(1,#1):RETURN