lejos.nxt.addon.tetrix
Class TetrixEncoderMotor

java.lang.Object
  extended by lejos.nxt.addon.tetrix.TetrixMotor
      extended by lejos.nxt.addon.tetrix.TetrixEncoderMotor
All Implemented Interfaces:
BaseMotor, DCMotor, Encoder
Direct Known Subclasses:
TetrixRegulatedMotor

public class TetrixEncoderMotor
extends TetrixMotor
implements Encoder

Tetrix DC motor abstraction with encoder support. The Tetrix motor must have an encoder installed and connected to the controller for the methods in this class to work. If an encoder is not installed, use the TetrixMotor class instead.

Use TetrixMotorController.getEncoderMotor(int) to retrieve a TetrixEncoderMotor instance.

Author:
Kirk P. Thompson

Method Summary
 int getLimitAngle()
          Return the last angle that this motor was rotating to via one of the rotate methods.
 int getTachoCount()
          Returns the tachometer count.
 void resetTachoCount()
          Reset the the tachometer count.
 void rotate(int degrees, boolean immediateReturn)
          Rotate by the requested number of degrees with option for wait until completion or immediate return where the motor completes its rotation asynchronously.
 void rotateTo(int limitAngle, boolean immediateReturn)
          Rotate to the target angle with option for wait until completion or immediate return where the motor completes its rotation asynchronously.
 void setRegulate(boolean regulate)
          Disable or Enable internal motor controller speed regulation.
 
Methods inherited from class lejos.nxt.addon.tetrix.TetrixMotor
backward, flt, forward, getPower, isMoving, setPower, setReverse, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getTachoCount

public int getTachoCount()
Description copied from interface: Encoder
Returns the tachometer count.

Specified by:
getTachoCount in interface Encoder
Returns:
tachometer count in degrees

resetTachoCount

public void resetTachoCount()
Reset the the tachometer count. Calling this method will stop any current motor action. This is imposed by the HiTechic Motor Controller firmware.

Specified by:
resetTachoCount in interface Encoder

rotate

public void rotate(int degrees,
                   boolean immediateReturn)
Rotate by the requested number of degrees with option for wait until completion or immediate return where the motor completes its rotation asynchronously.

Parameters:
degrees - number of degrees to rotate relative to the current position.
immediateReturn - if true, do not wait for the move to complete. false will block until the rotation completes.

rotateTo

public void rotateTo(int limitAngle,
                     boolean immediateReturn)
Rotate to the target angle with option for wait until completion or immediate return where the motor completes its rotation asynchronously.

Parameters:
limitAngle - Angle [in degrees] to rotate to.
immediateReturn - if true, do not wait for the move to complete. false will block until the rotation completes.

getLimitAngle

public int getLimitAngle()
Return the last angle that this motor was rotating to via one of the rotate methods.

Returns:
angle in degrees

setRegulate

public void setRegulate(boolean regulate)
Disable or Enable internal motor controller speed regulation. Setting this to true will cause the motor controller firmware to adjust the motor power to compensate for changing loads in order to maintain a constant motor speed. Default at instantiation is false.

Parameters:
regulate - true to enable regulation, false otherwise.