Package lejos.hardware.device
Class PSPNXController
- java.lang.Object
-
- lejos.hardware.Device
-
- lejos.hardware.sensor.BaseSensor
-
- lejos.hardware.sensor.I2CSensor
-
- lejos.hardware.device.PSPNXController
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,SensorConstants,SensorMode,SensorModes,SampleProvider
public class PSPNXController extends I2CSensor
This class allows you to use a Sony Playstation 2 controller to control your robot in conjunction with the Mindsensors.com PSP-Nx interface. The controller has 2 analog joysticks and 16 buttons. See www.mindsensors.com
-
-
Field Summary
-
Fields inherited from class lejos.hardware.sensor.I2CSensor
address, DEFAULT_I2C_ADDRESS, port, REG_PRODUCT_ID, REG_VENDOR_ID, REG_VERSION, retryCount
-
Fields inherited from class lejos.hardware.sensor.BaseSensor
currentMode, modes
-
Fields inherited from interface lejos.hardware.sensor.SensorConstants
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, BROWN, GREEN, GREEN_INDEX, MAX_TYPE, MIN_TYPE, MODE_RAW, NXT_ADC_RES, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HIGHSPEED, TYPE_HIGHSPEED_9V, TYPE_HISPEED, TYPE_LIGHT_ACTIVE, TYPE_LIGHT_INACTIVE, TYPE_LOWSPEED, TYPE_LOWSPEED_9V, TYPE_NO_SENSOR, TYPE_REFLECTION, TYPE_SOUND_DB, TYPE_SOUND_DBA, TYPE_SWITCH, TYPE_TEMPERATURE, WHITE, YELLOW
-
-
Constructor Summary
Constructors Constructor Description PSPNXController(I2CPort port)PSPNXController(I2CPort port, int address)PSPNXController(Port port)PSPNXController(Port port, int address)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int[]getButtons()Each bit in the short byte represents the boolean (pressed or not pressed) of a button.intgetLeftX()intgetLeftY()bytegetMode()Returns the current operating mode of the sensor.intgetRightX()intgetRightY()voidpowerUp(boolean activate)voidsetADPAMode(boolean activate)Use ADPA mode only if you are trying to connect more than one I2C sensor to a single port.voidsetDigitalMode(boolean activate)-
Methods inherited from class lejos.hardware.sensor.I2CSensor
fetchString, getAddress, getData, getData, getPort, getProductID, getRetryCount, getVendorID, getVersion, sendData, sendData, sendData, setAddress, setRetryCount
-
Methods inherited from class lejos.hardware.sensor.BaseSensor
fetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, getName, sampleSize, setCurrentMode, setCurrentMode, setModes
-
Methods inherited from class lejos.hardware.Device
close, releaseOnClose
-
-
-
-
Method Detail
-
powerUp
public void powerUp(boolean activate)
-
getButtons
public int[] getButtons()
Each bit in the short byte represents the boolean (pressed or not pressed) of a button.- Returns:
- Data for all 16 buttons as a int array
-
setDigitalMode
public void setDigitalMode(boolean activate)
-
getLeftX
public int getLeftX()
-
getLeftY
public int getLeftY()
-
getRightX
public int getRightX()
-
getRightY
public int getRightY()
-
getMode
public byte getMode()
Returns the current operating mode of the sensor. (put list of possible return values here:)- Returns:
- -1 if error otherwise the operating mode
-
setADPAMode
public void setADPAMode(boolean activate)
Use ADPA mode only if you are trying to connect more than one I2C sensor to a single port.- Parameters:
activate-
-
-