public class Motor extends LegoService
Modifier and Type | Class and Description |
---|---|
static class |
Motor.MotorDirection
The direction of a motor
|
Modifier and Type | Field and Description |
---|---|
static int |
MOTOR_MAX_SPEED |
static int |
MOTOR_MIN_SPEED |
static int |
MOTOR_POWER_BRAKE |
static int |
MOTOR_POWER_DRIFT |
static int |
MOTOR_POWER_OFFSET |
callbackHelper, connectInfo, inputFormat, io
Modifier | Constructor and Description |
---|---|
protected |
Motor(ConnectInfo connectInfo,
IO io) |
Modifier and Type | Method and Description |
---|---|
void |
brake()
Send a command to stop (brake) the motor
|
static Motor |
createService(ConnectInfo connectInfo,
IO io) |
void |
drift()
Send a command to stop (drift/float) the motor
|
boolean |
equals(java.lang.Object o) |
Motor.MotorDirection |
getDirection()
The current running direction of the motor
|
int |
getPower()
The power the motor is currently running with (0 if braking or drifting).
|
java.lang.String |
getServiceName() |
int |
hashCode() |
boolean |
isBraking()
true if the motor is currently braking (not running)
|
boolean |
isDrifting()
true if the motor is currently drifting / floating.
|
void |
run(Motor.MotorDirection direction,
int power)
Send a command to run the motor at a given power in a given direction.
|
addValidDataFormat, didReceiveInputFormat, didReceiveValueData, didRequestConnectInfo, getConnectInfo, getDefaultInputFormat, getDevice, getFloatFromData, getInputFormat, getInputFormatMode, getIntegerFromData, getIo, getNumberFromValueData, getNumberFromValueData, getNumbersFromValueDataSet, getNumbersFromValueDataSet, getValidDataFormats, getValueAsFloat, getValueAsInteger, getValueData, handleUpdatedInputFormat, handleUpdatedValueData, isInternalService, registerCallbackListener, removeValidDataFormat, sendReadValueRequest, sendResetStateRequest, setDevice, unregisterCallbackListener, updateCurrentInputFormatWithNewMode, updateInputFormat, writeData
public static final int MOTOR_MIN_SPEED
public static final int MOTOR_MAX_SPEED
public static final int MOTOR_POWER_DRIFT
public static final int MOTOR_POWER_BRAKE
public static final int MOTOR_POWER_OFFSET
protected Motor(ConnectInfo connectInfo, IO io)
public static Motor createService(ConnectInfo connectInfo, IO io)
public java.lang.String getServiceName()
getServiceName
in class LegoService
public int getPower()
public Motor.MotorDirection getDirection()
public boolean isBraking()
public boolean isDrifting()
public void run(Motor.MotorDirection direction, int power)
direction
- The direction to run the motorpower
- The power to run the motor with.public void brake()
public void drift()
public boolean equals(java.lang.Object o)
equals
in class LegoService
public int hashCode()
hashCode
in class LegoService