public abstract class BroadcomColorSensorImpl extends I2cDeviceSynchDeviceWithParameters<I2cDeviceSynchSimple,BroadcomColorSensor.Parameters> implements BroadcomColorSensor, I2cAddrConfig, Light
BroadcomColorSensor.Gain, BroadcomColorSensor.LEDCurrent, BroadcomColorSensor.LEDPulseModulation, BroadcomColorSensor.MainControl, BroadcomColorSensor.MainStatus, BroadcomColorSensor.Parameters, BroadcomColorSensor.PSMeasurementRate, BroadcomColorSensor.PSResolution, BroadcomColorSensor.RegisterHardwareDevice.Manufacturer| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
TAG |
parametersdeviceClient, deviceClientIsOwned, isInitializedBROADCOM_APDS9151_ADDRESS, BROADCOM_APDS9151_ID| Modifier | Constructor and Description |
|---|---|
protected |
BroadcomColorSensorImpl(BroadcomColorSensor.Parameters params,
I2cDeviceSynchSimple deviceClient,
boolean isOwned) |
| Modifier and Type | Method and Description |
|---|---|
int |
alpha()
Get the amount of light detected by the sensor as an int.
|
int |
argb()
Get the sensed ARGB color value from the sensor.
|
int |
blue()
Get the Blue values detected by the sensor as an int.
|
protected void |
delay(int ms) |
protected void |
disable() |
protected void |
dumpState() |
protected void |
enable() |
void |
enableLed(boolean enable)
Enable the LED light
|
byte |
getDeviceID()
Returns the flavor of the Broadcom color sensor as reported by the chip itself
|
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.
|
HardwareDevice.Manufacturer |
getManufacturer()
Returns an indication of the manufacturer of this device.
|
NormalizedRGBA |
getNormalizedColors()
Reads the colors from the sensor
|
int |
green()
Get the Green values detected by the sensor as an int.
|
protected boolean |
internalInitialize(BroadcomColorSensor.Parameters parameters)
Actually attempts to carry out initialization with the indicated parameter block.
|
boolean |
isLightOn()
Answers whether the light is on or off
|
byte[] |
read(BroadcomColorSensor.Register reg,
int cb)
Low level: read data starting at the indicated register
|
byte |
read8(BroadcomColorSensor.Register reg)
Low level: read the byte starting at the indicated register
|
protected byte |
readMainCtrl() |
protected int |
readUnsignedByte(BroadcomColorSensor.Register reg) |
protected int |
readUnsignedShort(BroadcomColorSensor.Register reg,
java.nio.ByteOrder byteOrder) |
int |
red()
In this implementation, the
Color methods return 16 bit unsigned values. |
protected void |
setGain(BroadcomColorSensor.Gain gain) |
void |
setI2cAddress(I2cAddr i2cAddr)
Set the I2C address to a new value.
|
protected void |
setLEDParameters(BroadcomColorSensor.LEDPulseModulation pulseMod,
BroadcomColorSensor.LEDCurrent curr) |
protected void |
setPDrive(BroadcomColorSensor.LEDCurrent ledDrive) |
protected void |
setProximityPulseCount(int proximityPulseCount) |
protected void |
setPSRateAndRes(BroadcomColorSensor.PSResolution res,
BroadcomColorSensor.PSMeasurementRate rate) |
protected boolean |
testBits(byte value,
byte desired) |
protected boolean |
testBits(byte value,
byte mask,
byte desired) |
void |
write(BroadcomColorSensor.Register reg,
byte[] data)
Low level: write data starting at the indicated register
|
void |
write8(BroadcomColorSensor.Register reg,
int data)
Low level: write a byte to the indicated register
|
doInitialize, getParameters, initializeclose, disengage, engage, getConnectionInfo, getDeviceClient, getVersion, initialize, initializeIfNecessary, onModuleStateChange, registerArmingStateCallback, resetDeviceConfigurationForOpModeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetParameters, initializeclose, getConnectionInfo, getVersion, resetDeviceConfigurationForOpModepublic static final java.lang.String TAG
protected BroadcomColorSensorImpl(BroadcomColorSensor.Parameters params, I2cDeviceSynchSimple deviceClient, boolean isOwned)
protected boolean internalInitialize(BroadcomColorSensor.Parameters parameters)
I2cDeviceSynchDeviceWithParametersI2cDeviceSynchDeviceWithParameters.parameters
member variable.internalInitialize in class I2cDeviceSynchDeviceWithParameters<I2cDeviceSynchSimple,BroadcomColorSensor.Parameters>parameters - the parameter block with which to initializeprotected void dumpState()
protected void enable()
protected void disable()
protected boolean testBits(byte value,
byte desired)
protected boolean testBits(byte value,
byte mask,
byte desired)
protected byte readMainCtrl()
protected void setProximityPulseCount(int proximityPulseCount)
protected void setGain(BroadcomColorSensor.Gain gain)
protected void setPDrive(BroadcomColorSensor.LEDCurrent ledDrive)
public byte getDeviceID()
BroadcomColorSensorgetDeviceID in interface BroadcomColorSensorprotected void setLEDParameters(BroadcomColorSensor.LEDPulseModulation pulseMod, BroadcomColorSensor.LEDCurrent curr)
protected void setPSRateAndRes(BroadcomColorSensor.PSResolution res, BroadcomColorSensor.PSMeasurementRate rate)
public int red()
Color methods return 16 bit unsigned values.red in interface ColorSensorpublic int green()
ColorSensorgreen in interface ColorSensorpublic int blue()
ColorSensorblue in interface ColorSensorpublic int alpha()
ColorSensoralpha in interface ColorSensorpublic int argb()
ColorSensorargb in interface ColorSensorpublic NormalizedRGBA getNormalizedColors()
NormalizedColorSensorgetNormalizedColors in interface NormalizedColorSensorpublic void enableLed(boolean enable)
ColorSensorenableLed in interface ColorSensorenable - true to enable; false to disablepublic boolean isLightOn()
Lightpublic I2cAddr getI2cAddress()
ColorSensorgetI2cAddress in interface ColorSensorgetI2cAddress in interface I2cAddressableDevicepublic void setI2cAddress(I2cAddr i2cAddr)
ColorSensorsetI2cAddress in interface ColorSensorsetI2cAddress in interface I2cAddrConfigi2cAddr - the new I2C address to usepublic java.lang.String getDeviceName()
HardwareDevicegetDeviceName in interface HardwareDevicepublic HardwareDevice.Manufacturer getManufacturer()
HardwareDevicegetManufacturer in interface HardwareDeviceprotected int readUnsignedByte(BroadcomColorSensor.Register reg)
protected int readUnsignedShort(BroadcomColorSensor.Register reg, java.nio.ByteOrder byteOrder)
public byte read8(BroadcomColorSensor.Register reg)
BroadcomColorSensorread8 in interface BroadcomColorSensorreg - the location from which to read the datapublic byte[] read(BroadcomColorSensor.Register reg, int cb)
BroadcomColorSensorread in interface BroadcomColorSensorreg - the location from which to read the datacb - the number of bytes to readpublic void write8(BroadcomColorSensor.Register reg, int data)
BroadcomColorSensorwrite8 in interface BroadcomColorSensorreg - the location at which to write the datadata - the data to writepublic void write(BroadcomColorSensor.Register reg, byte[] data)
BroadcomColorSensorwrite in interface BroadcomColorSensorprotected void delay(int ms)