:XHOME.BA House control using X10͹ :Revised: 5/7/03 :(C) 05/01/2003 R. H. Pigford:Read X-10 command data file (1 fileE:in RAM for each day of the week).j:Data file format ex: X-WED.DO:Compare to day and time.:Send Command strings to FireCracker500ƺ  D$(10),N$(10),AD$(10),D1$(10),T1$(10),D2$(10),T2$(10) #Z15(N0 :allows header in X-DAY.DO filesT22000 :reset FireCrackerd:"XHOME.BA (c) R.H.Pigford ":@308,"ESC to Quit";n 500ʻs@40,"____Name_____ Adr ___On____ ___Off___";:====Begin main XHOME.BA loop =====5(,5)"00:00"N0:500: switch to next day's file & dataG@27," "Ъ;bA$:A$""224:225rA$(27)ͺ D1$(Z)ݬ 230 : 300 T1$(Z)(,5) 250 : 300߼SELECT$AD$(Z)"N":1000: 400:turn it on, D2$(Z)ݬ 330 : 400J T2$(Z)(,5) 350 : 400L^SELECT$AD$(Z)"F":1000:400:turn it offm:==== screen riffle ======D1$N$(Z)" "AD$(Z)" "D1$(Z)" "T1$(Z)" "D2$(Z)" "T2$(Z)Ͻ:Q=Q+1:IFQ=5THENQ=1ܽ@80,D1$꽳@120,D2$@160,D3$@200,D4$@240,D5$8D5$D4$:D4$D3$:D3$D2$:D2$D1$OZZ1:ZN1 Z1u 200 :loop over and over again:===== get data from XDATA.DO =====FN$"X-"Ь".DO"Ⱦ FN$ AS #1 #1,N$(N),AD$(N),D1$(N),T1$(N),D2$(N),T2$(N) :data set counter! (1) 5900&NN1:530:N 1:Y:=======================a:B1(LOOKUP$,(SELECT$,1)) B10 "Error":::Get ACTion byte from endɿ:߿ACT$(SELECT$,1)::Calculate Byte 1 (B1) :B1(B11) 165 ACT$"D" 1200K ACT$"B" 1250p$NUM((SELECT$,(SELECT$)1))1. NUM 7 B1B143:4:Calculate Byte 2 (B2)5:8B2(NUM 1) 16BB2B2 ((NUM 2) 4)LB2B2 ((NUM 4) 16) V ACT$"F" B2B2 32([:G\:Now go send the commandO]:p` 1300 : Skip DIM & BRIGHTxe:B2 152 : DIM Command. Set B2 1300 : Go send commandB2 136 : BRIGHT Command. Set B2 : :Send 5 Bytes below as follows:6 :2 Header, 2 Data, 1 Footer> :bTX213 : First Header Bytem 1500(TX170 : Second Header Byte2 1500<TXB1 : First Data ByteF 1500PTXB2 : Second Data ByteZ 1500dTX173 : Footer Byte!n 1500)o:Ip:========================dq:End of Subroutine 1r:========================x::=================================: Sub 2 - Write single byte (TX): (called by Sub 1) :2: Write TX to FireCracker usingY: RTS and DTR signals, MSB first:=================================: SHOWTX$"Y" 1501 : 1510 X 7 0 1 TX (2X) "1"; : "0"; X " ":$P1(186) : Read PortB of 8155CP1P1 247: Clear BIT 3i 186, P1 : Select RS-232 Portq::Loop through bits starting with:the Most Significant bit: X 7 0 1 TX (2X) 1600:: Bit is a zero - send it out!:D 186, P1 128 :Send a "0"h" 186, P1 127 :Back to idle, 1620 : Skip sending a "1"1:2:Bit is a one - send it out3:@ 186, P1 64 : Send a "1"J 186, P1 191 : Back to idleO:T XX:@Y:==========================[Z:End of Subroutine 2}[:==========================^dž::=================================: Sub 3 - FireCracker Reset:: Call this routine first!(:=================================0:VP1(186) : Read PortB of 8155uP1P1 247: Clear BIT 3 186, P1 : Select RS-232 Port:: Set both RTS and DTR to zero: 186, P1 128 :Set RTS low 186, P1 64 :Set DTR low9 X1 10: X:Small DelayA:e: Set both RTS and DTR to onem :  186, P1 63 :Back to idle:: Set LOOKUP variable for later:LOOKUP$"MNOPCDABEFGHKLIJ"::=========================*:End of Subroutine 3K:=========================Q wʸ :"*** Communications Error ***"} ʠ: