lejos.nxt
Class BasicMotor

java.lang.Object
  extended by lejos.nxt.BasicMotor
All Implemented Interfaces:
DCMotor
Direct Known Subclasses:
Motor, RCXMotor

public abstract class BasicMotor
extends Object
implements DCMotor

An abstraction for a motor without a tachometer, such as an RCX motor.

Author:
Lawrie Griffiths.

Field Summary
protected  BasicMotorPort _port
           
 
Constructor Summary
BasicMotor()
           
 
Method Summary
 void backward()
          Causes motor to rotate backwards.
 void flt()
          Causes motor to float.
 void forward()
          Causes motor to rotate forward.
 int getMode()
          Returns the mode.
 int getPower()
          Returns the current power setting.
 boolean isBackward()
          Return true if motor is backward.
 boolean isFloating()
          Returns true iff the motor is in float mode.
 boolean isForward()
          Return true if motor is forward.
 boolean isMoving()
          Returns true iff the motor is in motion.
 boolean isStopped()
          Return true if motor is stopped.
 void reverseDirection()
          Reverses direction of the motor.
 void setPower(int power)
          Sets power.
 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
 

Field Detail

_port

protected BasicMotorPort _port
Constructor Detail

BasicMotor

public BasicMotor()
Method Detail

setPower

public void setPower(int power)
Sets power.

Parameters:
power - power setting: 0 - 100

getPower

public int getPower()
Returns the current power setting.

Returns:
power value 0-100

forward

public void forward()
Causes motor to rotate forward.

Specified by:
forward in interface DCMotor

isForward

public boolean isForward()
Return true if motor is forward.


backward

public void backward()
Causes motor to rotate backwards.

Specified by:
backward in interface DCMotor

isBackward

public boolean isBackward()
Return true if motor is backward.


reverseDirection

public void reverseDirection()
Reverses direction of the motor. It only has effect if the motor is moving.


isMoving

public boolean isMoving()
Returns true iff the motor is in motion.

Specified by:
isMoving in interface DCMotor
Returns:
true iff the motor is currently in motion.

flt

public void flt()
Causes motor to float. The motor will lose all power, but this is not the same as stopping. Use this method if you don't want your robot to trip in abrupt turns.

Specified by:
flt in interface DCMotor

isFloating

public boolean isFloating()
Returns true iff the motor is in float mode.

Returns:
true iff the motor is currently in float mode.

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. Cancels any rotate() orders in progress

Specified by:
stop in interface DCMotor

isStopped

public boolean isStopped()
Return true if motor is stopped.


getMode

public int getMode()
Returns the mode.

Returns:
mode 1=forward, 2=backward, 3=stopped, 4=floating