lejos.nxt.addon
Class MMXMotor

java.lang.Object
  extended by lejos.nxt.addon.MMXMotor
All Implemented Interfaces:
BaseMotor, DCMotor, Encoder, EncoderMotor
Direct Known Subclasses:
MMXRegulatedMotor

public class MMXMotor
extends java.lang.Object
implements EncoderMotor

Abstraction to drive a basic encoder motor with the NXTMMX motor multiplexer. The NXTMMX motor multiplexer device allows you to connect two additional motors to your robot using a sensor port. Multiple NXTMMXs can be chained together.

Create an instance of this class passing a NXTMMX instance and Motor ID (MMX_MOTOR_1 or MMX_MOTOR_2) in the constructor.

Author:
Kirk P. Thompson
See Also:
NXTMMX, MMXRegulatedMotor

Constructor Summary
MMXMotor(NXTMMX mux, int motor)
          Create an instance of a MMXMotor.
 
Method Summary
 void backward()
          Causes motor to rotate backwards.
 void flt()
          Causes motor to float.
 void forward()
          Causes motor to rotate forward.
 int getPower()
          Returns the current motor power setting.
 int getTachoCount()
          Returns the tachometer count.
 boolean isMoving()
          This method returns true if the motor has been commanded with the forward() or backward() methods.
 void resetTachoCount()
          Resets the tachometer count to zero.
 void setPower(int power)
          Set the power level 0-100% to be applied to the motor.
 void stop()
          Causes motor to stop pretty much instantaneously.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MMXMotor

public MMXMotor(NXTMMX mux,
                int motor)
Create an instance of a MMXMotor.

Parameters:
mux - the motor multiplexor NXTMMX instance to bind this motor to.
motor - the index of the motor connected to the NXTMMX: NXTMMX.MMX_MOTOR_1 or NXTMMX.MMX_MOTOR_2
See Also:
NXTMMX, NXTMMX.MMX_MOTOR_1, NXTMMX.MMX_MOTOR_2
Method Detail

setPower

public void setPower(int power)
Set the power level 0-100% to be applied to the motor.

Specified by:
setPower in interface DCMotor
Parameters:
power - new motor power 0-100%
See Also:
getPower()

getPower

public int getPower()
Returns the current motor power setting.

Specified by:
getPower in interface DCMotor
Returns:
current power 0-100%
See Also:
setPower(int)

forward

public void forward()
Causes motor to rotate forward.

Specified by:
forward in interface BaseMotor
See Also:
backward()

backward

public void backward()
Causes motor to rotate backwards.

Specified by:
backward in interface BaseMotor
See Also:
forward()

flt

public void flt()
Causes motor to float. This will stop the motor without braking and the position of the motor will not be maintained.

Specified by:
flt in interface BaseMotor

stop

public void stop()
Causes motor to stop pretty much instantaneously. In other words the motor doesn't just stop, it will resist any further motion.

Specified by:
stop in interface BaseMotor

getTachoCount

public int getTachoCount()
Returns the tachometer count.

Specified by:
getTachoCount in interface Encoder
Returns:
tachometer count in degrees
See Also:
resetTachoCount()

resetTachoCount

public void resetTachoCount()
Resets the tachometer count to zero.

Specified by:
resetTachoCount in interface Encoder
See Also:
getTachoCount()

isMoving

public boolean isMoving()
This method returns true if the motor has been commanded with the forward() or backward() methods.

Specified by:
isMoving in interface BaseMotor
Returns:
true if the motor has been commanded to move, false otherwise.
See Also:
flt()