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 I2CSensor

    java.lang.Object
      lejos.nxt.I2CSensor

All Implemented Interfaces:
  SensorConstants

Direct Known Subclasses:
  ColorSensor, CompassSensor, TiltSensor, UltrasonicSensor

    public abstract class I2CSensor

extends Object
implements SensorConstants

Abstract class that implements common methods for all I2C sensors. Extend this class to implement new I2C sensors.

Author:
  Lawrie Griffiths (lawrie.griffiths@ntlworld.com)

Field Summary

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
`I2CSensor(lejos.nxt.I2CPort port)`

Method Summary
`int` | `getData(int register, byte[] buf, int len)` Executes an I2C read transaction and waits for the result.
`String` | `getProductID()` Return the sensor product identifier.
`String` | `getSensorType()` Return the sensor type.
`String` | `getVersion()` Return the sensor version number.
`int` | `sendData(int register, byte[] buf, int len)` Executes an I2C write transaction - not yet working.

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

Constructor Detail

### I2CSensor

    public I2CSensor(lejos.nxt.I2CPort port)

Method Detail

### getData

    public int getData(int register,
                       byte[] buf,
                       int len)

  Executes an I2C read transaction and waits for the result.

  Parameters:
    `register` - I2C register, e.g 0x41
    `buf` - Buffer to return data
    `len` - Length of the return data
  Returns:
    status zero=success, non-zero=failure

### sendData

    public int sendData(int register,
                        byte[] buf,
                        int len)

  Executes an I2C write transaction - not yet working.

  Parameters:
    `register` - I2C register, e.g 0x42
    `buf` - Buffer containing data to send
    `len` - Length of data to send
  Returns:
    status zero=success, non-zero=failure

### getVersion

    public String getVersion()

  Return the sensor version number.

  Returns:
    8-byte string

### getProductID

    public String getProductID()

  Return the sensor product identifier.

  Returns:
    8-byte string

### getSensorType

    public String getSensorType()

  Return the sensor type.

  Returns:
    8-byte string

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