com.dexterind.gopigo.components
Class Encoders

java.lang.Object
  extended by com.dexterind.gopigo.components.Encoders

public class Encoders
extends java.lang.Object

Implements the methods needed to set, read, enable or disable the encoders.

Author:
marcello

Field Summary
private static Board board
          The main object which handles the methods to get access to the resources connected to the board.
private  Debug debug
          The debug object.
private static Encoders instance
          The instance of the current object.
 
Constructor Summary
Encoders()
           
 
Method Summary
 int disable()
          Disables the encoders.
 int enable()
          Enables the encoders.
static Encoders getInstance()
          Provides a global point of access to the Encoders instance.
 int read(int motor)
          Reads the encoding value for the motor.
 int readStatus()
          Reads the encoders status.
 int targeting(int m1, int m2, int target)
          Sets the targeting for both the motors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

board

private static Board board
The main object which handles the methods to get access to the resources connected to the board.


instance

private static Encoders instance
The instance of the current object.


debug

private Debug debug
The debug object.

Constructor Detail

Encoders

public Encoders()
         throws java.io.IOException,
                java.lang.InterruptedException
Throws:
java.io.IOException
java.lang.InterruptedException
Method Detail

getInstance

public static Encoders getInstance()
                            throws java.io.IOException,
                                   java.lang.InterruptedException
Provides a global point of access to the Encoders instance.

Returns:
the Encoders instance.
Throws:
java.io.IOException
java.lang.InterruptedException

targeting

public int targeting(int m1,
                     int m2,
                     int target)
              throws java.io.IOException
Sets the targeting for both the motors.

Parameters:
m1 - The value for the motor 1.
m2 - The value for the motor 2.
target - TODO: Find a nice description for the target
Returns:
A status code.
Throws:
java.io.IOException

read

public int read(int motor)
         throws java.io.IOException
Reads the encoding value for the motor.

Parameters:
motor - The motor id to read.
Returns:
The value for the motor or a "error" status code in case of failure.
Throws:
java.io.IOException

readStatus

public int readStatus()
               throws java.io.IOException
Reads the encoders status.

Returns:
The encoders status
Throws:
java.io.IOException

enable

public int enable()
           throws java.io.IOException
Enables the encoders.

Returns:
A status code.
Throws:
java.io.IOException

disable

public int disable()
            throws java.io.IOException
Disables the encoders.

Returns:
A status code.
Throws:
java.io.IOException