[Coco] The CM17A "Firecracker" works on the Coco - Final Code Sample to wirelessly control all 256 X10 Units.

K. Pruitt pruittk at roadrunner.com
Fri Jan 23 02:34:38 EST 2015


Okay folks, here is the final version of this code sample.  This version 
handles all 256 X-10 units.

The code below is as top-down and easy to follow as I can make it. If 
somethiong doesn't make sense, just ask and I will confuse you more with my 
answer.

This is my first attempt at basic since 1988 when I moved permanently to 
OS-9.  BASIC is fun, but typing in all caps is not fun. So I'm going back to 
my nice comfortable assembly is OS-9.

But then again I haven't added the dim or brighten handling to this program 
yet...

Programming this thing is easy, so I hope my sample code helps someone out 
there really do something fun with the CM17A.

Just remember that we're not sending data through the serial port, we're 
just manipulating the RTS and DTR
signals to control the CM17A.  I like to think of it as working sort of like 
a player piano.  But then again I like weird analogies.


100 '* CM17A "Firecracker" BASIC Interface for the Color Computer
110 '* Allows simple wireless control of all 256 X10 Units
120 '* This is demo code and contains no error handling
130 CLS
140 DIM LB(16):DIM UB(16):DIM O(8):DIM F(8)
150 FOR D=1 TO 16:READ LB(D):NEXT D
160 FOR D=1 TO 16:READ UB(D):NEXT D
170 FOR D=1 TO 8:READ O(D):NEXT D
180 FOR D=1 TO 8:READ F(D):NEXT D
190 '* Get User Input
200 INPUT "HOUSE   (A-P)        :";H$
210 INPUT "UNIT    (1-16)       :";U:IF U>8 THEN B=1 ELSE B=0
220 INPUT "COMMAND (O)N OR OF(F):";C$
230 IF B=1 THEN U=INT(U/2)
240 '* Process Housecode
250 IF B=0 THEN H=ASC(H$)-64:H=LB(H) ELSE IF B=1 THEN H=ASC(H$)-64:H=UB(H)
260 '* Process Command
270 IF C$="O" THEN C=O(U)ELSE IF C$="F" THEN C=F(U)
280 '* Send Header (Header never changes)
290 X=&HD5:GOSUB 360:X=&HAA:GOSUB 360
300 '* Send Housecode/Unit Code, then Command Code
310 X=H:GOSUB 360:X=C:GOSUB 360
320 '* Send Footer (Footer never changes)
330 X=&HAD:GOSUB 360
340 END
350 '* Convert to binary and procces it to the CM17A as 8'S and 1'S
360 FOR L=7 TO 0 STEP-1
370 P=2^L:P=INT(P)
380 IF X>=P THEN X=X-P:POKE &HFF6A,8 ELSE POKE &HFF6A,1
390 '* Put the CM17A in standby mode between signals
400 POKE &HFF6A,&H0D
410 NEXT L
420 RETURN
430 '*
440 '* House Codes - Lower Bank A-P 1-8
450 DATA &H60,&H70,&H40,&H50,&H80,&H90,&HA0,&HB0
460 DATA &HE0,&HF0,&HC0,&HD4,&H00,&H10,&H20,&H30
470 '* House Codes - Upper Bank A-P 9-16
480 DATA &H64,&H74,&H44,&H54,&H84,&H94,&HA4,&HB4
490 DATA &HE4,&HF4,&HC4,&HD0,&H0A,&H14,&H23,&H34
500 '* Command Codes - ON AND OFF
510 DATA &H00,&H10,&H08,&H18,&H40,&H50,&H48,&H58
520 DATA &H20,&H30,&H28,&H38,&H60,&H70,&H68,&H78



More information about the Coco mailing list