'>Hextor_6IR.BSx '============================================================== '{$stamp BS2Sx} '============================================================== 'Introduction to controlling Hextor using the infra-red 'communication link. (IR-link) 'To use the IR-link the receiver must first be trained to 'recognise the codes from your handset. 'See the 'Hextor-Manual, Documents, IR-Receiver'. ' 'Note how the srmlQT settings remain in force until re-written. ' 'New '--- ' 'Constant: 'Variable: 'Subroutine: '============================================================== BOStx con 0 'pin serial to BOS processor BOSrx con 1 'pin serial from BOS processor epower con 2 'pin high turns on power to electronics BOSbusy var in4 'pin BOS processor busy => high irrx con 5 'pin infra red comms in, i96n Rled con 8 'pin high turns on right green led Lled con 9 'pin high turns on left red led i96n con 16624 '9600 baud, 8 bit, no parity, inverted poweruptime con 1500 'pause before powering up electronics BOScmnd var byte 'byte to send to BOS processor Sptr var byte 'pointer to DATA sequence string arg1 var byte 'command argument irin var byte 'infra-red command 'during downloading the power to the electronics is turned off, 'if it is turned back on again too soon the electronics, 'especially the ultrasonics do not power up properly, 'so wait poweruptime before turning power on. init: output Rled output Lled high Rled high Lled pause poweruptime high epower 'turn on electronics init1:gosub irget pause 100 'no point in listening too often if irin<>0 then init1 'wait for ir to initialise debug cls 'Sequence in DATA statments '--------------------------- wiggle1 DATA "s",4,"r",170,"QUDFBCRLOBPMz" wiggle2 DATA "s",0,"r",200,"TUFFBBz" wiggle3 DATA "TUFRRLLBz" 'Program start '------------- start:toggle Rled pause 50 gosub irget debug ?irin goto start if irin=0 then start '0 is idle value if irin=1 then wig1 'trained key 1 if irin=2 then wig2 'trained key 2 if irin=3 then wig3 'trained key 3 toggle Lled pause 50 goto start wig1: Sptr =wiggle1 gosub dosequence goto start 'check ir wig2: Sptr =wiggle2 gosub dosequence goto start 'check ir wig3: Sptr =wiggle3 gosub dosequence goto start 'check ir '------------- subroutines --------------------- irget:'listen to InfraRed co-processor irin =0 'set to idle value serin irrx,i96n,100,noir,[irin] 'valid 0 - 8 irin =irin & $F 'mask high nibble timing data noir: return '-------------------- dosequence: 'loop round until BCbyte="z" read Sptr,BOScmnd if BOScmnd="z" then doneR arg1 =255 lookdown BOScmnd,["srml"],arg1 if arg1=255 then t1 'BOScmnd not srm or l, jump to t1 Sptr =Sptr+1 'point to argument read Sptr,arg1 'read it gosub tellBOS1d 'send them goto nxt 'go onto next operation t1: gosub tellBOS nxt: Sptr =Sptr+1 goto dosequence doneR:return '-------------------- tellBOS: pause 10 'give the BOS time to go into receive mode if BOSbusy=1 then tellBOS 'wait until BOS not busy serout BOStx,i96n,[BOScmnd] return '-------------------- tellBOS1d: 'send command plus one argument in decimal pause 10 'give the BOS time to go into receive mode if BOSbusy=1 then tellBOS1d 'wait until BOS not busy serout BOStx,i96n,50,[BOScmnd,dec arg1,cr] '50 pace time return '------------------------ end program -------------------------