public final class HiTechnicNxtDcMotorController extends HiTechnicNxtController implements DcMotorController, VoltageSensor
HardwareDevice.Manufacturer
Modifier and Type | Field and Description |
---|---|
protected static byte[] |
ADDRESS_MOTOR_CURRENT_ENCODER_VALUE_MAP |
protected static byte[] |
ADDRESS_MOTOR_MODE_MAP |
protected static byte[] |
ADDRESS_MOTOR_POWER_MAP |
protected static byte[] |
ADDRESS_MOTOR_TARGET_ENCODER_VALUE_MAP |
protected static double |
apiPowerMax |
protected static double |
apiPowerMin |
protected static byte |
bPowerBrake |
protected static byte |
bPowerFloat |
protected static byte |
bPowerMax |
protected static byte |
bPowerMin |
static int |
BUSY_THRESHOLD |
protected static byte |
cbEncoder |
protected static byte |
CHANNEL_MODE_FLAG_SELECT_RESET |
protected static byte |
CHANNEL_MODE_FLAG_SELECT_RUN_CONSTANT_SPEED_NXT |
protected static byte |
CHANNEL_MODE_FLAG_SELECT_RUN_POWER_CONTROL_ONLY_NXT |
protected static byte |
CHANNEL_MODE_FLAG_SELECT_RUN_TO_POSITION |
protected static int |
CHANNEL_MODE_MASK_BUSY |
protected static int |
CHANNEL_MODE_MASK_EMPTY_D5 |
protected static int |
CHANNEL_MODE_MASK_ERROR |
protected static int |
CHANNEL_MODE_MASK_LOCK |
protected static int |
CHANNEL_MODE_MASK_NO_TIMEOUT |
protected static int |
CHANNEL_MODE_MASK_REVERSE |
protected static int |
CHANNEL_MODE_MASK_SELECTION |
protected static I2cAddr |
I2C_ADDRESS |
protected static int |
iRegWindowFirst |
protected static int |
iRegWindowMax |
protected static int |
MOTOR_FIRST |
protected static int |
MOTOR_LAST |
protected static int |
MOTOR_MAX |
protected static int |
OFFSET_UNUSED |
context, i2cDevice, i2cDeviceSynch, isEngaged, isHardwareInitialized, isHooked
controller, physicalPort
Constructor and Description |
---|
HiTechnicNxtDcMotorController(Context context,
LegacyModule module,
int physicalPort) |
Modifier and Type | Method and Description |
---|---|
protected void |
controllerNowArmedOrPretending()
Our controller is newly armed or pretending, or we're newly constructed on a controller
|
protected void |
doHook() |
protected void |
doUnhook() |
protected void |
floatHardware() |
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.
|
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
|
double |
getVoltage()
Get the current voltage
|
void |
initializeHardware() |
protected void |
initPID() |
boolean |
isBusy(int motor)
Is the motor busy?
|
static DcMotor.RunMode |
modeFromByte(byte flag) |
static byte |
modeToByte(DcMotor.RunMode mode) |
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
|
void |
setMotorMode(int motor,
DcMotor.RunMode mode)
Set the current motor mode.
|
void |
setMotorPower(int motor,
double power)
Set the current motor power
|
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.
|
protected void |
validateMotor(int motor) |
adjustHookingToMatchEngagement, close, controllerNowDisarmed, disengage, engage, getManufacturer, hook, isArmed, isEngaged, read8, unhook, write, write8
finishConstruction, getI2cController, getPort, onModuleStateChange
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, getManufacturer
protected static final int MOTOR_FIRST
protected static final int MOTOR_LAST
protected static final int MOTOR_MAX
protected static final I2cAddr I2C_ADDRESS
protected static final int OFFSET_UNUSED
protected static final int CHANNEL_MODE_MASK_SELECTION
protected static final int CHANNEL_MODE_MASK_LOCK
protected static final int CHANNEL_MODE_MASK_REVERSE
protected static final int CHANNEL_MODE_MASK_NO_TIMEOUT
protected static final int CHANNEL_MODE_MASK_EMPTY_D5
protected static final int CHANNEL_MODE_MASK_ERROR
protected static final int CHANNEL_MODE_MASK_BUSY
protected static final byte CHANNEL_MODE_FLAG_SELECT_RUN_POWER_CONTROL_ONLY_NXT
protected static final byte CHANNEL_MODE_FLAG_SELECT_RUN_CONSTANT_SPEED_NXT
protected static final byte CHANNEL_MODE_FLAG_SELECT_RUN_TO_POSITION
protected static final byte CHANNEL_MODE_FLAG_SELECT_RESET
protected static final byte[] ADDRESS_MOTOR_POWER_MAP
protected static final byte[] ADDRESS_MOTOR_MODE_MAP
protected static final byte[] ADDRESS_MOTOR_TARGET_ENCODER_VALUE_MAP
protected static final byte[] ADDRESS_MOTOR_CURRENT_ENCODER_VALUE_MAP
protected static final int iRegWindowFirst
protected static final int iRegWindowMax
protected static final byte bPowerBrake
protected static final byte bPowerFloat
protected static final byte bPowerMax
protected static final byte bPowerMin
protected static final byte cbEncoder
protected static final double apiPowerMin
protected static final double apiPowerMax
public static final int BUSY_THRESHOLD
public HiTechnicNxtDcMotorController(Context context, LegacyModule module, int physicalPort)
protected void controllerNowArmedOrPretending()
controllerNowArmedOrPretending
in class I2cControllerPortDeviceImpl
protected void doHook()
doHook
in class HiTechnicNxtController
public void initializeHardware()
initializeHardware
in class HiTechnicNxtController
protected void doUnhook()
doUnhook
in class HiTechnicNxtController
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 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 boolean isBusy(int motor)
DcMotorController
isBusy
in interface DcMotorController
motor
- port of motorpublic 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 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 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 motorprotected void validateMotor(int motor)
public static DcMotor.RunMode modeFromByte(byte flag)
public static byte modeToByte(DcMotor.RunMode mode)
protected void initPID()
protected void floatHardware()
floatHardware
in class HiTechnicNxtController
public double getVoltage()
VoltageSensor
getVoltage
in interface VoltageSensor