Package lejos.remote.nxt
Class RemoteNXTAnalogPort
- java.lang.Object
-
- lejos.remote.nxt.RemoteNXTIOPort
-
- lejos.remote.nxt.RemoteNXTAnalogPort
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,AnalogPort,BasicSensorPort,IOPort,EV3SensorConstants,SensorConstants
public class RemoteNXTAnalogPort extends RemoteNXTIOPort implements AnalogPort
This class provides access to the EV3 Analog based sensor ports and other analog data sources.- Author:
- Lawrie Griffiths
-
-
Field Summary
-
Fields inherited from class lejos.remote.nxt.RemoteNXTIOPort
currentMode, dc, nxtCommand, openPorts, port, ref, typ
-
Fields inherited from interface lejos.hardware.sensor.EV3SensorConstants
ADC_REF, ADC_RES, CMD_AUTOMATIC, CMD_COL_AMB, CMD_COL_BLU, CMD_COL_COL, CMD_COL_GRN, CMD_COL_RED, CMD_CONNECTED, CMD_DISCONNECTED, CMD_FLOAT, CMD_NONE, CMD_PIN1, CMD_PIN5, CMD_SET, CONN_DAISYCHAIN, CONN_ERROR, CONN_INPUT_DUMB, CONN_INPUT_UART, CONN_NONE, CONN_NXT_COLOR, CONN_NXT_DUMB, CONN_NXT_IIC, CONN_OUTPUT_DUMB, CONN_OUTPUT_INTELLIGENT, CONN_OUTPUT_TACHO, CONN_UNKNOWN, IIC_DATA_LENGTH, MAX_DEVICE_DATALENGTH, MOTORS, PORTS, STATUS_BUSY, STATUS_FAIL, STATUS_OK, STATUS_STOP, TYPE_ERROR, TYPE_IIC_UNKNOWN, TYPE_MINITACHO, TYPE_NEWTACHO, TYPE_NONE, TYPE_NXT_COLOR, TYPE_NXT_IIC, TYPE_NXT_LIGHT, TYPE_NXT_SOUND, TYPE_NXT_TEST, TYPE_NXT_TOUCH, TYPE_TACHO, TYPE_TERMINAL, TYPE_THIRD_PARTY_END, TYPE_THIRD_PARTY_START, TYPE_UNKNOWN, UART_MAX_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
-
-
Constructor Summary
Constructors Constructor Description RemoteNXTAnalogPort(NXTCommand nxtCommand)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intgetAnalogSensorType(int port)Get the type of analog sensor (if any) attached to the portvoidgetFloats(float[] vals, int offset, int length)Return a series of results obtained from the sensor.floatgetPin1()return the voltage present on pin 1 of the sensor portfloatgetPin6()return the voltage present on pin 6 of the sensor portstatic intgetPortType(int port)get the type of the portbooleansetMode(int mode)Set the sensor modebooleansetType(int type)Set the sensor typebooleansetTypeAndMode(int type, int mode)Set the sensor type and mode-
Methods inherited from class lejos.remote.nxt.RemoteNXTIOPort
close, getMode, getName, getType, open, setPinMode
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface lejos.hardware.port.BasicSensorPort
getMode, getType
-
Methods inherited from interface lejos.hardware.port.IOPort
close, getName, setPinMode
-
-
-
-
Constructor Detail
-
RemoteNXTAnalogPort
public RemoteNXTAnalogPort(NXTCommand nxtCommand)
-
-
Method Detail
-
setTypeAndMode
public boolean setTypeAndMode(int type, int mode)Set the sensor type and mode- Specified by:
setTypeAndModein interfaceBasicSensorPort- Overrides:
setTypeAndModein classRemoteNXTIOPort- Parameters:
type- the sensor typemode- the sensor mode- Returns:
- true if success
-
setType
public boolean setType(int type)
Set the sensor type- Specified by:
setTypein interfaceBasicSensorPort- Overrides:
setTypein classRemoteNXTIOPort- Parameters:
type- the sensor type- Returns:
- true if success
-
setMode
public boolean setMode(int mode)
Set the sensor mode- Specified by:
setModein interfaceBasicSensorPort- Overrides:
setModein classRemoteNXTIOPort- Parameters:
mode- the sensor mode- Returns:
- true if success
-
getPortType
public static int getPortType(int port)
get the type of the port- Parameters:
port-- Returns:
- true if sucesss
-
getAnalogSensorType
public static int getAnalogSensorType(int port)
Get the type of analog sensor (if any) attached to the port- Parameters:
port-- Returns:
- the type of analog sensor
-
getFloats
public void getFloats(float[] vals, int offset, int length)Description copied from interface:AnalogPortReturn a series of results obtained from the sensor. This is currently only used for the NXT color sensor- Specified by:
getFloatsin interfaceAnalogPort- Parameters:
vals- Place to store the valuesoffset- Offset into the above array to start storinglength- number of values to read
-
getPin6
public float getPin6()
Description copied from interface:AnalogPortreturn the voltage present on pin 6 of the sensor port- Specified by:
getPin6in interfaceAnalogPort- Returns:
- voltage reading
-
getPin1
public float getPin1()
Description copied from interface:AnalogPortreturn the voltage present on pin 1 of the sensor port- Specified by:
getPin1in interfaceAnalogPort- Returns:
- voltage reading
-
-