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.Register
HardwareDevice.Manufacturer
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
TAG |
parameters
deviceClient, deviceClientIsOwned, isInitialized
BROADCOM_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, initialize
close, disengage, engage, getConnectionInfo, getDeviceClient, getVersion, initialize, initializeIfNecessary, onModuleStateChange, registerArmingStateCallback, resetDeviceConfigurationForOpMode
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getParameters, initialize
close, getConnectionInfo, getVersion, resetDeviceConfigurationForOpMode
public static final java.lang.String TAG
protected BroadcomColorSensorImpl(BroadcomColorSensor.Parameters params, I2cDeviceSynchSimple deviceClient, boolean isOwned)
protected boolean internalInitialize(BroadcomColorSensor.Parameters parameters)
I2cDeviceSynchDeviceWithParameters
I2cDeviceSynchDeviceWithParameters.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()
BroadcomColorSensor
getDeviceID
in interface BroadcomColorSensor
protected 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 ColorSensor
public int green()
ColorSensor
green
in interface ColorSensor
public int blue()
ColorSensor
blue
in interface ColorSensor
public int alpha()
ColorSensor
alpha
in interface ColorSensor
public int argb()
ColorSensor
argb
in interface ColorSensor
public NormalizedRGBA getNormalizedColors()
NormalizedColorSensor
getNormalizedColors
in interface NormalizedColorSensor
public void enableLed(boolean enable)
ColorSensor
enableLed
in interface ColorSensor
enable
- true to enable; false to disablepublic boolean isLightOn()
Light
public I2cAddr getI2cAddress()
ColorSensor
getI2cAddress
in interface ColorSensor
getI2cAddress
in interface I2cAddressableDevice
public void setI2cAddress(I2cAddr i2cAddr)
ColorSensor
setI2cAddress
in interface ColorSensor
setI2cAddress
in interface I2cAddrConfig
i2cAddr
- the new I2C address to usepublic java.lang.String getDeviceName()
HardwareDevice
getDeviceName
in interface HardwareDevice
public HardwareDevice.Manufacturer getManufacturer()
HardwareDevice
getManufacturer
in interface HardwareDevice
protected int readUnsignedByte(BroadcomColorSensor.Register reg)
protected int readUnsignedShort(BroadcomColorSensor.Register reg, java.nio.ByteOrder byteOrder)
public byte read8(BroadcomColorSensor.Register reg)
BroadcomColorSensor
read8
in interface BroadcomColorSensor
reg
- the location from which to read the datapublic byte[] read(BroadcomColorSensor.Register reg, int cb)
BroadcomColorSensor
read
in interface BroadcomColorSensor
reg
- the location from which to read the datacb
- the number of bytes to readpublic void write8(BroadcomColorSensor.Register reg, int data)
BroadcomColorSensor
write8
in interface BroadcomColorSensor
reg
- the location at which to write the datadata
- the data to writepublic void write(BroadcomColorSensor.Register reg, byte[] data)
BroadcomColorSensor
write
in interface BroadcomColorSensor
protected void delay(int ms)