public abstract class AMSColorSensorImpl extends I2cDeviceSynchDeviceWithParameters<I2cDeviceSynchSimple,AMSColorSensor.Parameters> implements AMSColorSensor, I2cAddrConfig, Light
AMSColorSensor.Config, AMSColorSensor.Enable, AMSColorSensor.Gain, AMSColorSensor.LEDDrive, AMSColorSensor.Parameters, AMSColorSensor.Pers, AMSColorSensor.Register, AMSColorSensor.Status, AMSColorSensor.WaitHardwareDevice.Manufacturer| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
TAG |
parametersdeviceClient, deviceClientIsOwned, isInitializedAMS_COLOR_COMMAND_BIT, AMS_COLOR_COMMAND_TYPE_AUTO_INCREMENT, AMS_COLOR_COMMAND_TYPE_REPEATED_BYTE, AMS_COLOR_COMMAND_TYPE_RESERVED, AMS_COLOR_COMMAND_TYPE_SPECIAL, AMS_TCS34725_ADDRESS, AMS_TCS34725_ID, AMS_TMD37821_ADDRESS, AMS_TMD37821_ID, AMS_TMD37823_ID| Modifier | Constructor and Description |
|---|---|
protected |
AMSColorSensorImpl(AMSColorSensor.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 AMS 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(AMSColorSensor.Parameters parameters)
Actually attempts to carry out initialization with the indicated parameter block.
|
protected boolean |
is3782() |
protected boolean |
isConnectedAndEnabled()
Return whether we know we are enabled and still actively able to talk to the device
|
boolean |
isLightOn()
Answers whether the light is on or off
|
protected int |
normalToUnsignedShort(float normal) |
byte[] |
read(AMSColorSensor.Register reg,
int cb)
Low level: read data starting at the indicated register
|
byte |
read8(AMSColorSensor.Register reg)
Low level: read the byte starting at the indicated register
|
protected byte |
readEnable() |
protected byte |
readEnableAfterWrite() |
protected int |
readUnsignedByte(AMSColorSensor.Register reg) |
protected int |
readUnsignedShort(AMSColorSensor.Register reg,
java.nio.ByteOrder byteOrder) |
int |
red()
In this implementation, the
Color methods return 16 bit unsigned values. |
protected void |
setGain(AMSColorSensor.Gain gain) |
void |
setI2cAddress(I2cAddr i2cAddr)
Set the I2C address to a new value.
|
protected void |
setIntegrationTime(int atime) |
protected void |
setPDrive(AMSColorSensor.LEDDrive ledDrive) |
protected void |
setProximityPulseCount(int proximityPulseCount)
From the TMD3782 datasheet:
"When the proximity detection feature is enabled (PEN), the
state machine transitions through the Prox Accum, Prox Wait,
and Prox ADC states.
|
protected boolean |
testBits(byte value,
AMSColorSensor.Enable desired) |
protected boolean |
testBits(byte value,
AMSColorSensor.Enable mask,
AMSColorSensor.Enable desired) |
protected boolean |
testBits(byte value,
byte desired) |
protected boolean |
testBits(byte value,
byte mask,
byte desired) |
protected void |
updateControl(int mask,
int value) |
void |
write(AMSColorSensor.Register reg,
byte[] data)
Low level: write data starting at the indicated register
|
void |
write8(AMSColorSensor.Register reg,
int data)
Low level: write a byte to the indicated register
|
protected void |
writeEnable(int value) |
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 AMSColorSensorImpl(AMSColorSensor.Parameters params, I2cDeviceSynchSimple deviceClient, boolean isOwned)
protected boolean internalInitialize(AMSColorSensor.Parameters parameters)
I2cDeviceSynchDeviceWithParametersI2cDeviceSynchDeviceWithParameters.parameters
member variable.internalInitialize in class I2cDeviceSynchDeviceWithParameters<I2cDeviceSynchSimple,AMSColorSensor.Parameters>parameters - the parameter block with which to initializeprotected void dumpState()
protected void enable()
protected void disable()
protected boolean isConnectedAndEnabled()
protected boolean testBits(byte value,
byte desired)
protected boolean testBits(byte value,
byte mask,
byte desired)
protected boolean testBits(byte value,
AMSColorSensor.Enable desired)
protected boolean testBits(byte value,
AMSColorSensor.Enable mask,
AMSColorSensor.Enable desired)
protected void writeEnable(int value)
protected byte readEnable()
protected byte readEnableAfterWrite()
protected void setIntegrationTime(int atime)
protected void setProximityPulseCount(int proximityPulseCount)
protected boolean is3782()
protected void setGain(AMSColorSensor.Gain gain)
protected void setPDrive(AMSColorSensor.LEDDrive ledDrive)
protected void updateControl(int mask,
int value)
public byte getDeviceID()
AMSColorSensorgetDeviceID in interface AMSColorSensorpublic 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 ColorSensorprotected int normalToUnsignedShort(float normal)
public 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(AMSColorSensor.Register reg)
protected int readUnsignedShort(AMSColorSensor.Register reg, java.nio.ByteOrder byteOrder)
public byte read8(AMSColorSensor.Register reg)
AMSColorSensorread8 in interface AMSColorSensorreg - the location from which to read the datapublic byte[] read(AMSColorSensor.Register reg, int cb)
AMSColorSensorread in interface AMSColorSensorreg - the location from which to read the datacb - the number of bytes to readpublic void write8(AMSColorSensor.Register reg, int data)
AMSColorSensorwrite8 in interface AMSColorSensorreg - the location at which to write the datadata - the data to writepublic void write(AMSColorSensor.Register reg, byte[] data)
AMSColorSensorwrite in interface AMSColorSensorprotected void delay(int ms)