For twin Button press ...
just add another scan loop ...
Code:
SCAN:
RESULT = 0
FOR I = 0 to 4
BVar = 0
BUTTON PORTB.0[I],0,255,0,BVar,1,Action
NEXT I
GOTO SCAN ' No need to go further ...
Action :
RESULT.I = 1 ' Store the first button pushed
PAUSE 250 ' Let a little time for pushing the
' next button ...
FOR J= 0 to 4
IF J = I THEN I = I+1 ' Button already pushed !!! ... Skip test.
BVar = 0
BUTTON PORTB.0[I],0,255,0,BVar,1,Action2
NEXT J
GOTO Action1 ' Only one button Pushed ...
Action2:
RESULT.J = 1 ' Store the second button pushed
Action1:
SELECT CASE RESULT
CASE %00000001 ' Button 0 alone
...
CASE %00000010 ' Button 1 Alone
...
CASE %00000100 ' Button 2 Alone
...
...
...
CASE %00000011 ' Buttons 0 and 1 ... or 1 and 0
...
CASE %00000101 ' Buttons 0 and 2 ... or 2 and 0
...
...
...
CASE %00000110 ' Buttons 1 and 2 ... or 2 and 1
...
CASE %00001010 ' Buttons 1 and 3 ... or 3 and 1
...
...
...
CASE %00001100 ' Buttons 2 and 3 ... or 3 and 2
...
CASE %00010100 ' Buttons 2 and 4 ... or 4 and 2
CASE ELSE GOTO SCAN
END SELECT
with 16 bits for RESULT, RESULT.Highbyte for I, RESULT.Lowbyte for J, .... you can even check in which order the buttons have been pushed ...
Too much ??? Ok, I take it back to my kangaroo pocket ...
Alain
Bookmarks