BNC 630 User Manual

Page 91

Advertising
background image

86

GetCommand:

CLS

PRINT : PRINT
PRINT " 1. Power on/off"
PRINT " 2. Channel Up"
PRINT " 3. Channel Down"
PRINT " 4. Volume Up"
PRINT " 5. Volume Down"
PRINT
PRINT " ESC To exit program"
PRINT
PRINT " Please select a command >"

CommandPoll:
a$ = INKEY$
IF a$ = "" THEN GOTO CommandPoll

IF a$ = CHR$(27) THEN SYSTEM ' Exit the program on ESC keypress

IF a$ < "1" OR a$ > "5" THEN GOTO GetCommand ' Is input valid?

PRINT : PRINT
PRINT "Command sent." ' Tell user command will be sent.

a = VAL(a$) ' Convert selection to a number, 1 to 5

NumPulses = Array(a) ' Look up no. of pulses for this command

' The variable NumPulses now has the number of infrared pulses to form this remote
' control command. Download this many "t" characters to the 630 which causes it to
' trigger that many pulses in Burst mode.

a$ = STRING$(NumPulses, "t") ' Form a string with NumPulses number
' of "t" chars in it. I.e., if
' Numpulses=3, then a$="ttt"

PRINT #1, a$; ' Dump the "t"'s to the 630

' The 630 will now trigger a burst for each "t" char we sent it. After the 630
' executes each "t" command, it will return a prompt character (">"). We wish to wait
' until after all prompts have come in, since that's when the 630 has finished
' processing the last "t". The GetResponse1 subroutine has a time-out feature which will
' accomplish this purpose.

GOSUB GetResponse1 ' Wait for and get response from 630 to a$

GOTO GetCommand ' Go get another remote control command

'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
' SUBROUTINES
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------

' The subroutines needed for this example are listed in Appendix A

Advertising