public class Joystick extends AnalogComponent
Example of module: http://www.sunfounder.com/joystick-ps2-module.html
To decode the signals received from this joystick module, we need to use an ADC (Analog to Digital Converter). We then decode the x, y and bt signals from analogic to digital.
|Constructor and Description|
Constructor for a joystick using a specifc ADC instance, and specific channels on this ADC for the x, y and bt variations of the joystick.
|Modifier and Type||Method and Description|
Returns the main current position of the joystick among (by priority):
Returns an array containing raw digital outputs respectively for variations on the X axis variations on the Y axis variations on the push button
Returns the (x, y) position of the joystick, or (-1,-1) if button pressed.
public Joystick(ADC adc, ADCChannel xChannel, ADCChannel yChannel, ADCChannel btChannel)
adc- the ADC to use to decode analogic signals from the joystick.
xChannel- the channel on the ADC used to read variations on the x axis of the joystick.
yChannel- the channel on the ADC used to read variations on the y axis of the joystick.
btChannel- the channel on the ADC used to read variations on the push button of the joystick.
public java.lang.String getPosition()
1. press-down 2. up/down 4. left/right 5. home
Note: "by priority" means
"if 'home' and 'press-down', 'press-down' returned".
public int getXYPosition()
x and y values are between 0 and 255.
public int getRawData()