Class 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 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.