Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## josx.platform.rcx
Class Motor

    java.lang.Object
      josx.platform.rcx.Motor

    public class Motor

extends Object

Abstraction for a motor. Three instances of `Motor` are available: `Motor.A`, `Motor.B` and `Motor.C`. To control each motor use methods `forward, backward, reverseDirection, stop` and `flt`. To set each motor's power, use `setPower`.

Example:

``

       Motor.A.setPower(1);
       Motor.C.setPower(7);
       Motor.A.forward();
       Motor.C.forward();
       Thread.sleep (1000);
       Motor.A.stop();
       Motor.C.stop();

Field Summary
`static Motor` | `A` Motor A.
`static Motor` | `B` Motor B.
`static Motor` | `C` Motor C.

Method Summary
`void` | `backward()` Causes motor to rotate backwards.
`static void` | `controlMotor(char aMotor, int aMode, int aPower)` Deprecated. I've decided to remove this method. If you really need it, check its implementation in classes/josx/platform/rcx/Motor.java.
`void` | `flt()` Causes motor to float.
`void` | `forward()` Causes motor to rotate forward.
`char` | `getId()` Get the ID of the motor.
`int` | `getPower()` Returns the current motor power.
`boolean` | `isBackward()` Return true if motor is backward.
`boolean` | `isFloating()`
`boolean` | `isForward()` Return true if motor is forward.
`boolean` | `isMoving()`
`boolean` | `isStopped()` Return true if motor is stopped.
`void` | `reverseDirection()` Reverses direction of the motor.
`void` | `setPower(int aPower)` Sets motor power to a value between 0 and 7.
`void` | `stop()` Causes motor to stop, pretty much instantaneously.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait`

Field Detail

### A

    public static final Motor A

  Motor A.

### B

    public static final Motor B

  Motor B.

### C

    public static final Motor C

  Motor C.

Method Detail

### getId

    public final char getId()

  Get the ID of the motor. One of 'A', 'B' or 'C'.

### setPower

    public final void setPower(int aPower)

  Sets motor power to a value between 0 and 7.

  Parameters:
    `aPower` - value in the range [0-7].

### forward

    public final void forward()

  Causes motor to rotate forward.

### isForward

    public final boolean isForward()

  Return true if motor is forward.

### backward

    public final void backward()

  Causes motor to rotate backwards.

### isBackward

    public final boolean isBackward()

  Return true if motor is backward.

### reverseDirection

    public final void reverseDirection()

  Reverses direction of the motor. It only has effect if the motor is moving.

### getPower

    public final int getPower()

  Returns the current motor power.

### isMoving

    public final boolean isMoving()

  Returns:
    true iff the motor is currently in motion.

### isFloating

    public final boolean isFloating()

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

### stop

    public final void stop()

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

### isStopped

    public final boolean isStopped()

  Return true if motor is stopped.

### flt

    public final 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.

### controlMotor

    public static void controlMotor(char aMotor,
                                    int aMode,
                                    int aPower)

  Deprecated. I've decided to remove this method. If you really need it, check its implementation in classes/josx/platform/rcx/Motor.java.

  Low-level API for controlling a motor. This method is not meant to be called directly. If called, other methods such as isRunning() will be unreliable.

  Parameters:
    `aMotor` - The motor id: 'A', 'B' or 'C'.
    `aMode` - 1=forward, 2=backward, 3=stop, 4=float
    `aPower` - A value in the range [0-7].

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD