SunSPOT API V3.0


com.sun.spot.sensorboard.io
Class BinaryScalar

java.lang.Object
  extended by com.sun.spot.sensorboard.io.BinaryScalar
All Implemented Interfaces:
IInputPin, IScalarInputThresholdListener

public class BinaryScalar
extends Object
implements IInputPin, IScalarInputThresholdListener

Class to allow using a ScalarInput as though it is an GPIO InputPin.

Author:
arshan

Constructor Summary
BinaryScalar(IScalarInput pin)
          Constructor.
 
Method Summary
 void addIInputPinListener(IInputPinListener who)
          Adds the specified input pin listener to receive callbacks from this input pin.
 IInputPinListener[] getIInputPinListeners()
          Returns an array of all the input pin listeners registered on this input pin.
 PinDescriptor getIndex()
          Return the PinDescriptor associated with this input pin.
 int getRange()
           
 int getValue()
           
 boolean isHigh()
          Return true if the input bit is high.
 boolean isLow()
          Return true if the input bit is low.
 void removeIInputPinListener(IInputPinListener who)
          Removes the specified input pin listener so that it no longer receives callbacks from this input pin.
 void thresholdChanged(IScalarInput in, int low, int high)
          Callback for when the scalar input thresholds are changed.
 void thresholdExceeded(IScalarInput in, int val)
          Callback for when the scalar input value goes above or below the specified thresholds.
 void waitForChange()
          Either polls or blocks until interrupt from a-to-d.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryScalar

public BinaryScalar(IScalarInput pin)
Constructor. The threshold for low/high is range/2.

Parameters:
pin - ScalarInput Pin to use
Method Detail

getValue

public int getValue()
             throws IOException
Throws:
IOException

getRange

public int getRange()
             throws IOException
Throws:
IOException

isLow

public boolean isLow()
Description copied from interface: IInputPin
Return true if the input bit is low.

Specified by:
isLow in interface IInputPin
Returns:
true if the input bit is low.

isHigh

public boolean isHigh()
Description copied from interface: IInputPin
Return true if the input bit is high.

Specified by:
isHigh in interface IInputPin
Returns:
true if the input bit is high.

waitForChange

public void waitForChange()
Either polls or blocks until interrupt from a-to-d.

Specified by:
waitForChange in interface IInputPin

getIndex

public PinDescriptor getIndex()
Description copied from interface: IInputPin
Return the PinDescriptor associated with this input pin.

Specified by:
getIndex in interface IInputPin
Returns:
the PinDescriptor associated with this input pin.

addIInputPinListener

public void addIInputPinListener(IInputPinListener who)
Adds the specified input pin listener to receive callbacks from this input pin.

Specified by:
addIInputPinListener in interface IInputPin
Parameters:
who - the input pin listener to add.

removeIInputPinListener

public void removeIInputPinListener(IInputPinListener who)
Removes the specified input pin listener so that it no longer receives callbacks from this input pin. 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 pin.

Specified by:
removeIInputPinListener in interface IInputPin
Parameters:
who - the input pin listener to remove.

getIInputPinListeners

public IInputPinListener[] getIInputPinListeners()
Returns an array of all the input pin listeners registered on this input pin.

Specified by:
getIInputPinListeners in interface IInputPin
Returns:
all of this input pin's listeners or an empty array if no input pin listeners are currently registered.

thresholdExceeded

public void thresholdExceeded(IScalarInput in,
                              int val)
Callback for when the scalar input value goes above or below the specified thresholds.

Specified by:
thresholdExceeded in interface IScalarInputThresholdListener
Parameters:
in - the IScalarInput that has crossed a threshold.
val - the current scalar input reading.

thresholdChanged

public void thresholdChanged(IScalarInput in,
                             int low,
                             int high)
Callback for when the scalar input thresholds are changed.

Specified by:
thresholdChanged in interface IScalarInputThresholdListener
Parameters:
in - the IScalarInput that had its threshold values changed.
low - the new scalar input low threshold value.
high - the new scalar input high threshold value.

SunSPOT API V3.0


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