; ; ; IR Remote v2.0 for the TI89 and the TI92+. ; ; A sample program for using the IR Link as a Learning Remote Control. ; ; by Sami Khawam (sKhawam@bigfoot.com) ; ; http://sami.ticalc.org ; ; The programm is very simple to use. There are 8 keys functions ; represented by F1-F8 keys. To make the program record data ; from a remote control, press Enter and choose the key and then the ; frequency and the time base. If you don't know thoses value , eg. ; when dealing with an unknow remote, you should experiment by using ; differents ones. Try also the classic Time Base/Frequency combinations ; like 15/38Khz and 12/32Khz. ; ; This programm needs the STANDART version of the IR Link. ; The IRLib library is needed. ; ; ; If you haven't yet heard of the IR Link, take a look at my homepage: ; ; http://sami.ticalc.org ; include "doorsos.h" include "graphlib.h" include "userlib.h" include "hexlib.h" include "irlib.h" xdef _ti89 xdef _ti92plus xdef _main xdef _comment ;************************* Start of Program ************************** _main: clr d3 clr d4 clr d5 jsr graphlib::clr_scr2 SetFont #1 WriteStr #8,#5,#0,_comment SetFont #2 WriteStr #0,#40,#1,Text1 WriteStr #0,#60,#1,Text2 clr.b $60000C bset.b #6,$60000C ; Turn on control mode Loop: jsr userlib::idle_loop cmp #264,d0 ; exit beq Exit cmp #13,d0 ; Enter beq RecordRemote cmp #268,d0 blt Loop sub #268,d0 ; 268 is the code for F1 cmp #7,d0 ; 268+7=275, code for F8 bgt Loop lea CmdTable(PC),a0 ; Now A0 points to the data start. lsl.w #5,d0 ; Multiply by 32, since we use 32 bytes for each ; of the 5 commands. add.l d0,a0 move.b #30,d3 ; Tell the link that we are going to send jsr irlib::PutByte ; 30 bytes. bsr SendHeader move.w #29,d5 SNextByte: move.b (a0)+,d3 jsr irlib::PutByte dbra.w d5,SNextByte ; sub.w #1,d5 ; cmp.w #0,d5 ; bne SNextByte bra Loop Exit: jsr doorsos::reset_link rts SendHeader: move.b (a0)+,d3 ; Send the time base. jsr irlib::PutByte clr d2 move.b (a0)+,d2 ; Read the frequency information. jsr irlib::Freq2Delay move.w #15,d4 ; Send both of them. jsr irlib::PutLink rts ; Return. RecordRemote jsr graphlib::clr_scr2 SetFont #1 WriteStr #8,#5,#0,_comment WriteStr #0,#30,#1,Text3 RRKLoop: jsr userlib::idle_loop cmp #264,d0 ; exit. Return to main loop. beq _main cmp #268,d0 blt RRKLoop sub #268,d0 ; 268 is the code for F1 cmp #7,d0 ; 268+7=275, code for F8 bgt RRKLoop lea CmdTable(PC),a3 ; Now A3 points to the data start. lsl.w #5,d0 ; Multiply by 32, since we use 32 bytes for each ; of the 5 commands. add.l d0,a3 ; a3 points now to the start of data. WriteStr #0,#40,#1,Text4 ; Get time base move.w #5,d1 ; Where to print the value. move.w #8,d2 clr d5 ; Min time base = 0 move.b #$FE,d6 ; Max time base = $FE bsr InputValue ; Get time base from user. add #1,a3 WriteStr #0,#48,#1,Text5 ; Get freq move.w #6,d1 ; Where to print the value. move.w #13,d2 move.b #30,d5 ; Min freq = 30Khz move.b #48,d6 ; Max freq = 48Khz bsr InputValue ; Get time base from user. move.b #$5E,d3 ; Tell the link that we want to receive jsr irlib::PutByte ; 30 bytes. sub #1,a3 move.l a3,a0 bsr SendHeader ; Send the header. move.l a0,a3 jsr graphlib::clr_scr2 WriteStr #20,#10,#0,Text6 bclr.b #0,$60000E ; Set R1 bclr.b #1,$60000E ; Set W1 move.w #1,-(a7) jsr doorsos::ST_busy lea 2(a7),a7 WaitSig: tst.w (doorsos::kb_vars+$1C) beq CheckLines move.w (doorsos::kb_vars+$1E),d0 clr.w (doorsos::kb_vars+$1C) cmp.w #264,d0 beq _main CheckLines: btst.b #2,$60000E bne ReceiveData btst.b #3,$60000E bne ReceiveData bra WaitSig ; move.l #5,d1 ; move.l #1,d2 ReceiveData: move.w #29,d5 GNextByte: jsr irlib::GetByte move.b d3,(a3)+ ; movem d3-d5,-(a7) ; ; clr.l d0 ; move.b d3,d0 ; move.l #1,d3 ; jsr hexlib::put_hex ; ; add.l #2,d2 ; cmp.l #20,d2 ; blt NoNewLine ; add.l #1,d1 ; clr.l d1 ;NoNewLine ; movem (a7)+,d3-d5 dbra.w d5,GNextByte ; sub.w #1,d5 ; cmp.w #0,d5 ; bne GNextByte bra _main ; InputValue ; Input: d1 ( row), d2 (column) ; d5 ( min val), d6 ( max val ) ; a3 ( address where the byte will be stored ) ; Output: (a3) contains byte read ; InputValue: movem d1-d6,-(a7) ; Save the coordinates of the numbers move.b (a3),d4 ; Read the data from memory. clr.b d0 Convert2BCD subi.b #10,d4 bcs IVCont addi.b #$10,d0 bra Convert2BCD IVCont addi.b #10,d4 or.b d4,d0 move.w #1,d4 jsr hexlib::put_hex jsr userlib::idle_loop movem (a7)+,d1-d6 ; Restore the coordinates of the numbers cmp #KEY_DOWN,d0 ; down beq Decrement cmp #KEY_UP,d0 ; up beq Increment cmp #13,d0 ; Enter beq IVExit bra InputValue Decrement: move.b (a3),d0 ; Read the data from memory. cmp.b d5,d0 beq InputValue sub.b #1,d0 move.b d0,(a3) ; Write data to memory. bra InputValue Increment: move.b (a3),d0 ; Read the data from memory. cmp.b d6,d0 beq InputValue add.b #1,d0 move.b d0,(a3) ; Write data to memory. bra InputValue IVExit: rts CmdTable: dc.b 10,32 dc.b 1,2,3,4,5,6,7,8,9,$Fe dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 11,34 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 12,36 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 13,38 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 14,40 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 15,42 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 16,44 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 17,46 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 Text1: dc.b "Enter to Record.",0 Text2: dc.b "F1-F8 to Send.",0 Text3: dc.b "Key (F1-F8) to Assing:",0 Text4: dc.b "Time Base:",0 Text5: dc.b "Frequency (KHz):",0 Text6: dc.b "Waiting for data...",0 _comment dc.b "IR Remote by Sami Khawam",0 end