|
SunSPOT API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.spot.sensorboard.io.ScalarInput com.sun.spot.sensorboard.peripheral.LightSensor
public class LightSensor
Simple extension of ScalarInput.
Field Summary |
---|
Fields inherited from class com.sun.spot.sensorboard.io.ScalarInput |
---|
index, myController, range |
Constructor Summary | |
---|---|
LightSensor(PinDescriptor pidx,
int r,
IADCController cntrl)
Creates a new instance of LightSensor |
Method Summary | |
---|---|
void |
addILightSensorThresholdListener(ILightSensorThresholdListener who)
Adds the specified light sensor threshold listener to receive callbacks from this light sensor. |
int |
getAverageValue()
Take 17 readings, one every 1 msec and average them. |
int |
getAverageValue(int n)
To deal with light sources that change rapidly over time, such as fluorescent light bulbs, it is necessary to take multiple readings and average them. |
ILightSensorThresholdListener[] |
getILightSensorThresholdListeners()
Returns an array of all the light sensor threshold listeners registered on this light sensor. |
void |
removeILightSensorThresholdListener(ILightSensorThresholdListener who)
Removes the specified light sensor threshold listener so that it no longer receives callbacks from this light sensor. |
void |
thresholdChanged(int low,
int high)
Called by pin's IADCController when pin threshold values are exceeded. |
void |
thresholdExceeded(int val)
Callback from EDemoBoard interrupt handler for threshold event. |
Methods inherited from class com.sun.spot.sensorboard.io.ScalarInput |
---|
addIScalarInputThresholdListener, areThresholdEventsEnabled, enableThresholdEvents, getHighThreshold, getIndex, getIScalarInputThresholdListeners, getLowThreshold, getRange, getValue, getVoltage, removeIScalarInputThresholdListener, setThresholds, supportsThresholdEvents |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.sun.spot.sensorboard.io.IScalarInput |
---|
addIScalarInputThresholdListener, areThresholdEventsEnabled, enableThresholdEvents, getHighThreshold, getIndex, getIScalarInputThresholdListeners, getLowThreshold, getRange, getValue, removeIScalarInputThresholdListener, setThresholds, supportsThresholdEvents |
Constructor Detail |
---|
public LightSensor(PinDescriptor pidx, int r, IADCController cntrl)
pidx
- PinDescriptor that the lightsensor is connected tor
- Range of the mask for the above pincntrl
- the ADC controller to useMethod Detail |
---|
public int getAverageValue(int n) throws IOException
getAverageValue
in interface ILightSensor
n
- the number of readings to take.
IOException
public int getAverageValue() throws IOException
getAverageValue
in interface ILightSensor
IOException
public void addILightSensorThresholdListener(ILightSensorThresholdListener who)
addILightSensorThresholdListener
in interface ILightSensor
who
- the light sensor threshold listener to add.public void removeILightSensorThresholdListener(ILightSensorThresholdListener who)
removeILightSensorThresholdListener
in interface ILightSensor
who
- the light sensor threshold listener to remove.public ILightSensorThresholdListener[] getILightSensorThresholdListeners()
getILightSensorThresholdListeners
in interface ILightSensor
public void thresholdChanged(int low, int high)
thresholdChanged
in class ScalarInput
low
- the new low threshold value.high
- the new high threshold value.public void thresholdExceeded(int val)
thresholdExceeded
in class ScalarInput
val
- light sensor value taken after event triggered
|
SunSPOT API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |