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, isHookedcontroller, 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, write8finishConstruction, getI2cController, getPort, onModuleStateChangeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclose, getManufacturerprotected 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 I2cControllerPortDeviceImplprotected void doHook()
doHook in class HiTechnicNxtControllerpublic void initializeHardware()
initializeHardware in class HiTechnicNxtControllerprotected void doUnhook()
doUnhook in class HiTechnicNxtControllerpublic 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 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 boolean isBusy(int motor)
DcMotorControllerisBusy in interface DcMotorControllermotor - port of motorpublic 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 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 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 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 HiTechnicNxtControllerpublic double getVoltage()
VoltageSensorgetVoltage in interface VoltageSensor