Remote-processing CAMBASIC Manuale Utente Pagina 197

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 208
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 196
Event Multitasking - 8
40 DELAY .25
50 GOTO 30
60 PRINT "match"
70 RETURN
Line 10 defines the INP task 0 to look at address 2. The bits of interest are set by the seven
parameters and are bits 0, 1 and 2. When the data at the por t is ANDed with 7, and the value is 5
(bits 0 and 2 are high and bit 1 is low), the progr am branches to line 50.
Line 20 prints the binary representation of the port of interest so that you can see the bits pattern
while you experim ent.
Line 30 actually starts the tasking process.
Line 40 creates a small delay so that the binary string printing is easily readable.
Line 50 repeats the printing.
Line 60 lets you know that an interrupt has occurred.
Using START INP and STOP INP
As shown in the example above, START INP enables the task defined by the ON INP statement. Generally, the ON INP
statements are declared at the beginning of the program for document clarity. This also makes the program r un faster by
not executing these statements in the body of the program. The START INP executes about three times faster than ON
INP.
The STOP INP halts the task checking, temporarily. It does not change any of the parameters specified by ON INP.
Executing another START INP will reactivate the task.
Tasks can be started and stopped in banks. For example:
10 START INP 0, 1, 4, 5, 7
10 STOP INP 2, 3, 4
KEYPAD MULTITASKING
CAM BASIC has built– in keypad scanner and debounce software. When activated, a keypad is scanned in the
background. When a key press is detected, the system waits 80 mS and tests again. If the key is still pressed, the system
is notified that a valid input exists. The program then jumps to a subroutine, w hich acts on the key press.
1. ON KE YPAD$ GOSUB tells the program wher e to branch when a key is pressed. The syntax is:
ON KEY PAD $ GO SUB line/label
The line/ label is the beginn ing of the subr outine to react to the key pr ess. The routine must end with
a RETURN statement. If the line/label are omitted, this task is disabled.
Vedere la pagina 196
1 2 ... 192 193 194 195 196 197 198 199 200 201 202 ... 207 208

Commenti su questo manuale

Nessun commento