Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## lejos.nxt
Class OpticalDistanceSensor

    java.lang.Object
      lejos.nxt.I2CSensor
          lejos.nxt.OpticalDistanceSensor

All Implemented Interfaces:
  SensorConstants

    public class OpticalDistanceSensor

extends I2CSensor

Supports Mindsensors DIST-Nx series of Optical Distance Sensor.
This sensor is used for greater precision than the Ultrasonic Sensor.

Author:
  Michael Smith
  Lum, Many thanks for helping me test this class.

Field Summary
`static byte` | `CUSTOM` Custom sensor
`static byte` | `GP2D12`
`static byte` | `GP2D120` DIST-Nx-Short
`static byte` | `GP2YA02` DIST-Nx-Long
`static byte` | `GP2YA21` DIST-Nx-Medium

Fields inherited from interface lejos.nxt.SensorConstants
`MODE_ANGLESTEP, MODE_BOOLEAN, MODE_CELSIUS, MODE_FARENHEIT, MODE_PCTFULLSCALE, MODE_PERIODCOUNTER, MODE_RAW, MODE_TRANSITIONCNT, TYPE_ANGLE, TYPE_CUSTOM, 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`

Constructor Summary
`OpticalDistanceSensor(I2CPort port)`

Method Summary
`int` | `getCurveCount()` Gets the number of points that will be in the curve.
`int` | `getDistance()` Returns the distance from the object in millimeters.
`int` | `getDistLSB()` Returns the current distance in millimeters for the LSB.
`int` | `getDistMaxLSB()` Gets the max value in millimeters for the LSB. Used for recalibrating the sensor.
`int` | `getDistMaxMSB()` Gets the max value in millimeters for the MSB. Used for recalibrating the sensor.
`int` | `getDistMinLSB()` Gets the min value in millimeters for the LSB. Used for recalibrating the sensor.
`int` | `getDistMinMSB()` Gets the min value in millimeters for the MSB. Used for recalibrating the sensor.
`int` | `getDistMSB()` Returns the current distance in millimeters for MSB.
`int` | `getDistPointLSB(int index)` Gets millimeter value of the specific index for the LSB. Used for recalibrating the sensor.
`int` | `getDistPointMSB(int index)` Gets millimeter value of the specific index for the MSB.
`int` | `getSensorModule()` Used to determin the sensore module that is configured.
`int` | `getVoltLSB()` Returns the current voltage level in millivolts for the LSB.
`int` | `getVoltMSB()` Returns the current voltage level in millivolts for the MSB.
`int` | `getVoltPointLSB(int index)` Gets millivolts value of the specific index for the LSB.
`int` | `getVoltPointMSB(int index)` Gets millivolts value of the specific index for the MSB.
`void` | `powerOff()` Turns power to the sensor module off.
`void` | `powerOn()` Turns the sensor module on.
`void` | `setAPDAOff()` Disables (ADPA) Auto Detecting Parallel Architecture. Disabled by default.
`void` | `setAPDAOn()` Enables (ADPA) Auto Detecting Parallel Architecture.
`void` | `setCurveCount(int value)` Sets the number of points that will be in the configured curve.
`void` | `setDistMaxLSB(int value)` Sets the max value in millimeters for LSB. Used for recalibrating the sensor.
`void` | `setDistMaxMSB(int value)` Sets the max value in millimeters for the MSB. Used for recalibrating the sensor.
`void` | `setDistMinLSB(int value)` Sets the min value in millimeters for the LSB. Used for recalibrating the sensor.
`void` | `setDistMinMSB(int value)` Sets the min value in millimeters for the MSB. Used for recalibrating the sensor.
`void` | `setDistPointLSB(int index, int value)` Sets millimeter value of the specific index for the LSB.
`void` | `setDistPointMSB(int index, int value)` Sets millimeter value of the specific index for the MSB.
`void` | `setSensorModule(byte module)` This only needs the be run if you are changing the sensor.
`void` | `setVoltPointLSB(int index, int value)` Sets millivolts value of the specific index for the LSB.
`void` | `setVoltPointMSB(int index, int value)` Sets millivolts value of the specific index for the MSB.

Methods inherited from class lejos.nxt.I2CSensor
`getData, getPort, getProductID, getSensorType, getVersion, sendData, sendData, setAddress`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait`

Field Detail

### GP2D12

    public static final byte GP2D12

See Also:
  Constant Field Values

### GP2D120

    public static final byte GP2D120

  DIST-Nx-Short

  See Also:
    Constant Field Values

### GP2YA21

    public static final byte GP2YA21

  DIST-Nx-Medium

  See Also:
    Constant Field Values

### GP2YA02

    public static final byte GP2YA02

  DIST-Nx-Long

  See Also:
    Constant Field Values

### CUSTOM

    public static final byte CUSTOM

  Custom sensor

  See Also:
    Constant Field Values

Constructor Detail

### OpticalDistanceSensor

    public OpticalDistanceSensor(I2CPort port)

Parameters:
  `port` - NXT sensor port 1-4

Method Detail

### setSensorModule

    public void setSensorModule(byte module)

  This only needs the be run if you are changing the sensor.

  Parameters:
    `module` - changes the sensor module attached the he board.

### getDistance

    public int getDistance()

  Returns the distance from the object in millimeters. This returns the same value as getDistLSB.

  Returns:
    int

### powerOn

    public void powerOn()

  Turns the sensor module on.
  Power is turned on by the constuctor method.

### powerOff

    public void powerOff()

  Turns power to the sensor module off.

### setAPDAOn

    public void setAPDAOn()

  Enables (ADPA) Auto Detecting Parallel Architecture.
  Once you have enabled it you dont have to enable again.

### setAPDAOff

    public void setAPDAOff()

  Disables (ADPA) Auto Detecting Parallel Architecture.
  Disabled by default.

### getDistLSB

    public int getDistLSB()

  Returns the current distance in millimeters for the LSB.

  Returns:
    int

### getDistMSB

    public int getDistMSB()

  Returns the current distance in millimeters for MSB.

  Returns:
    int

### getVoltLSB

    public int getVoltLSB()

  Returns the current voltage level in millivolts for the LSB.

  Returns:
    int

### getVoltMSB

    public int getVoltMSB()

  Returns the current voltage level in millivolts for the MSB.

  Returns:
    int

### getSensorModule

    public int getSensorModule()

  Used to determin the sensore module that is configured. This can be helpful if the sensor is not working properly.

  Returns:
    int

### getCurveCount

    public int getCurveCount()

  Gets the number of points that will be in the curve. This corisponds with the set/get Volt and Distance methods.
  Used for recalibrating the sensor.

  Returns:
    int

### setCurveCount

    public void setCurveCount(int value)

  Sets the number of points that will be in the configured curve. This corisponds with the set/get Vold and Distance points methods.
  Used for recalibrating the sensor.

  Parameters:
    `value` - max 39

### getDistMinLSB

    public int getDistMinLSB()

  Gets the min value in millimeters for the LSB.
  Used for recalibrating the sensor.

  Returns:
    int

### setDistMinLSB

    public void setDistMinLSB(int value)

  Sets the min value in millimeters for the LSB.
  Used for recalibrating the sensor.

  Parameters:
    `value` - int

### getDistMinMSB

    public int getDistMinMSB()

  Gets the min value in millimeters for the MSB.
  Used for recalibrating the sensor.

  Returns:
    int

### setDistMinMSB

    public void setDistMinMSB(int value)

  Sets the min value in millimeters for the MSB.
  Used for recalibrating the sensor.

  Parameters:
    `value` - int

### getDistMaxLSB

    public int getDistMaxLSB()

  Gets the max value in millimeters for the LSB.
  Used for recalibrating the sensor.

  Returns:
    int

### setDistMaxLSB

    public void setDistMaxLSB(int value)

  Sets the max value in millimeters for LSB.
  Used for recalibrating the sensor.

  Parameters:
    `value` - int

### getDistMaxMSB

    public int getDistMaxMSB()

  Gets the max value in millimeters for the MSB.
  Used for recalibrating the sensor.

  Returns:
    int

### setDistMaxMSB

    public void setDistMaxMSB(int value)

  Sets the max value in millimeters for the MSB.
  Used for recalibrating the sensor.

  Parameters:
    `value` - int

### getVoltPointLSB

    public int getVoltPointLSB(int index)

  Gets millivolts value of the specific index for the LSB. These will corispond with the point methods index value.
  Used for recalibrating the sensor.

  Parameters:
    `index` - max 39
  Returns:
    int

### setVoltPointLSB

    public void setVoltPointLSB(int index,
                                int value)

  Sets millivolts value of the specific index for the LSB. These will corispond with the point methods index value.
  Used for recalibrating the sensor.

  Parameters:
    `index` - max 39
    `value` - int

### getVoltPointMSB

    public int getVoltPointMSB(int index)

  Gets millivolts value of the specific index for the MSB. These will corispond with the point methods index value.
  Used for recalibrating the sensor.

  Parameters:
    `index` - max 39
  Returns:
    Returns int

### setVoltPointMSB

    public void setVoltPointMSB(int index,
                                int value)

  Sets millivolts value of the specific index for the MSB. These will corispond with the point methods index value.
  Used for recalibrating the sensor.

  Parameters:
    `index` - max 39
    `value` - int

### getDistPointLSB

    public int getDistPointLSB(int index)

  Gets millimeter value of the specific index for the LSB.
  Used for recalibrating the sensor.

  Parameters:
    `index` - max 39
  Returns:
    Returns int

### setDistPointLSB

    public void setDistPointLSB(int index,
                                int value)

  Sets millimeter value of the specific index for the LSB.
  Used for recalibrating the sensor.

  Parameters:
    `index` - max 39
    `value` - int

### getDistPointMSB

    public int getDistPointMSB(int index)

  Gets millimeter value of the specific index for the MSB.
  Used for recalibrating the sensor.

  Parameters:
    `index` - max 39
  Returns:
    int

### setDistPointMSB

    public void setDistPointMSB(int index,
                                int value)

  Sets millimeter value of the specific index for the MSB.
  Used for recalibrating the sensor.

  Parameters:
    `index` - max 39.
    `value` - int

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD