@I2cDeviceType @DeviceProperties(name="@string/mr_range_name", description="@string/mr_range_description", xmlTag="ModernRoboticsI2cRangeSensor", builtIn=true) public class ModernRoboticsI2cRangeSensor extends I2cDeviceSynchDevice<I2cDeviceSynch> implements DistanceSensor, OpticalDistanceSensor, I2cAddrConfig
ModernRoboticsI2cRangeSensor
implements support for the MR ultrasonic/optical combo
range sensor.Modifier and Type | Class and Description |
---|---|
static class |
ModernRoboticsI2cRangeSensor.Register |
HardwareDevice.Manufacturer
Modifier and Type | Field and Description |
---|---|
static I2cAddr |
ADDRESS_I2C_DEFAULT |
double |
aParam
Experimentally determined constants for converting optical measurements to distance.
|
protected static double |
apiLevelMax |
protected static double |
apiLevelMin |
double |
bParam |
protected static int |
cmUltrasonicMax |
double |
cParam |
double |
dParam |
int |
rawOpticalMinValid |
deviceClient, deviceClientIsOwned, isInitialized
distanceOutOfRange
Constructor and Description |
---|
ModernRoboticsI2cRangeSensor(I2cDeviceSynch deviceClient) |
Modifier and Type | Method and Description |
---|---|
protected double |
cmFromOptical(int rawOptical)
Converts a raw optical inverse-square reading into a fitted, calibrated linear reading in cm.
|
double |
cmOptical() |
double |
cmUltrasonic() |
protected boolean |
doInitialize()
Actually carries out the initialization of the instance.
|
void |
enableLed(boolean enable)
Enable the LED light
|
java.lang.String |
getDeviceName()
Returns a string suitable for display to the user as to the type of device.
|
double |
getDistance(DistanceUnit unit)
Returns a calibrated, linear sense of distance as read by the infrared proximity
part of the sensor.
|
I2cAddr |
getI2cAddress()
Returns the I2C address currently in use to communicate with an I2C hardware device
|
double |
getLightDetected()
Get the amount of light detected by the sensor, scaled and cliped to a range
which is a pragmatically useful sensitivity.
|
HardwareDevice.Manufacturer |
getManufacturer()
Returns an indication of the manufacturer of this device.
|
double |
getRawLightDetected()
Returns a signal whose strength is proportional to the intensity of the light measured.
|
double |
getRawLightDetectedMax()
Returns the maximum value that can be returned by
LightSensor.getRawLightDetected() . |
int |
rawOptical()
Returns the raw reading on the optical sensor
|
int |
rawUltrasonic()
Returns the raw reading on the ultrasonic sensor
|
byte |
read8(ModernRoboticsI2cRangeSensor.Register reg) |
protected int |
readUnsignedByte(ModernRoboticsI2cRangeSensor.Register reg) |
void |
setI2cAddress(I2cAddr newAddress)
Configures a new I2C address to use
|
protected void |
setOptimalReadWindow() |
java.lang.String |
status()
Status of this sensor, in string form
|
void |
write8(ModernRoboticsI2cRangeSensor.Register reg,
byte value) |
void |
write8(ModernRoboticsI2cRangeSensor.Register reg,
byte value,
I2cWaitControl waitControl) |
close, disengage, engage, getConnectionInfo, getDeviceClient, getVersion, initialize, initializeIfNecessary, onModuleStateChange, registerArmingStateCallback, resetDeviceConfigurationForOpMode
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, getConnectionInfo, getVersion, resetDeviceConfigurationForOpMode
public static final I2cAddr ADDRESS_I2C_DEFAULT
protected static final double apiLevelMin
protected static final double apiLevelMax
public double aParam
public double bParam
public double cParam
public double dParam
public int rawOpticalMinValid
protected static final int cmUltrasonicMax
public ModernRoboticsI2cRangeSensor(I2cDeviceSynch deviceClient)
protected void setOptimalReadWindow()
protected boolean doInitialize()
I2cDeviceSynchDevice
doInitialize
in class I2cDeviceSynchDevice<I2cDeviceSynch>
public double getDistance(DistanceUnit unit)
getDistance
in interface DistanceSensor
unit
- the unit of distance in which the result should be returnedprotected double cmFromOptical(int rawOptical)
public double cmUltrasonic()
public double cmOptical()
public double getLightDetected()
LightSensor
getLightDetected
in interface LightSensor
public double getRawLightDetected()
LightSensor
getRawLightDetected
in interface LightSensor
public double getRawLightDetectedMax()
LightSensor
LightSensor.getRawLightDetected()
.getRawLightDetectedMax
in interface LightSensor
LightSensor.getRawLightDetected()
public void enableLed(boolean enable)
LightSensor
enableLed
in interface LightSensor
enable
- true to enable; false to disablepublic java.lang.String status()
LightSensor
status
in interface LightSensor
public int rawUltrasonic()
public int rawOptical()
public void setI2cAddress(I2cAddr newAddress)
I2cAddrConfig
setI2cAddress
in interface I2cAddrConfig
newAddress
- the new I2C address to usepublic I2cAddr getI2cAddress()
I2cAddressableDevice
getI2cAddress
in interface I2cAddressableDevice
public HardwareDevice.Manufacturer getManufacturer()
HardwareDevice
getManufacturer
in interface HardwareDevice
public java.lang.String getDeviceName()
HardwareDevice
getDeviceName
in interface HardwareDevice
public byte read8(ModernRoboticsI2cRangeSensor.Register reg)
public void write8(ModernRoboticsI2cRangeSensor.Register reg, byte value)
public void write8(ModernRoboticsI2cRangeSensor.Register reg, byte value, I2cWaitControl waitControl)
protected int readUnsignedByte(ModernRoboticsI2cRangeSensor.Register reg)