lejos.nxt.addon
Class TouchMUX

java.lang.Object
  extended by lejos.nxt.addon.TouchMUX

public class TouchMUX
extends Object

Interface for the Mindsensors Touch Multiplexer. This device allows up to three touch sensors to be attached to a single NXT sensor port.

Author:
Andy

Field Summary
static int ID_T1
          Bit ID returned by readSensors when sensor T1 is pressed
static int ID_T2
          Bit ID returned by readSensors when sensor T1 is pressed
static int ID_T3
          Bit ID returned by readSensors when sensor T1 is pressed
static int NUMBER_OF_SENSORS
          number of touch sensors supported by this device
 Touch T1
          Instance for the touch sensor connected to port T1
 Touch T2
          Instance for the touch sensor connected to port T2
 Touch T3
          Instance for the touch sensor connected to port T3
 
Constructor Summary
TouchMUX(ADSensorPort port)
          Create a object to provide access to a touch sensor multiplexer
 
Method Summary
 Touch getInstance(int id)
          Return a Touch interface providing access to the sensor specified by the given id.
 int readSensors()
          Read the touch multiplexer and return a bit mask showing which sensors are currently pressed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUMBER_OF_SENSORS

public static final int NUMBER_OF_SENSORS
number of touch sensors supported by this device

See Also:
Constant Field Values

ID_T1

public static final int ID_T1
Bit ID returned by readSensors when sensor T1 is pressed

See Also:
Constant Field Values

ID_T2

public static final int ID_T2
Bit ID returned by readSensors when sensor T1 is pressed

See Also:
Constant Field Values

ID_T3

public static final int ID_T3
Bit ID returned by readSensors when sensor T1 is pressed

See Also:
Constant Field Values

T1

public final Touch T1
Instance for the touch sensor connected to port T1


T2

public final Touch T2
Instance for the touch sensor connected to port T2


T3

public final Touch T3
Instance for the touch sensor connected to port T3

Constructor Detail

TouchMUX

public TouchMUX(ADSensorPort port)
Create a object to provide access to a touch sensor multiplexer

Parameters:
port - The NXT sensor port to which the multiplexer is attached
Method Detail

getInstance

public Touch getInstance(int id)
Return a Touch interface providing access to the sensor specified by the given id.

Parameters:
id - a number between 0..NUMBER_OF_SENSORS-1
Returns:
the requested Touch interface

readSensors

public int readSensors()
Read the touch multiplexer and return a bit mask showing which sensors are currently pressed. Returns ID_T1 if T1 is pressed, ID_T2 if T2 is pressed and ID_T3 id T3 is pressed. If more then one sensor is pressed the return will be an or of the values.

Returns:
bit mask showing which sensor buttons are pressed.