public class MatrixDcMotorController extends java.lang.Object implements DcMotorController
HardwareDevice.Manufacturer| Modifier and Type | Field and Description |
|---|---|
protected static double |
apiPowerMax |
protected static double |
apiPowerMin |
protected MatrixMasterController |
master |
static byte |
POWER_MAX |
static byte |
POWER_MIN |
| Constructor and Description |
|---|
MatrixDcMotorController(MatrixMasterController master) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this device
|
protected DcMotor.RunMode |
flagMatrixToRunMode(byte flag) |
int |
getBattery() |
java.lang.String |
getConnectionInfo()
Get connection information about this device in a human readable format
|
java.lang.String |
getDeviceName()
Returns a string suitable for display to the user as to the type of device.
|
HardwareDevice.Manufacturer |
getManufacturer()
Returns an indication of the manufacturer of this device.
|
int |
getMotorCurrentPosition(int motor)
Get the current motor position
|
DcMotor.RunMode |
getMotorMode(int motor)
Get the current motor mode.
|
double |
getMotorPower(int motor)
Get the current motor power
|
boolean |
getMotorPowerFloat(int motor)
Is motor power set to float?
|
int |
getMotorTargetPosition(int motor)
Get the current motor target position
|
MotorConfigurationType |
getMotorType(int motor)
Retrieves the motor type configured for this motor
|
DcMotor.ZeroPowerBehavior |
getMotorZeroPowerBehavior(int motor)
Returns the current zero power behavior of the motor.
|
int |
getVersion()
Version
|
void |
handleReadBattery(byte[] buffer) |
void |
handleReadMode(MatrixI2cTransaction transaction,
byte[] buffer) |
void |
handleReadPosition(MatrixI2cTransaction transaction,
byte[] buffer) |
void |
handleReadTargetPosition(MatrixI2cTransaction transaction,
byte[] buffer) |
boolean |
isBusy(int motor)
Is the motor busy?
|
void |
resetDeviceConfigurationForOpMode()
Resets the device's configuration to that which is expected at the beginning of an OpMode.
|
void |
resetDeviceConfigurationForOpMode(int motor)
Reset the state we hold for the given motor so that it's clean at the start of an opmode
|
protected byte |
runModeToFlagMatrix(DcMotor.RunMode mode) |
void |
setMotorMode(int motor,
DcMotor.RunMode mode)
Set the current motor mode.
|
void |
setMotorPower(int motor,
double power)
Set the current motor power
|
void |
setMotorPower(java.util.Set<DcMotor> motors,
double power)
Sets the power for a group of motors.
|
protected void |
setMotorPowerFloat(int motor) |
void |
setMotorTargetPosition(int motor,
int position)
Set the motor target position.
|
void |
setMotorType(int motor,
MotorConfigurationType motorType)
Informs the motor controller of the type of a particular motor.
|
void |
setMotorZeroPowerBehavior(int motor,
DcMotor.ZeroPowerBehavior zeroPowerBehavior)
Sets the behavior of the motor when zero power is applied.
|
public static final byte POWER_MAX
public static final byte POWER_MIN
protected static final double apiPowerMin
protected static final double apiPowerMax
protected MatrixMasterController master
public MatrixDcMotorController(MatrixMasterController master)
protected byte runModeToFlagMatrix(DcMotor.RunMode mode)
protected DcMotor.RunMode flagMatrixToRunMode(byte flag)
public boolean isBusy(int motor)
DcMotorControllerisBusy in interface DcMotorControllermotor - port of motorpublic void resetDeviceConfigurationForOpMode(int motor)
DcMotorControllerresetDeviceConfigurationForOpMode in interface DcMotorControllerpublic void setMotorType(int motor,
MotorConfigurationType motorType)
DcMotorControllersetMotorType in interface DcMotorControllermotor - port of the motor in questionmotorType - the motor type.public MotorConfigurationType getMotorType(int motor)
DcMotorControllergetMotorType in interface DcMotorControllermotor - the motor in questionMotorConfigurationType.getUnspecifiedMotorType()
if no type has been configuredpublic void setMotorMode(int motor,
DcMotor.RunMode mode)
DcMotorControllerDcMotor.RunModesetMotorMode in interface DcMotorControllermotor - port of motormode - run modepublic DcMotor.RunMode getMotorMode(int motor)
DcMotorControllergetMotorMode in interface DcMotorControllermotor - port of motorpublic void setMotorZeroPowerBehavior(int motor,
DcMotor.ZeroPowerBehavior zeroPowerBehavior)
DcMotorControllersetMotorZeroPowerBehavior in interface DcMotorControllerzeroPowerBehavior - the behavior of the motor when zero power is applied.public DcMotor.ZeroPowerBehavior getMotorZeroPowerBehavior(int motor)
DcMotorControllergetMotorZeroPowerBehavior in interface DcMotorControllerprotected void setMotorPowerFloat(int motor)
public boolean getMotorPowerFloat(int motor)
DcMotorControllergetMotorPowerFloat in interface DcMotorControllermotor - port of motorpublic void setMotorPower(java.util.Set<DcMotor> motors, double power)
motors - This provides an optimization specific to the Matrix controller
by using the controller's pending bit to tell all of the motors
to start at the same time.power - The motor power to apply to all motors in the set.public void setMotorPower(int motor,
double power)
DcMotorControllersetMotorPower in interface DcMotorControllermotor - port of motorpower - from -1.0 to 1.0public double getMotorPower(int motor)
DcMotorControllergetMotorPower in interface DcMotorControllermotor - port of motorpublic void setMotorTargetPosition(int motor,
int position)
DcMotorControllersetMotorTargetPosition in interface DcMotorControllermotor - port of motorposition - range from Integer.MIN_VALUE to Integer.MAX_VALUEpublic int getMotorTargetPosition(int motor)
DcMotorControllergetMotorTargetPosition in interface DcMotorControllermotor - port of motorpublic int getMotorCurrentPosition(int motor)
DcMotorControllergetMotorCurrentPosition in interface DcMotorControllermotor - port of motorpublic int getBattery()
public HardwareDevice.Manufacturer getManufacturer()
HardwareDevicegetManufacturer in interface HardwareDevicepublic java.lang.String getDeviceName()
HardwareDevicegetDeviceName in interface HardwareDevicepublic java.lang.String getConnectionInfo()
HardwareDevicegetConnectionInfo in interface HardwareDevicepublic int getVersion()
HardwareDevicegetVersion in interface HardwareDevicepublic void resetDeviceConfigurationForOpMode()
HardwareDeviceresetDeviceConfigurationForOpMode in interface HardwareDevicepublic void close()
HardwareDeviceclose in interface HardwareDevicepublic void handleReadBattery(byte[] buffer)
public void handleReadPosition(MatrixI2cTransaction transaction, byte[] buffer)
public void handleReadTargetPosition(MatrixI2cTransaction transaction, byte[] buffer)
public void handleReadMode(MatrixI2cTransaction transaction, byte[] buffer)