public class HiTechnicNxtIrSeekerSensor extends I2cControllerPortDeviceImpl implements IrSeekerSensor, I2cAddressableDevice, I2cController.I2cPortReadyCallback
IrSeekerSensor.IrSeekerIndividualSensor, IrSeekerSensor.Mode
HardwareDevice.Manufacturer
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_SIGNAL_DETECTED_THRESHOLD |
static byte |
DIRECTION |
static double[] |
DIRECTION_TO_ANGLE |
static I2cAddr |
I2C_ADDRESS |
static byte |
INVALID_ANGLE |
static byte |
MAX_ANGLE |
static double |
MAX_SENSOR_STRENGTH |
static int |
MEM_AC_START_ADDRESS |
static int |
MEM_DC_START_ADDRESS |
static int |
MEM_MODE_ADDRESS |
static int |
MEM_READ_LENGTH |
static byte |
MIN_ANGLE |
static byte |
MODE_AC |
static byte |
MODE_DC |
static byte |
SENSOR_COUNT |
static byte |
SENSOR_FIRST |
controller, physicalPort
Constructor and Description |
---|
HiTechnicNxtIrSeekerSensor(I2cController module,
int physicalPort) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this device
|
protected void |
controllerNowArmedOrPretending()
intended as a subclass hook
|
double |
getAngle()
Estimated angle in which the signal is coming from
|
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.
|
I2cAddr |
getI2cAddress()
Get the current I2C Address of this object.
|
IrSeekerSensor.IrSeekerIndividualSensor[] |
getIndividualSensors()
Get a list of all IR sensors attached to this seeker.
|
HardwareDevice.Manufacturer |
getManufacturer()
Returns an indication of the manufacturer of this device.
|
IrSeekerSensor.Mode |
getMode()
Get the device mode
|
double |
getSignalDetectedThreshold()
Get the minimum threshold for a signal to be considered detected
|
double |
getStrength()
IR Signal strength
|
int |
getVersion()
Version
|
void |
portIsReady(int port) |
void |
resetDeviceConfigurationForOpMode()
Resets the device's configuration to that which is expected at the beginning of an OpMode.
|
void |
setI2cAddress(I2cAddr newAddress)
Set the I2C address to a new value.
|
void |
setMode(IrSeekerSensor.Mode mode)
Set the device mode
|
void |
setSignalDetectedThreshold(double threshold)
Set the minimum threshold for a signal to be considered detected
|
boolean |
signalDetected()
Returns true if an IR signal is detected
|
java.lang.String |
toString() |
controllerNowDisarmed, finishConstruction, getI2cController, getPort, onModuleStateChange
public static final I2cAddr I2C_ADDRESS
public static final int MEM_MODE_ADDRESS
public static final int MEM_DC_START_ADDRESS
public static final int MEM_AC_START_ADDRESS
public static final int MEM_READ_LENGTH
public static final byte MODE_AC
public static final byte MODE_DC
public static final byte DIRECTION
public static final byte SENSOR_FIRST
public static final byte SENSOR_COUNT
public static final double MAX_SENSOR_STRENGTH
public static final byte INVALID_ANGLE
public static final byte MIN_ANGLE
public static final byte MAX_ANGLE
public static final double[] DIRECTION_TO_ANGLE
public static final double DEFAULT_SIGNAL_DETECTED_THRESHOLD
public HiTechnicNxtIrSeekerSensor(I2cController module, int physicalPort)
protected void controllerNowArmedOrPretending()
I2cControllerPortDeviceImpl
controllerNowArmedOrPretending
in class I2cControllerPortDeviceImpl
public java.lang.String toString()
toString
in class java.lang.Object
public void setSignalDetectedThreshold(double threshold)
IrSeekerSensor
setSignalDetectedThreshold
in interface IrSeekerSensor
threshold
- minimum thresholdpublic double getSignalDetectedThreshold()
IrSeekerSensor
getSignalDetectedThreshold
in interface IrSeekerSensor
public void setMode(IrSeekerSensor.Mode mode)
IrSeekerSensor
setMode
in interface IrSeekerSensor
mode
- sample ratepublic IrSeekerSensor.Mode getMode()
IrSeekerSensor
getMode
in interface IrSeekerSensor
public boolean signalDetected()
IrSeekerSensor
signalDetected
in interface IrSeekerSensor
public double getAngle()
IrSeekerSensor
If the signal is estimated to be directly ahead, 0 will be returned. If the signal is to the left a negative angle will be returned. If the signal is to the right a positive angle will be returned. If no signal is detected, a 0 will be returned.
NOTE: not all sensors give an accurate angle.
getAngle
in interface IrSeekerSensor
public double getStrength()
IrSeekerSensor
Detected IR signal strength, on a scale of 0.0 to 1.0, where 0 is no signal detected and 1 is max IR signal detected.
getStrength
in interface IrSeekerSensor
public IrSeekerSensor.IrSeekerIndividualSensor[] getIndividualSensors()
IrSeekerSensor
getIndividualSensors
in interface IrSeekerSensor
public void setI2cAddress(I2cAddr newAddress)
IrSeekerSensor
setI2cAddress
in interface IrSeekerSensor
public I2cAddr getI2cAddress()
IrSeekerSensor
getI2cAddress
in interface I2cAddressableDevice
getI2cAddress
in interface IrSeekerSensor
public void portIsReady(int port)
portIsReady
in interface I2cController.I2cPortReadyCallback
public HardwareDevice.Manufacturer getManufacturer()
HardwareDevice
getManufacturer
in interface HardwareDevice
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 close()
HardwareDevice
close
in interface HardwareDevice