|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectlejos.nxt.addon.tetrix.TetrixControllerFactory
public class TetrixControllerFactory
HiTechnic Tetrix Motor and Servo Controller factory class used to provide Motor and Servo controller abstractions.
These are then used
to obtain motor and servo instances respectively. These abstraction classes are TetrixMotorController and
TetrixServoController.
Motor and servo controllers are enumerated starting at the controller connected to one of the NXT's sensor ports and then working outwards along the daisy chain. 4 controllers can be daisy-chained, with a mixture of servo and/or motor controllers. No other sensors can be connected to the daisy-chain.
Code Example:
// Instantiate the factory and get a Motor and servo controller. We assume that there is one of
// each daisy-chained.
TetrixControllerFactory cf = new TetrixControllerFactory(SensorPort.S1);
TetrixMotorController mc = cf.newMotorController();
TetrixServoController sc = cf.newServoController();
// Display the voltage from the motor controller
System.out.println("v=" + mc.getVoltage());'
// Get an encoder motor instance. The physical motor (with encoder) is connected to the Motor 2 terminals on the controller
TetrixEncoderMotor mot1 = mc.getEncoderMotor(TetrixMotorController.MOTOR_2);
// Start the motor
mot1.forward();
TetrixMotorController,
TetrixServoController| Field Summary | |
|---|---|
static int |
DAISY_CHAIN_POSITION_1
Position 1 (nearest to the NXT) in the daisy chain. |
static int |
DAISY_CHAIN_POSITION_2
Position 2 in the daisy chain. |
static int |
DAISY_CHAIN_POSITION_3
Position 3 in the daisy chain. |
static int |
DAISY_CHAIN_POSITION_4
Position 3 (furthest from the NXT)in the daisy chain. |
| Constructor Summary | |
|---|---|
TetrixControllerFactory(I2CPort port)
Instantiate a TetrixControllerFactory using the specified NXT sensor port. |
|
| Method Summary | |
|---|---|
TetrixMotorController |
newMotorController()
Get the next available Tetrix Motor controller. |
TetrixServoController |
newServoController()
Get the next available Tetrix Servo controller. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DAISY_CHAIN_POSITION_1
public static final int DAISY_CHAIN_POSITION_2
public static final int DAISY_CHAIN_POSITION_3
public static final int DAISY_CHAIN_POSITION_4
| Constructor Detail |
|---|
public TetrixControllerFactory(I2CPort port)
TetrixControllerFactory using the specified NXT sensor port.
port - The NXT sensor port the Tetrix controller is connected to| Method Detail |
|---|
public TetrixMotorController newMotorController()
Successive controllers in a daisy-chain logically go "outwards" from the controller closest to the NXT as #1 to #4 for each controller in the chain. Once a specific, logical controller has been retrieved using this method, it cannot be retrieved again.
A combination of Servo and Motor controllers can be daisy-chained.
TetrixMotorController instance.
IllegalStateException - If no more motor controllers can be returned. If there are no motor controllers
in the daisy-chain, this exception is also thrown.newServoController()public TetrixServoController newServoController()
Successive controllers in a daisy-chain logically go "outwards" from the controller closest to the NXT as #1 to #4 for each controller in the chain. Once a specific, logical controller has been retrieved using this method, it cannot be retrieved again.
A combination of Servo and Motor controllers can be daisy-chained.
TetrixServoController instance.
IllegalStateException - If no more servo controllers can be returned. If there are no servo controllers
in the daisy-chain, this exception is also thrown.newMotorController()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||