SunSPOT API V3.0


com.sun.spot.sensorboard.peripheral
Interface ILightSensor

All Superinterfaces:
IScalarInput
All Known Implementing Classes:
LightSensor

public interface ILightSensor
extends IScalarInput

Simple extension of a scalar type input.

Author:
arshan & Ron Goldman

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.
 
Methods inherited from interface com.sun.spot.sensorboard.io.IScalarInput
addIScalarInputThresholdListener, areThresholdEventsEnabled, enableThresholdEvents, getHighThreshold, getIndex, getIScalarInputThresholdListeners, getLowThreshold, getRange, getValue, removeIScalarInputThresholdListener, setThresholds, supportsThresholdEvents
 

Method Detail

getAverageValue

int getAverageValue(int n)
                    throws IOException
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. This method sleeps for 1 millisecond between readings. At least one reading is always taken, even if n <= 0.

Parameters:
n - the number of readings to take.
Returns:
the averaged light intensity.
Throws:
IOException

getAverageValue

int getAverageValue()
                    throws IOException
Take 17 readings, one every 1 msec and average them. Equivalent to getAverageValue(17);

Returns:
the averaged light intensity.
Throws:
IOException

addILightSensorThresholdListener

void addILightSensorThresholdListener(ILightSensorThresholdListener who)
Adds the specified light sensor threshold listener to receive callbacks from this light sensor. Callbacks occur when the light sensor reading falls below or equal to the low threshold value, or when it rises above or equal to the high threshold value.

Parameters:
who - the light sensor threshold listener to add.

removeILightSensorThresholdListener

void removeILightSensorThresholdListener(ILightSensorThresholdListener who)
Removes the specified light sensor threshold listener so that it no longer receives callbacks from this light sensor. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this light sensor.

Parameters:
who - the light sensor threshold listener to remove.

getILightSensorThresholdListeners

ILightSensorThresholdListener[] getILightSensorThresholdListeners()
Returns an array of all the light sensor threshold listeners registered on this light sensor.

Returns:
all of this light sensor's ILightSensorThresholdListener or an empty array if no light sensor threshold listeners are currently registered.

SunSPOT API V3.0


Copyright © 2006, 2007 Sun Microsystems, Inc. All Rights Reserved.