Class EV3IRSensor

    • Constructor Detail

      • EV3IRSensor

        public EV3IRSensor​(UARTPort port)
      • EV3IRSensor

        public EV3IRSensor​(Port port)
    • Method Detail

      • init

        protected void init()
      • getRemoteCommand

        public int getRemoteCommand​(int chan)
        Return the current remote command from the specified channel. Remote commands are a single numeric value which represents which button on the Lego IR remote is currently pressed (0 means no buttons pressed). Four channels are supported (0-3) which correspond to 1-4 on the remote. The button values are:
        1 TOP-LEFT
        2 BOTTOM-LEFT
        3 TOP-RIGHT
        4 BOTTOM-RIGHT
        5 TOP-LEFT + TOP-RIGHT
        6 TOP-LEFT + BOTTOM-RIGHT
        7 BOTTOM-LEFT + TOP-RIGHT
        8 BOTTOM-LEFT + BOTTOM-RIGHT
        9 CENTRE/BEACON
        10 BOTTOM-LEFT + TOP-LEFT
        11 TOP-RIGHT + BOTTOM-RIGHT
        Parameters:
        chan - channel to obtain the command for
        Returns:
        the current command
      • getRemoteCommands

        public void getRemoteCommands​(byte[] cmds,
                                      int offset,
                                      int len)
        Obtain the commands associated with one or more channels. Each element of the array contains the command for the associated channel (0-3).
        Parameters:
        cmds - the array to store the commands
        offset - the offset to start storing
        len - the number of commands to store.
      • getDistanceMode

        public SensorMode getDistanceMode()
        EV3 Infra Red sensor, Distance mode
        Measures the distance to an object in front of the sensor.

        Size and content of the sample
        The sample contains one element giving the distance to an object in front of the sensor. The distance provided is very roughly equivalent to meters but needs conversion to give better distance. See product page for details.
        The effective range of the sensor in Distance mode is about 5 to 50 centimeters. Outside this range a zero is returned for low values and positive infinity for high values.

        Returns:
        A sampleProvider See leJOS conventions for SampleProviders See Sensor Product page
      • getSeekMode

        public SensorMode getSeekMode()
        EV3 Infra Red sensor, Seek mode
        In seek mode the sensor locates up to four beacons and provides bearing and distance of each beacon.

        Size and content of the sample
        The sample contains four pairs of elements in a single sample. Each pair gives bearing of and distance to the beacon. The first pair of elements is associated with a beacon transmitting on channel 0, the second pair with a beacon transmitting on channel 1 etc.
        The bearing values range from -25 to +25 (with values increasing clockwise when looking from behind the sensor). A bearing of 0 indicates the beacon is directly in front of the sensor.
        Distance values are not to scale. Al increasing values indicate increasing distance.
        If no beacon is detected both bearing is set to zero, and distance to positive infinity.

        Returns:
        A sampleProvider See leJOS conventions for SampleProviders See Sensor Product page