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)
DcMotorController
isBusy
in interface DcMotorController
motor
- port of motorpublic void resetDeviceConfigurationForOpMode(int motor)
DcMotorController
resetDeviceConfigurationForOpMode
in interface DcMotorController
public void setMotorType(int motor, MotorConfigurationType motorType)
DcMotorController
setMotorType
in interface DcMotorController
motor
- port of the motor in questionmotorType
- the motor type.public MotorConfigurationType getMotorType(int motor)
DcMotorController
getMotorType
in interface DcMotorController
motor
- the motor in questionMotorConfigurationType.getUnspecifiedMotorType()
if no type has been configuredpublic void setMotorMode(int motor, DcMotor.RunMode mode)
DcMotorController
DcMotor.RunMode
setMotorMode
in interface DcMotorController
motor
- port of motormode
- run modepublic DcMotor.RunMode getMotorMode(int motor)
DcMotorController
getMotorMode
in interface DcMotorController
motor
- port of motorpublic void setMotorZeroPowerBehavior(int motor, DcMotor.ZeroPowerBehavior zeroPowerBehavior)
DcMotorController
setMotorZeroPowerBehavior
in interface DcMotorController
zeroPowerBehavior
- the behavior of the motor when zero power is applied.public DcMotor.ZeroPowerBehavior getMotorZeroPowerBehavior(int motor)
DcMotorController
getMotorZeroPowerBehavior
in interface DcMotorController
protected void setMotorPowerFloat(int motor)
public boolean getMotorPowerFloat(int motor)
DcMotorController
getMotorPowerFloat
in interface DcMotorController
motor
- 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)
DcMotorController
setMotorPower
in interface DcMotorController
motor
- port of motorpower
- from -1.0 to 1.0public double getMotorPower(int motor)
DcMotorController
getMotorPower
in interface DcMotorController
motor
- port of motorpublic void setMotorTargetPosition(int motor, int position)
DcMotorController
setMotorTargetPosition
in interface DcMotorController
motor
- port of motorposition
- range from Integer.MIN_VALUE to Integer.MAX_VALUEpublic int getMotorTargetPosition(int motor)
DcMotorController
getMotorTargetPosition
in interface DcMotorController
motor
- port of motorpublic int getMotorCurrentPosition(int motor)
DcMotorController
getMotorCurrentPosition
in interface DcMotorController
motor
- port of motorpublic int getBattery()
public HardwareDevice.Manufacturer getManufacturer()
HardwareDevice
getManufacturer
in interface HardwareDevice
public java.lang.String getDeviceName()
HardwareDevice
getDeviceName
in interface HardwareDevice
public java.lang.String getConnectionInfo()
HardwareDevice
getConnectionInfo
in interface HardwareDevice
public int getVersion()
HardwareDevice
getVersion
in interface HardwareDevice
public void resetDeviceConfigurationForOpMode()
HardwareDevice
resetDeviceConfigurationForOpMode
in interface HardwareDevice
public void close()
HardwareDevice
close
in interface HardwareDevice
public 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)