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

## com.phidgets
Class EncoderPhidget

    java.lang.Object
      com.phidgets.Phidget
          com.phidgets.EncoderPhidget

    public final class EncoderPhidget

extends Phidget

This class represents a Phidget Encoder. All methods to read encoder data from an encoder are implemented in this class.

Phidget Encoder boards generally support 1 or more encoders with 0 or more digital inputs. Both high speed optical and low speed mechanical encoders are supported with this API.

Constructor Summary
`EncoderPhidget()`

Method Summary
`void` | `addEncoderPositionChangeListener(EncoderPositionChangeListener l)` Adds a position change listener.
`void` | `addInputChangeListener(InputChangeListener l)` Adds an input change listener.
`int` | `getEncoderCount()` Returns number of encoders.
`int` | `getEncoderPosition(int index)` Returns the position of an encoder.
`int` | `getInputCount()` Returns number of digital inputs.
`boolean` | `getInputState(int index)` Returns the state of a digital input.
`void` | `removeEncoderPositionChangeListener(EncoderPositionChangeListener l)`
`void` | `removeInputChangeListener(InputChangeListener l)`
`void` | `setEncoderPosition(int index, int position)` Sets the position of a specific encoder.

Methods inherited from class com.phidgets.Phidget
`addAttachListener, addDetachListener, addErrorListener, close, equals, getDeviceName, getDeviceType, getDeviceVersion, getLibraryVersion, getSerialNumber, getTag, isAttached, open, openAny, removeAttachListener, removeDetachListener, removeErrorListener, setTag, toString, waitForAttachment`

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

Constructor Detail

### EncoderPhidget

    public EncoderPhidget()
                   throws PhidgetException

Throws:
  `PhidgetException`

Method Detail

### getEncoderCount

    public int getEncoderCount()
                        throws PhidgetException

  Returns number of encoders. All current encoder boards support one encoder.

  Returns:
    number of encoders
  Throws:
    `PhidgetException` - If this Phidget is not opened and attached. See `open` for information on determining if a device is attached.

### getInputCount

    public int getInputCount()
                      throws PhidgetException

  Returns number of digital inputs. On the mechanical encoder this refers to the pushbutton. The high speed encoder does not have any digital inputs.

  Returns:
    number of inputs
  Throws:
    `PhidgetException` - If this Phidget is not opened and attached. See `open` for information on determining if a device is attached.

### getEncoderPosition

    public int getEncoderPosition(int index)
                           throws PhidgetException

  Returns the position of an encoder. This is an absolute position as calcutated since the encoder was plugged in. This value can be reset to anything using `setEncoderPosition`.

  Parameters:
    `index` - index of the encoder
  Returns:
    position of the encoder
  Throws:
    `PhidgetException` - If this Phidget is not opened and attached, or if the index is out of range. See `open` for information on determining if a device is attached.

### setEncoderPosition

    public void setEncoderPosition(int index,
                                   int position)
                            throws PhidgetException

  Sets the position of a specific encoder. This resets the internal position count for an encoder. This call in no way actually sends information to the device, as an absolute position is maintained only in the library. After this call, position changes from the encoder will use the new value to calculate absolute position as reported by `getEncoderPosition`.

  Parameters:
    `index` - index of the encoder
    `position` - new position for this encoder.
  Throws:
    `PhidgetException` - If this Phidget is not opened and attached, or if the index is out of range. See `open` for information on determining if a device is attached.

### getInputState

    public boolean getInputState(int index)
                          throws PhidgetException

  Returns the state of a digital input. On the mechanical encoder this refers to the pushbutton. The high speed encoder does not have any digital inputs. A value of true means that the input is active(the button is pushed).

  Parameters:
    `index` - index of the input
  Returns:
    state of the input
  Throws:
    `PhidgetException` - If this Phidget is not opened and attached, or if the index is out of range. See `open` for information on determining if a device is attached.

### addEncoderPositionChangeListener

    public final void addEncoderPositionChangeListener(EncoderPositionChangeListener l)

  Adds a position change listener. The position change handler is a method that will be called when the position of an encoder changes. The position change event provides data about how many ticks have occured, and how much time has passed since the last position change event, but does not contain an absolute position. This can be obtained from `getEncoderPosition`.

  There is no limit on the number of position change handlers that can be registered for a particular Phidget.

  Parameters:
    `l` - An implemetation of the `EncoderPositionChangeListener` interface

### removeEncoderPositionChangeListener

    public final void removeEncoderPositionChangeListener(EncoderPositionChangeListener l)

### addInputChangeListener

    public final void addInputChangeListener(InputChangeListener l)

  Adds an input change listener. The input change handler is a method that will be called when an input on this Encoder board has changed.

  There is no limit on the number of input change handlers that can be registered for a particular Phidget.

  Parameters:
    `l` - An implemetation of the `InputChangeListener` interface

### removeInputChangeListener

    public final void removeInputChangeListener(InputChangeListener l)

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