Package lejos.hardware.device
Class NXTMMX
- java.lang.Object
-
- lejos.hardware.Device
-
- lejos.hardware.sensor.BaseSensor
-
- lejos.hardware.sensor.I2CSensor
-
- lejos.hardware.device.NXTMMX
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,SensorConstants,SensorMode,SensorModes,SampleProvider
public class NXTMMX extends I2CSensor
Supports the Mindsensors NXTMMX motor multiplexor. This device allows you to connect two additional motors to your robot using a sensor port. Multiple NXTMMXs can be chained together when addressed correctly.Create an instance of this class and use the factory methods to provide a
MMXRegulatedMotororMMXMotorinstance.- Author:
- Kirk P Thompsonn
- See Also:
MMXRegulatedMotor,MMXMotor
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_MMX_ADDRESSThe default I2C address (0x06) for the NXTMMX.static intMOTOR_M1Represents Motor 1 as indicated on the controllerstatic intMOTOR_M2Represents Motor 2 as indicated on the controller-
Fields inherited from class lejos.hardware.sensor.I2CSensor
address, DEFAULT_I2C_ADDRESS, port, REG_PRODUCT_ID, REG_VENDOR_ID, REG_VERSION, retryCount
-
Fields inherited from class lejos.hardware.sensor.BaseSensor
currentMode, modes
-
Fields inherited from interface lejos.hardware.sensor.SensorConstants
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, BROWN, GREEN, GREEN_INDEX, MAX_TYPE, MIN_TYPE, MODE_RAW, NXT_ADC_RES, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HIGHSPEED, TYPE_HIGHSPEED_9V, TYPE_HISPEED, TYPE_LIGHT_ACTIVE, TYPE_LIGHT_INACTIVE, TYPE_LOWSPEED, TYPE_LOWSPEED_9V, TYPE_NO_SENSOR, TYPE_REFLECTION, TYPE_SOUND_DB, TYPE_SOUND_DBA, TYPE_SWITCH, TYPE_TEMPERATURE, WHITE, YELLOW
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfltMotors()Synchronized Float both motorsMMXMotorgetBasicMotor(int motorID)Get aMMXMotorinstance that is associated with themotorID.MMXRegulatedMotorgetRegulatedMotor(int motorID)Get aMMXRegulatedMotorinstance that is associated with themotorID.floatgetVoltage()Returns the voltage supplied to the NXTMMXvoidstopMotors()Synchronized stop both motors-
Methods inherited from class lejos.hardware.sensor.I2CSensor
fetchString, getAddress, getData, getData, getPort, getProductID, getRetryCount, getVendorID, getVersion, sendData, sendData, sendData, setAddress, setRetryCount
-
Methods inherited from class lejos.hardware.sensor.BaseSensor
fetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, getName, sampleSize, setCurrentMode, setCurrentMode, setModes
-
Methods inherited from class lejos.hardware.Device
close, releaseOnClose
-
-
-
-
Field Detail
-
MOTOR_M1
public static final int MOTOR_M1
Represents Motor 1 as indicated on the controller- See Also:
- Constant Field Values
-
MOTOR_M2
public static final int MOTOR_M2
Represents Motor 2 as indicated on the controller- See Also:
- Constant Field Values
-
DEFAULT_MMX_ADDRESS
public static final int DEFAULT_MMX_ADDRESS
The default I2C address (0x06) for the NXTMMX.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NXTMMX
public NXTMMX(I2CPort port)
Constructor for the NXTMMX- Parameters:
port- - the port its plugged in to
-
NXTMMX
public NXTMMX(Port port)
Constructor for the NXTMMX- Parameters:
port- - the port its plugged in to
-
NXTMMX
public NXTMMX(I2CPort port, int address)
Constructor for the NXTMMX- Parameters:
port- - the sensor port its plugged in toaddress- The I2C address for the device
-
NXTMMX
public NXTMMX(Port port, int address)
Constructor for the NXTMMX- Parameters:
port- - the sensor port its plugged in toaddress- The I2C address for the device
-
-
Method Detail
-
getRegulatedMotor
public MMXRegulatedMotor getRegulatedMotor(int motorID)
Get aMMXRegulatedMotorinstance that is associated with themotorID.- Parameters:
motorID- The motor ID number. This is indicated on the NXTMMX Motor Controller and is represented usingorMOTOR_M1.MOTOR_M2- Returns:
- The
MMXRegulatedMotorinstance - Throws:
java.lang.IllegalArgumentException- if invalidmotorIDjava.lang.UnsupportedOperationException- ifmotorIDhas already been used for aMMXMotormotor instance.- See Also:
MMXRegulatedMotor,getBasicMotor(int)
-
getBasicMotor
public MMXMotor getBasicMotor(int motorID)
Get aMMXMotorinstance that is associated with themotorID.- Parameters:
motorID- The motor ID number. This is indicated on the NXTMMX Motor Controller and is represented usingorMOTOR_M1.MOTOR_M2- Returns:
- The
MMXMotorinstance - Throws:
java.lang.IllegalArgumentException- if invalidmotorIDjava.lang.UnsupportedOperationException- ifmotorIDhas already been used for aMMXRegulatedMotormotor instance.- See Also:
MMXMotor,getRegulatedMotor(int)
-
getVoltage
public float getVoltage()
Returns the voltage supplied to the NXTMMX- Returns:
- the voltage in volts
-
stopMotors
public void stopMotors()
Synchronized stop both motors
-
fltMotors
public void fltMotors()
Synchronized Float both motors
-
-