SunSPOT API V3.0


com.sun.spot.sensorboard.io
Interface IScalarInput

All Known Subinterfaces:
ILightSensor, ITemperatureInput
All Known Implementing Classes:
LightSensor, ScalarInput, TemperatureInput

public interface IScalarInput

IScalarInput provides access to the values returned by an analogue input device. The value range is from zero to the value returned by getRange()

Author:
Syntropy & Ron Goldman

Method Summary
 void addIScalarInputThresholdListener(IScalarInputThresholdListener who)
          Adds the specified scalar input threshold listener to receive callbacks from this input device.
 boolean areThresholdEventsEnabled()
          Return whether threshold events are enabled or not.
 void enableThresholdEvents(boolean enable)
          Enable or disable threshold events.
 int getHighThreshold()
          Return the current high threshold value.
 PinDescriptor getIndex()
          Return the PinDescriptor associated with this input pin.
 IScalarInputThresholdListener[] getIScalarInputThresholdListeners()
          Returns an array of all the scalar input threshold listeners registered on this input device.
 int getLowThreshold()
          Return the current low threshold value.
 int getRange()
          Return the maximum possible value that could be returned from the input device.
 int getValue()
          Return the current value of the input.
 void removeIScalarInputThresholdListener(IScalarInputThresholdListener who)
          Removes the specified scalar input threshold listener so that it no longer receives callbacks from this input device.
 void setThresholds(int low, int high)
          Set the low and high threshold values for this scalar input.
 boolean supportsThresholdEvents()
          Returns whether the underlying hardware supports threshold events.
 

Method Detail

getIndex

PinDescriptor getIndex()
Return the PinDescriptor associated with this input pin.

Returns:
the PinDescriptor associated with this input pin.

getRange

int getRange()
             throws IOException
Return the maximum possible value that could be returned from the input device.

Returns:
maximum possible value that could be returned from the input device
Throws:
IOException

getValue

int getValue()
             throws IOException
Return the current value of the input.

Returns:
current value of the input
Throws:
IOException

supportsThresholdEvents

boolean supportsThresholdEvents()
Returns whether the underlying hardware supports threshold events.

Returns:
true if threshold events are supported

addIScalarInputThresholdListener

void addIScalarInputThresholdListener(IScalarInputThresholdListener who)
Adds the specified scalar input threshold listener to receive callbacks from this input device. Callbacks occur when the scalar input 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.

removeIScalarInputThresholdListener

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

Parameters:
who - the scalar input threshold listener to remove.

getIScalarInputThresholdListeners

IScalarInputThresholdListener[] getIScalarInputThresholdListeners()
Returns an array of all the scalar input threshold listeners registered on this input device.

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

setThresholds

void setThresholds(int low,
                   int high)
Set the low and high threshold values for this scalar input. Callbacks occur when the scalar input reading falls below or equal to the low threshold value, or when it rises above or equal to the high threshold value. Note: some devices, such as the ADT7411, only compare against the most significant 8-bits.

Parameters:
low - the new low threshold value.
high - the new high threshold value.

getLowThreshold

int getLowThreshold()
Return the current low threshold value.

Returns:
the current low threshold value.

getHighThreshold

int getHighThreshold()
Return the current high threshold value.

Returns:
the current high threshold value.

enableThresholdEvents

void enableThresholdEvents(boolean enable)
Enable or disable threshold events.

Parameters:
enable - if true then listeners will be notified if the scalar input reading goes above the high threshold or below the low threshold.

areThresholdEventsEnabled

boolean areThresholdEventsEnabled()
Return whether threshold events are enabled or not.

Returns:
true if listeners will be notified if the scalar input reading goes above the high threshold or below the low threshold.

SunSPOT API V3.0


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