public class SMUXSensorPort
extends java.lang.Object
implements lejos.nxt.LegacySensorPort, lejos.nxt.I2CPort
lejos.nxt.addon.SensorMux
class, Xander's tutorial on how to
use smuxes, his RobotC driver suite and the HiTechnic Website.
Lego color sensor not supported, see Xander's guide on the smux for which
other sensors are/aren't. Essentially a version of the SensorPort class which
sends requests to the sensor through the smux.
This class has been tested with a pair of Ultrasonic Sensors and a Pair of
Light SensorsSMUX
,
lejos.nxt.addon.SensorMux
,
http://www.breigh.com/xander/HTSMUX-Tutorial-LATEST.pdf,
http://botbench.com/driversuite/,
https://www.hitechnic.com/cgi-bin/commerce.cgi?preadd=action&key=NSX2020BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, GREEN, GREEN_INDEX, MAX_AD_RAW, MAX_TYPE, MIN_TYPE, MODE_ANGLESTEP, MODE_BOOLEAN, MODE_CELSIUS, MODE_FARENHEIT, MODE_PCTFULLSCALE, MODE_PERIODCOUNTER, MODE_RAW, MODE_TRANSITIONCNT, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, 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
Constructor and Description |
---|
SMUXSensorPort(lejos.nxt.SensorPort port,
int portID)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
activate()
NOT Implemented
|
int |
getMode()
gets the mode of the smux's sensor currently not implemented (But doesn't
throw an unsupported operation exception
|
SMUX |
getSMUX() |
int |
getType()
gets the type of the smux's sensor currently not implemented (but doesn't
throw an unsupported operation exception)
|
void |
i2cDisable()
not yet implemented
|
void |
i2cEnable(int mode)
Calles i2cEnable on the smux's sensor port
|
int |
i2cStatus()
not yet implemented
|
int |
i2cTransaction(int deviceAddress,
byte[] writeBuf,
int writeOffset,
int writeLen,
byte[] readBuf,
int readOffset,
int readLen)
Can only read data from the 16 byte i2c byte buffer in the
sensormultiplexer.
|
void |
passivate()
NOT Implemented
|
boolean |
readBooleanValue()
Reads a boolean value from an analog sensor (like the touch sensor)
|
int |
readRawValue()
Reads a value from an analog sensor Implementation based on the one in
the SensorMux class.
|
int |
readValue()
Reads a value, essentially copied from lejos.nxt.SensorPort.
|
void |
setMode(int newMode)
sets the mode of the smux's sensor currently not implemented (but doesn't
throw an unsupported operation exception)
|
void |
setType(int newType)
Sets the type of the smux's sensor.
|
void |
setTypeAndMode(int type,
int mode)
Calls setType(type); and then setMode(mode);
|
public SMUXSensorPort(lejos.nxt.SensorPort port, int portID)
port
- the port on the NXT the smux is connected to. Only takes
SensorPort.S1-4 (constants)portID
- the port on the smux that this sensor is connected to.
Valid values are 1-4.SensorPort
,
SMUX.getInstance(lejos.nxt.SensorPort)
public SMUX getSMUX()
public void activate()
activate
in interface lejos.nxt.LegacySensorPort
java.lang.UnsupportedOperationException
- This method isn't
implementedLegacySensorPort.activate()
public void passivate()
passivate
in interface lejos.nxt.LegacySensorPort
java.lang.UnsupportedOperationException
- This method isn't
implementedLegacySensorPort.passivate()
public boolean readBooleanValue()
readBooleanValue
in interface lejos.nxt.ADSensorPort
ADSensorPort.readBooleanValue()
public int readRawValue()
readRawValue
in interface lejos.nxt.ADSensorPort
ADSensorPort.readRawValue()
,
lejos.nxt.addon.SensorMux
public int readValue()
readValue
in interface lejos.nxt.ADSensorPort
SensorPort.readValue()
public int getMode()
getMode
in interface lejos.nxt.BasicSensorPort
BasicSensorPort.getMode()
public void setMode(int newMode)
setMode
in interface lejos.nxt.BasicSensorPort
newMode
- the mode to set it toBasicSensorPort.setMode(int)
public int getType()
getType
in interface lejos.nxt.BasicSensorPort
BasicSensorPort.getType()
public void setType(int newType)
setType
in interface lejos.nxt.BasicSensorPort
newType
- the type to set it toBasicSensorPort.setType(int)
public void setTypeAndMode(int type, int mode)
setTypeAndMode
in interface lejos.nxt.BasicSensorPort
type
- the type to set the sensor tomode
- the mode to set the sensor tosetMode(int)
,
setType(int)
,
BasicSensorPort.setTypeAndMode(int, int)
public void i2cEnable(int mode)
i2cEnable
in interface lejos.nxt.I2CPort
mode
- see i2cEnableI2CPort.i2cEnable(int)
public void i2cDisable()
i2cDisable
in interface lejos.nxt.I2CPort
I2CPort.i2cDisable()
public int i2cStatus()
i2cStatus
in interface lejos.nxt.I2CPort
I2CPort.i2cStatus()
public int i2cTransaction(int deviceAddress, byte[] writeBuf, int writeOffset, int writeLen, byte[] readBuf, int readOffset, int readLen)
i2cTransaction
in interface lejos.nxt.I2CPort