Package lejos.hardware.device.tetrix
Class TetrixMotorController
- java.lang.Object
-
- lejos.hardware.Device
-
- lejos.hardware.sensor.BaseSensor
-
- lejos.hardware.sensor.I2CSensor
-
- lejos.hardware.device.tetrix.TetrixMotorController
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,SensorConstants,SensorMode,SensorModes,SampleProvider
public class TetrixMotorController extends I2CSensor
HiTechnic Tetrix Motor Controller abstraction. ProvidesTetrixMotorandTetrixEncoderMotorinstances which are used to control the Tetrix motors.Use
to retrieve aTetrixControllerFactory.newMotorController()TetrixMotorControllerinstance.- Author:
- Kirk P. Thompson
- See Also:
TetrixControllerFactory,TetrixMotor,TetrixEncoderMotor
-
-
Field Summary
Fields Modifier and Type Field Description static intMOTOR_1Represents Motor 1 as indicated on the controllerstatic intMOTOR_2Represents Motor 2 as indicated on the controller-
Fields inherited from class lejos.hardware.sensor.I2CSensor
address, DEFAULT_I2C_ADDRESS, port, REG_PRODUCT_ID, REG_VENDOR_ID, REG_VERSION, retryCount
-
Fields inherited from class lejos.hardware.sensor.BaseSensor
currentMode, modes
-
Fields inherited from interface lejos.hardware.sensor.SensorConstants
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, BROWN, GREEN, GREEN_INDEX, MAX_TYPE, MIN_TYPE, MODE_RAW, NXT_ADC_RES, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HIGHSPEED, TYPE_HIGHSPEED_9V, 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
Constructors Constructor Description TetrixMotorController(I2CPort port, int daisyChainPosition)Instantiate a HiTechnic TETRIX Motor Controller connected to the givenportand daisy chain position.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TetrixMotorgetBasicMotor(int motorID)Get aTetrixMotorinstance that is associated with themotorID.TetrixEncoderMotorgetEncoderMotor(int motorID)Get aTetrixEncoderMotorinstance that is associated with themotorID.TetrixRegulatedMotorgetRegulatedMotor(int motorID)Get aTetrixRegulatedMotorinstance that is associated with themotorID.floatgetVoltage()Return the current battery voltage supplied to the controller.-
Methods inherited from class lejos.hardware.sensor.I2CSensor
fetchString, getAddress, getData, getData, getPort, getProductID, getRetryCount, getVendorID, getVersion, sendData, sendData, sendData, setAddress, setRetryCount
-
Methods inherited from class lejos.hardware.sensor.BaseSensor
fetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, getName, sampleSize, setCurrentMode, setCurrentMode, setModes
-
Methods inherited from class lejos.hardware.Device
close, releaseOnClose
-
-
-
-
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 givenportand 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:
java.lang.IllegalStateException- if a Motor Controller was not found with givenportanddaisyChainPosition- See Also:
TetrixControllerFactory.DAISY_CHAIN_POSITION_1,TetrixControllerFactory.DAISY_CHAIN_POSITION_2,TetrixControllerFactory.DAISY_CHAIN_POSITION_3,TetrixControllerFactory.DAISY_CHAIN_POSITION_4
-
-
Method Detail
-
getBasicMotor
public TetrixMotor getBasicMotor(int motorID)
Get aTetrixMotorinstance that is associated with themotorID.- Parameters:
motorID- The motor ID number. This is indicated on the HiTechnic Motor Controller and is represented usingorMOTOR_1.MOTOR_2- Returns:
- The
TetrixMotorinstance - Throws:
java.lang.IllegalArgumentException- if invalidmotorIDjava.lang.UnsupportedOperationException- ifmotorIDhas already been used for a Tetrix motor instance other thanTetrixMotor.- See Also:
TetrixMotor,getEncoderMotor(int),getRegulatedMotor(int)
-
getEncoderMotor
public TetrixEncoderMotor getEncoderMotor(int motorID)
Get aTetrixEncoderMotorinstance that is associated with themotorID. The motor must have an encoder installed for aTetrixEncoderMotorinstance to work correctly.- Parameters:
motorID- The motor ID number. This is indicated on the HiTechnic Motor Controller and is represented usingorMOTOR_1.MOTOR_2- Returns:
- The
TetrixEncoderMotorinstance - Throws:
java.lang.IllegalArgumentException- if invalidmotorIDjava.lang.UnsupportedOperationException- ifmotorIDhas already been used for a Tetrix motor instance other thanTetrixEncoderMotor.- See Also:
TetrixEncoderMotor,getBasicMotor(int),getRegulatedMotor(int)
-
getRegulatedMotor
public TetrixRegulatedMotor getRegulatedMotor(int motorID)
Get aTetrixRegulatedMotorinstance that is associated with themotorID. The motor must have an encoder installed for aTetrixRegulatedMotorinstance to work correctly.- Parameters:
motorID- The motor ID number. This is indicated on the HiTechnic Motor Controller and is represented usingorMOTOR_1.MOTOR_2- Returns:
- The
TetrixRegulatedMotorinstance - Throws:
java.lang.IllegalArgumentException- if invalidmotorIDjava.lang.UnsupportedOperationException- ifmotorIDhas already been used for a Tetrix motor instance other thanTetrixRegulatedMotor.- 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
-
-