|
SunSPOT API V6.0 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.spot.resources.Resource
com.sun.spot.sensorboard.peripheral.ADJDS311TriColorLightSensor
public class ADJDS311TriColorLightSensor
Class to implement an RGB light sensor on the demo sensor board and provide access to it via the ITriColorLightSensor interface. Provides methods specific to this particular light sensor.
The Avago ADJD-S311-CR999 RGB Digital Color Sensor measures the light level using a filter-coated photodiode array that converts the incident light into digital Red, Green, Blue & Clear readings. Since all the outputs increase linearly with increasing light intensity, the sensor can measure both color and total intensity of the light.
Note: Before the ADJD-S311/S371 can be used, a one time sensor gain optimization routine must be done so that the digital values ranges from 0 to 1000.
| Field Summary | |
|---|---|
static int |
BLUE
|
static int |
CLEAR
|
static int |
GREEN
|
static int[][] |
MAX_GAINS
|
static int[][] |
MID_GAINS
|
static int[][] |
MIN_GAINS
|
static int |
RED
|
| Constructor Summary | |
|---|---|
ADJDS311TriColorLightSensor()
|
|
| Method Summary | |
|---|---|
void |
addILightSensorThresholdListener(ILightSensorThresholdListener who)
|
void |
addIScalarInputThresholdListener(IScalarInputThresholdListener who)
temporary method for compatibility with deprecated ILightSensor interface. |
boolean |
areThresholdEventsEnabled()
temporary method for compatibility with deprecated ILightSensor interface. |
SensorEvent |
createSensorEvent()
Create a SensorEvent of the appropriate type for this sensor. |
void |
enableThresholdEvents(boolean enable)
temporary method for compatibility with deprecated ILightSensor interface. |
double |
getAccuracy()
Returns the accuracy of the sensor (in the current measurement range) as a percentage of reading (=data value). |
int[] |
getAverageColorValues()
Return the average of 17 readings of the red, green, blue & clear light values. |
int[] |
getAverageColorValues(int n)
Return the average of N readings of the red, green, blue & clear light values. |
int |
getAverageValue()
Return the average of 17 readings of the clear light value. |
int |
getAverageValue(int n)
Return the average of N readings of the clear light value. |
int |
getBlueValue()
Read the current blue light value. |
int |
getClearValue()
Read the current clear light value. |
int[] |
getColorValues()
Read the current red, green, blue & clear light values. |
String |
getCurrentRangeSetting()
Return the current sensor gain settings. |
String |
getDescription()
This method returns a readable description of the sensor. |
int[][] |
getGains()
Return the current gain values. |
int |
getGreenValue()
Read the current green light value. |
int |
getHighThreshold()
temporary method for compatibility with deprecated ILightSensor interface. |
ILightSensorThresholdListener[] |
getILightSensorThresholdListeners()
|
PinDescriptor |
getIndex()
temporary method for compatibility with deprecated ILightSensor interface. |
IScalarInputThresholdListener[] |
getIScalarInputThresholdListeners()
temporary method for compatibility with deprecated ILightSensor interface. |
int |
getLowThreshold()
temporary method for compatibility with deprecated ILightSensor interface. |
double |
getMaxSamplingRate()
Return the maximum sampling rate per second for this sensor. |
double |
getMaxValue()
Returns the current maximum value of the sensor (in the current measurement range). |
double |
getMinValue()
Returns the current minimum value of the sensor (in the current measurement range). |
int[] |
getOffsetValues()
Set the current trim offsets based on current light reading and return them. |
int |
getRange()
temporary method for compatibility with deprecated ILightSensor interface. |
int |
getRedValue()
Read the current red light value. |
double |
getResolution()
Returns the resolution of the range (in the current measurement range). |
int |
getValue()
Return the current light sensor reading. |
boolean |
isInStandbyMode()
Check if the light sensor is in standby mode. |
int[][] |
readGains()
Read the current gain settings from the sensor. |
void |
removeILightSensorThresholdListener(ILightSensorThresholdListener who)
|
void |
removeIScalarInputThresholdListener(IScalarInputThresholdListener who)
temporary method for compatibility with deprecated ILightSensor interface. |
void |
saveEventState(SensorEvent evt)
Save the current sensor state in the specified event. |
void |
setCurrentRangeSetting(String range)
Sets the measurement range setting of the sensor. |
void |
setGains(int[][] gains)
Set the light sensor sensitivity: number of capacitors & integration time for each channel: red, green, blue & clear. |
void |
setStandbyMode(boolean sleep)
Put the light sensor into standby mode to save power. |
void |
setThresholds(int low,
int high)
temporary method for compatibility with deprecated ILightSensor interface. |
void |
setTrimOffsetMode(boolean enable)
Specify if sensor should apply trim offsets to values returned when reading the Red/Green/Blue/Clear light values. |
void |
simpleAdjustGains()
Use a simple method to adjust the gain settings to the maximum sensitivity for the current clear light level. |
boolean |
supportsThresholdEvents()
temporary method for compatibility with deprecated ILightSensor interface. |
| Methods inherited from class com.sun.spot.resources.Resource |
|---|
addTag, getTags, getTagValue, hasTag, removeTag |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.sun.spot.resources.IResource |
|---|
addTag, getTags, getTagValue, hasTag, removeTag |
| Methods inherited from interface com.sun.spot.resources.IResource |
|---|
addTag, getTags, getTagValue, hasTag, removeTag |
| Methods inherited from interface com.sun.spot.resources.IResource |
|---|
addTag, getTags, getTagValue, hasTag, removeTag |
| Field Detail |
|---|
public static final int RED
public static final int GREEN
public static final int BLUE
public static final int CLEAR
public static final int[][] MAX_GAINS
public static final int[][] MID_GAINS
public static final int[][] MIN_GAINS
| Constructor Detail |
|---|
public ADJDS311TriColorLightSensor()
| Method Detail |
|---|
public void setGains(int[][] gains)
throws IOException
gains - a 2-dimensional array [2][4] with values:
{ { num_cap_Red, num_cap_Green, num_cap_Blue, num_cap_Clear }
{ int_time_Red, int_time_Green, int_time_Blue, int_time_Clear } }
IOExceptionpublic int[][] getGains()
public int[][] readGains()
throws IOException
IOException
public void setTrimOffsetMode(boolean enable)
throws IOException
enable - if true then apply offsets to future RGBC reads
IOException
public int[] getOffsetValues()
throws IOException
IOException
public void simpleAdjustGains()
throws IOException
Generally takes from 1-10 seconds to find a good gains setting.
Note if trim offsets were in use, calling simpleAdjustGains will disable them.
IOException
public int getClearValue()
throws IOException
getClearValue in interface ITriColorLightSensorIOException
public int getRedValue()
throws IOException
getRedValue in interface ITriColorLightSensorIOException
public int getGreenValue()
throws IOException
getGreenValue in interface ITriColorLightSensorIOException
public int getBlueValue()
throws IOException
getBlueValue in interface ITriColorLightSensorIOException
public int[] getColorValues()
throws IOException
getColorValues in interface ITriColorLightSensorIOException
public int[] getAverageColorValues(int n)
throws IOException
getAverageColorValues in interface ITriColorLightSensorn - the number of readings to take and average
IOException
public int[] getAverageColorValues()
throws IOException
getAverageColorValues in interface ITriColorLightSensorIOException
public int getAverageValue(int n)
throws IOException
getAverageValue in interface ILightSensorn - the number of readings to take and average
IOException
public int getAverageValue()
throws IOException
getAverageValue in interface ILightSensorIOExceptionpublic void addILightSensorThresholdListener(ILightSensorThresholdListener who)
public void removeILightSensorThresholdListener(ILightSensorThresholdListener who)
public ILightSensorThresholdListener[] getILightSensorThresholdListeners()
public int getValue()
throws IOException
ILightSensor
getValue in interface ILightSensorgetValue in interface IScalarInputIOExceptionpublic String getDescription()
ITransducer
getDescription in interface ITransducerpublic double getMaxSamplingRate()
ITransducer
getMaxSamplingRate in interface ITransducerpublic SensorEvent createSensorEvent()
ITransducer
createSensorEvent in interface ITransducerpublic void saveEventState(SensorEvent evt)
ITransducer
saveEventState in interface ITransducerevt - the event to store the sensor state inpublic PinDescriptor getIndex()
getIndex in interface IScalarInputpublic int getRange()
getRange in interface IScalarInputpublic boolean supportsThresholdEvents()
supportsThresholdEvents in interface IScalarInputpublic void addIScalarInputThresholdListener(IScalarInputThresholdListener who)
addIScalarInputThresholdListener in interface IScalarInputwho - the light sensor threshold listener to add.
IllegalStateException - since TriColorLightSensor does not support threshold eventspublic void removeIScalarInputThresholdListener(IScalarInputThresholdListener who)
removeIScalarInputThresholdListener in interface IScalarInputwho - the scalar input threshold listener to remove.
IllegalStateException - since TriColorLightSensor does not support threshold eventspublic IScalarInputThresholdListener[] getIScalarInputThresholdListeners()
getIScalarInputThresholdListeners in interface IScalarInputIllegalStateException - since TriColorLightSensor does not support threshold events
public void setThresholds(int low,
int high)
setThresholds in interface IScalarInputlow - the new low threshold value.high - the new high threshold value.
IllegalStateException - since TriColorLightSensor does not support threshold eventspublic int getLowThreshold()
getLowThreshold in interface IScalarInputIllegalStateException - since TriColorLightSensor does not support threshold eventspublic int getHighThreshold()
getHighThreshold in interface IScalarInputIllegalStateException - since TriColorLightSensor does not support threshold eventspublic void enableThresholdEvents(boolean enable)
enableThresholdEvents in interface IScalarInputenable - if true then listeners will be notified if the scalar input
reading goes above the high threshold or below the low threshold.
IllegalStateException - since TriColorLightSensor does not support threshold eventspublic boolean areThresholdEventsEnabled()
areThresholdEventsEnabled in interface IScalarInputpublic double getMinValue()
getMinValue in interface IMeasurementInfopublic double getMaxValue()
getMaxValue in interface IMeasurementInfopublic double getResolution()
getResolution in interface IMeasurementInfopublic double getAccuracy()
getAccuracy in interface IMeasurementInfopublic String getCurrentRangeSetting()
getCurrentRangeSetting in interface IMeasurementRangeVariablepublic void setCurrentRangeSetting(String range)
setCurrentRangeSetting in interface IMeasurementRangeVariablerange - the measurement range setting to be set as a String.
IllegalArgumentException - - if the given range is not
a valid range for the sensor.public void setStandbyMode(boolean sleep)
setStandbyMode in interface IStandbysleep - if true then put light sensor into standby modepublic boolean isInStandbyMode()
isInStandbyMode in interface IStandby
|
SunSPOT API V6.0 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||