public class Motor extends Part
Constructor and Description |
---|
Motor(MotorPort port)
Creates a motor instance that is plugged into given port.
|
Modifier and Type | Method and Description |
---|---|
void |
backward()
Starts the backward rotation.
|
void |
continueRelativeTo(int count)
Same as rotateTo(int count), but the rotation counter
is not set to zero.
|
void |
continueRelativeTo(int count,
boolean blocking)
Same as rotateTo(int count, boolean blocking), but the rotation counter
is not set to zero.
|
void |
continueTo(int count)
Same as rotateTo(int count), but the rotation counter
is not set to zero.
|
void |
continueTo(int count,
boolean blocking)
Same as rotateTo(int count, boolean blocking), but the rotation counter
is not set to zero.
|
void |
forward()
Starts the forward rotation.
|
int |
getMotorCount()
Returns current value of the rotation counter.
|
MotorPort |
getPort()
Returns the port of the motor.
|
int |
getSpeed()
Returns the current speed (arbitrary units).
|
boolean |
isMoving()
Checks if motor is rotating.
|
void |
resetMotorCount()
Resets the rotation counter to zero.
|
void |
rotateTo(int count)
Sets the rotation counter to zero and rotates the motor until the given count is reached.
|
void |
rotateTo(int count,
boolean blocking)
Sets the rotation counter to zero and rotates the motor until the given count is reached.
|
void |
setSpeed(int speed)
Sets the speed to the given value (arbitrary units).
|
void |
stop()
Stops the rotation.
|
public Motor(MotorPort port)
port
- the port where the motor is plugged-in (MotorPort.A, MotorPort.B)public void forward()
public void backward()
public void stop()
public void resetMotorCount()
rotateTo(int count)
public int getMotorCount()
public void rotateTo(int count)
rotateTo(int count, boolean blocking)
public void rotateTo(int count, boolean blocking)
rotateTo(int count)
public void continueTo(int count)
count
- the rotation counter value to be reachedrotateTo(int count)
public void continueTo(int count, boolean blocking)
count
- the rotation counter value to be reachedrotateTo(int count, boolean blocking)
public void continueRelativeTo(int count)
count
- the rotation counter value to be increased/decreasedrotateTo(int count)
public void continueRelativeTo(int count, boolean blocking)
count
- the rotation counter value to be increased/decreasedblocking
- if true, the method blocks until the count is reached, otherwise it returns immediatelyrotateTo(int count, boolean blocking)
public void setSpeed(int speed)
speed
- the speed 0..100public int getSpeed()
public MotorPort getPort()
public boolean isMoving()