Package lejos.hardware.device
Class TouchMUX
- java.lang.Object
-
- lejos.hardware.Device
-
- lejos.hardware.sensor.BaseSensor
-
- lejos.hardware.sensor.AnalogSensor
-
- lejos.hardware.device.TouchMUX
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,SensorConstants,SensorMode,SensorModes,SampleProvider
public class TouchMUX extends AnalogSensor
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
Fields Modifier and Type Field Description static intID_T1Bit ID returned by readSensors when sensor T1 is pressedstatic intID_T2Bit ID returned by readSensors when sensor T1 is pressedstatic intID_T3Bit ID returned by readSensors when sensor T1 is pressedstatic intNUMBER_OF_SENSORSnumber of touch sensors supported by this deviceTouchT1Instance for the touch sensor connected to port T1TouchT2Instance for the touch sensor connected to port T2TouchT3Instance for the touch sensor connected to port T3-
Fields inherited from class lejos.hardware.sensor.AnalogSensor
currentType, port
-
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 TouchMUX(AnalogPort port)Create a object to provide access to a touch sensor multiplexerTouchMUX(Port port)Create a object to provide access to a touch sensor multiplexer
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TouchgetInstance(int id)Return a Touch interface providing access to the sensor specified by the given id.intreadSensors()Read the touch multiplexer and return a bit mask showing which sensors are currently pressed.-
Methods inherited from class lejos.hardware.sensor.AnalogSensor
normalize, NXTRawIntValue, NXTRawValue, switchType
-
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
-
-
-
-
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(AnalogPort port)
Create a object to provide access to a touch sensor multiplexer- Parameters:
port- The NXT sensor port to which the multiplexer is attached
-
TouchMUX
public TouchMUX(Port 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.
-
-