BS2P Code Advice for Novice
I'm working on a project with the hope of using a PS2 controller through a BS2P to control a track vehicle. I've mapped the buttons and joysticks on the controller to determine the input values. My request is guidance on·code that would read the values then based on the values output commands to the various functions on the vehicle. I realize that a bunch of If-Then statements should do it but I can't help but think there is a more streamlined way of accomplishing this. At first "read" it appears that the "Branch" command would do it but am I correct in that the "offsets" values have to be numerically sequenced; 0,1,2? The values on each controller button is unique and not necessarily in a·sequence.
Any guidance would be very helpful.
Brian
Any guidance would be very helpful.
Brian
Comments
What joystick do you have for this project?
Brian
Jeff T.
··Joystick VAR Byte
Main:
DEBUGIN "joystick", DEC joystick,
ON·joystick·GOSUB forward,·back
forward:
·pulsout, something
·pulsout, something
·GOTO main
back:
·pulsout, something
·pulsout, something
·GOTO main
Am I on the right track? As stated earlier, knowing the amount of button/joystick combinations that can be sent I'm trying to streamline the code.
Thanks for the help
Brian
·Joystick VAR Byte
·result VAR Byte
DEBUGIN DEC joystick
LOOKDOWN joystick, [noparse][[/noparse]128, 255], result
ON·result GOSUB forward, back
LOOKDOWN matches the joystick value with the values in the lookdown table and puts the position of the value in result. Result will now·have a number 0,1,2,3... etc that can be used for the ON....GOSUB index.
Jeff T.
Got it. Thank you so much for your help.
Brian