lejos.nxt.addon.tetrix
Class TetrixMotorController

java.lang.Object
  extended by lejos.nxt.I2CSensor
      extended by lejos.nxt.addon.tetrix.TetrixMotorController
All Implemented Interfaces:
SensorConstants

public class TetrixMotorController
extends I2CSensor

HiTechnic Tetrix Motor Controller abstraction. Provides TetrixMotor and TetrixEncoderMotor instances which are used to control the Tetrix motors.

Use TetrixControllerFactory.newMotorController() to retrieve a TetrixMotorController instance.

Author:
Kirk P. Thompson
See Also:
TetrixControllerFactory, TetrixMotor, TetrixEncoderMotor

Field Summary
static int MOTOR_1
          Represents Motor 1 as indicated on the controller
static int MOTOR_2
          Represents Motor 2 as indicated on the controller
 
Fields inherited from class lejos.nxt.I2CSensor
address, DEFAULT_I2C_ADDRESS, port, REG_PRODUCT_ID, REG_VENDOR_ID, REG_VERSION
 
Fields inherited from interface lejos.nxt.SensorConstants
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, GREEN, GREEN_INDEX, MAX_AD_RAW, MAX_TYPE, MIN_TYPE, MODE_ANGLESTEP, MODE_BOOLEAN, MODE_CELSIUS, MODE_FARENHEIT, MODE_PCTFULLSCALE, MODE_PERIODCOUNTER, MODE_RAW, MODE_TRANSITIONCNT, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HISPEED, 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, WHITE, YELLOW
 
Constructor Summary
TetrixMotorController(I2CPort port, int daisyChainPosition)
          Instantiate a HiTechnic TETRIX Motor Controller connected to the given port and daisy chain position.
 
Method Summary
 TetrixMotor getBasicMotor(int motorID)
          Get the TetrixMotor instance that is associated with the motorID.
 TetrixEncoderMotor getEncoderMotor(int motorID)
          Get the TetrixEncoderMotor instance that is associated with the motorID.
 TetrixRegulatedMotor getRegulatedMotor(int motorID)
          Get the TetrixRegulatedMotor instance that is associated with the motorID.
 float getVoltage()
          Return the current battery voltage supplied to the controller.
 
Methods inherited from class lejos.nxt.I2CSensor
fetchString, getAddress, getData, getData, getPort, getProductID, getVendorID, getVersion, sendData, sendData, sendData, setAddress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MOTOR_1

public static final int MOTOR_1
Represents Motor 1 as indicated on the controller

See Also:
Constant Field Values

MOTOR_2

public static final int MOTOR_2
Represents Motor 2 as indicated on the controller

See Also:
Constant Field Values
Constructor Detail

TetrixMotorController

public TetrixMotorController(I2CPort port,
                             int daisyChainPosition)
Instantiate a HiTechnic TETRIX Motor Controller connected to the given port and daisy chain position.

Parameters:
port - The sensor port the controller (if daisy-chained, the first) is connected to.
daisyChainPosition - The position of the controller in the daisy chain.
Throws:
IllegalStateException - if a Motor Controller was not found with given port and daisyChainPosition
See Also:
TetrixControllerFactory.DAISY_CHAIN_POSITION_1, TetrixControllerFactory.DAISY_CHAIN_POSITION_2, TetrixControllerFactory.DAISY_CHAIN_POSITION_3, TetrixControllerFactory.DAISY_CHAIN_POSITION_4, SensorPort
Method Detail

getBasicMotor

public TetrixMotor getBasicMotor(int motorID)
Get the TetrixMotor instance that is associated with the motorID.

Parameters:
motorID - The motor ID number. This is indicated on the HiTechnic Motor Controller and is represented using MOTOR_1 or MOTOR_2.
Returns:
The TetrixMotor instance
See Also:
TetrixMotor, getEncoderMotor(int), getRegulatedMotor(int)

getEncoderMotor

public TetrixEncoderMotor getEncoderMotor(int motorID)
Get the TetrixEncoderMotor instance that is associated with the motorID. The motor must have an encoder installed for a TetrixEncoderMotor instance to work correctly.

Parameters:
motorID - The motor ID number. This is indicated on the HiTechnic Motor Controller and is represented using MOTOR_1 or MOTOR_2.
Returns:
The TetrixEncoderMotor instance
Throws:
IllegalArgumentException - if invalid motorID
See Also:
TetrixEncoderMotor, getBasicMotor(int), getRegulatedMotor(int)

getRegulatedMotor

public TetrixRegulatedMotor getRegulatedMotor(int motorID)
Get the TetrixRegulatedMotor instance that is associated with the motorID. The motor must have an encoder installed for a TetrixRegulatedMotor instance to work correctly.

Parameters:
motorID - The motor ID number. This is indicated on the HiTechnic Motor Controller and is represented using MOTOR_1 or MOTOR_2.
Returns:
The TetrixRegulatedMotor instance
Throws:
IllegalArgumentException - if invalid motorID
See Also:
TetrixRegulatedMotor, getBasicMotor(int), getEncoderMotor(int)

getVoltage

public float getVoltage()
Return the current battery voltage supplied to the controller.

Returns:
The current battery voltage in volts