public class ModernRoboticsI2cColorSensor extends I2cDeviceSynchDevice<I2cDeviceSynch> implements ColorSensor, NormalizedColorSensor, SwitchableLight, I2cAddrConfig
ModernRoboticsI2cColorSensor provides support for the Modern Robotics Color Sensor.| Modifier and Type | Class and Description |
|---|---|
static class |
ModernRoboticsI2cColorSensor.Command |
static class |
ModernRoboticsI2cColorSensor.Register |
HardwareDevice.Manufacturer| Modifier and Type | Field and Description |
|---|---|
static I2cAddr |
ADDRESS_I2C_DEFAULT |
protected float |
colorNormalizationFactor
In
NormalizedColorSensor we report the 16-bit sensor-normalized values, not the
8 bit colors reported through ColorSensor. |
protected boolean |
isLightOn |
deviceClient, deviceClientIsOwned, isInitialized| Constructor and Description |
|---|
ModernRoboticsI2cColorSensor(I2cDeviceSynch deviceClient) |
| 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 boolean |
doInitialize()
Actually carries out the initialization of the instance.
|
void |
enableLed(boolean enable)
Enable the LED light
|
void |
enableLight(boolean enable)
Turns the light on or off.
|
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.
|
boolean |
isLightOn()
Answers whether the light is on or off
|
byte |
read8(ModernRoboticsI2cColorSensor.Register reg) |
int |
readUnsignedByte(ModernRoboticsI2cColorSensor.Register register) |
int |
readUnsignedShort(ModernRoboticsI2cColorSensor.Register register) |
int |
red()
Get the Red values detected by the sensor as an int.
|
void |
setI2cAddress(I2cAddr newAddress)
Set the I2C address to a new value.
|
java.lang.String |
toString() |
void |
write8(ModernRoboticsI2cColorSensor.Register reg,
byte value) |
void |
writeCommand(ModernRoboticsI2cColorSensor.Command command) |
close, disengage, engage, getConnectionInfo, getDeviceClient, getVersion, initialize, initializeIfNecessary, onModuleStateChange, registerArmingStateCallback, resetDeviceConfigurationForOpModeclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitclose, getConnectionInfo, getVersion, resetDeviceConfigurationForOpModepublic static final I2cAddr ADDRESS_I2C_DEFAULT
protected final float colorNormalizationFactor
NormalizedColorSensor we report the 16-bit sensor-normalized values, not the
8 bit colors reported through ColorSensor.protected boolean isLightOn
public ModernRoboticsI2cColorSensor(I2cDeviceSynch deviceClient)
protected boolean doInitialize()
I2cDeviceSynchDevicedoInitialize in class I2cDeviceSynchDevice<I2cDeviceSynch>public HardwareDevice.Manufacturer getManufacturer()
HardwareDevicegetManufacturer in interface HardwareDevicepublic java.lang.String getDeviceName()
HardwareDevicegetDeviceName in interface HardwareDevicepublic byte read8(ModernRoboticsI2cColorSensor.Register reg)
public void write8(ModernRoboticsI2cColorSensor.Register reg, byte value)
public int readUnsignedByte(ModernRoboticsI2cColorSensor.Register register)
public int readUnsignedShort(ModernRoboticsI2cColorSensor.Register register)
public void writeCommand(ModernRoboticsI2cColorSensor.Command command)
public java.lang.String toString()
toString in class java.lang.Objectpublic int red()
ColorSensorred 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 void enableLight(boolean enable)
SwitchableLightenableLight in interface SwitchableLightenable - if true, the light turns on; otherwise the light turns offpublic boolean isLightOn()
Lightpublic void setI2cAddress(I2cAddr newAddress)
ColorSensorsetI2cAddress in interface ColorSensorsetI2cAddress in interface I2cAddrConfignewAddress - the new I2C address to usepublic I2cAddr getI2cAddress()
ColorSensorgetI2cAddress in interface ColorSensorgetI2cAddress in interface I2cAddressableDevice