SunSPOT API V5.0


com.sun.spot.sensorboard.io
Class InputPin

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

public class InputPin
extends Object
implements IInputPin

Accessor object for input only GPIO pins.


Constructor Summary
InputPin(PinDescriptor idx, IGPIOController cntrl)
          Do not call: for internal use only.
 
Method Summary
 void addIInputPinListener(IInputPinListener who)
          Adds the specified input pin listener to receive callbacks from this input pin.
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" 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 hashCode()
          Returns a hash code value for the object.
 boolean isHigh()
          Return true if the input bit is high.
 boolean isLow()
          Return true if the input bit is low.
 void notifyIInputPinListeners(boolean nowHigh)
          Called by pin's IGPIOController when pin state changes.
 void removeIInputPinListener(IInputPinListener who)
          Removes the specified input pin listener so that it no longer receives callbacks from this input pin.
 void waitForChange()
          Block the current thread until the pin's state changes.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputPin

public InputPin(PinDescriptor idx,
                IGPIOController cntrl)
Do not call: for internal use only. Use EDemoBoard#getIOPins() to get an array of all available bidirectional digital pins: D0-D4.

Method Detail

isLow

public boolean isLow()
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()
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()
Block the current thread until the pin's state changes. (This now uses interrupts and no longer polls.) Note: waitForChange does not inhibit deep sleep.

Specified by:
waitForChange in interface IInputPin

getIndex

public PinDescriptor getIndex()
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. Note: that if pin changes happen too fast some transitions may be missed. At least 3 milliseconds is required between pin changes.

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 noinput input pin listeners are currently registered.

notifyIInputPinListeners

public void notifyIInputPinListeners(boolean nowHigh)
Called by pin's IGPIOController when pin state changes. Spawns threads to notify any registered IInputPinListeners.

Parameters:
nowHigh - true if pin is currently set to high state.

equals

public boolean equals(Object obj)
Indicates whether some other object is "equal to" this input pin.

Overrides:
equals in class Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this input pin is the same as the obj argument; false otherwise.
See Also:
Boolean.hashCode(), Hashtable

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.
See Also:
Object.equals(java.lang.Object), Hashtable

SunSPOT API V5.0


Copyright � 2006-2008 Sun Microsystems, Inc. All Rights Reserved.