@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, isInitializeddistanceOutOfRange| 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, resetDeviceConfigurationForOpModeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclose, getConnectionInfo, getVersion, resetDeviceConfigurationForOpModepublic 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()
I2cDeviceSynchDevicedoInitialize in class I2cDeviceSynchDevice<I2cDeviceSynch>public double getDistance(DistanceUnit unit)
getDistance in interface DistanceSensorunit - the unit of distance in which the result should be returnedprotected double cmFromOptical(int rawOptical)
public double cmUltrasonic()
public double cmOptical()
public double getLightDetected()
LightSensorgetLightDetected in interface LightSensorpublic double getRawLightDetected()
LightSensorgetRawLightDetected in interface LightSensorpublic double getRawLightDetectedMax()
LightSensorLightSensor.getRawLightDetected().getRawLightDetectedMax in interface LightSensorLightSensor.getRawLightDetected()public void enableLed(boolean enable)
LightSensorenableLed in interface LightSensorenable - true to enable; false to disablepublic java.lang.String status()
LightSensorstatus in interface LightSensorpublic int rawUltrasonic()
public int rawOptical()
public void setI2cAddress(I2cAddr newAddress)
I2cAddrConfigsetI2cAddress in interface I2cAddrConfignewAddress - the new I2C address to usepublic I2cAddr getI2cAddress()
I2cAddressableDevicegetI2cAddress in interface I2cAddressableDevicepublic HardwareDevice.Manufacturer getManufacturer()
HardwareDevicegetManufacturer in interface HardwareDevicepublic java.lang.String getDeviceName()
HardwareDevicegetDeviceName in interface HardwareDevicepublic 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)