public class HiTechnicNxtColorSensor extends I2cDeviceSynchDevice<I2cDeviceSynch> implements ColorSensor, NormalizedColorSensor, SwitchableLight, I2cAddressableDevice
HiTechnicNxtColorSensor
provides support for the HiTechnic color sensor.Modifier and Type | Class and Description |
---|---|
static class |
HiTechnicNxtColorSensor.Command |
static class |
HiTechnicNxtColorSensor.Register |
HardwareDevice.Manufacturer
Modifier and Type | Field and Description |
---|---|
static I2cAddr |
ADDRESS_I2C |
protected float |
colorNormalizationFactor |
protected boolean |
isLightOn |
deviceClient, deviceClientIsOwned, isInitialized
Constructor and Description |
---|
HiTechnicNxtColorSensor(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 |
getVersion()
Version
|
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(HiTechnicNxtColorSensor.Register reg) |
int |
readColorByte(HiTechnicNxtColorSensor.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(HiTechnicNxtColorSensor.Register reg,
byte value) |
void |
writeCommand(HiTechnicNxtColorSensor.Command command) |
close, disengage, engage, getConnectionInfo, getDeviceClient, initialize, initializeIfNecessary, onModuleStateChange, registerArmingStateCallback, resetDeviceConfigurationForOpMode
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
close, getConnectionInfo, resetDeviceConfigurationForOpMode
public static final I2cAddr ADDRESS_I2C
protected final float colorNormalizationFactor
protected boolean isLightOn
public HiTechnicNxtColorSensor(I2cDeviceSynch deviceClient)
protected boolean doInitialize()
I2cDeviceSynchDevice
doInitialize
in class I2cDeviceSynchDevice<I2cDeviceSynch>
public byte read8(HiTechnicNxtColorSensor.Register reg)
public void write8(HiTechnicNxtColorSensor.Register reg, byte value)
public int readColorByte(HiTechnicNxtColorSensor.Register register)
public void writeCommand(HiTechnicNxtColorSensor.Command command)
public java.lang.String toString()
toString
in class java.lang.Object
public int red()
ColorSensor
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 void enableLight(boolean enable)
SwitchableLight
enableLight
in interface SwitchableLight
enable
- if true, the light turns on; otherwise the light turns offpublic boolean isLightOn()
Light
public void setI2cAddress(I2cAddr newAddress)
ColorSensor
setI2cAddress
in interface ColorSensor
public I2cAddr getI2cAddress()
ColorSensor
getI2cAddress
in interface ColorSensor
getI2cAddress
in interface I2cAddressableDevice
public HardwareDevice.Manufacturer getManufacturer()
HardwareDevice
getManufacturer
in interface HardwareDevice
public java.lang.String getDeviceName()
HardwareDevice
getDeviceName
in interface HardwareDevice
public int getVersion()
HardwareDevice
getVersion
in interface HardwareDevice
getVersion
in class I2cDeviceSynchDevice<I2cDeviceSynch>