SunSPOT API V5.0


com.sun.spot.sensorboard.io
Class IOPin

java.lang.Object
  extended by com.sun.spot.sensorboard.io.IOPin
All Implemented Interfaces:
IInputPin, IIOPin, IOutputPin

public class IOPin
extends Object
implements IIOPin


Constructor Summary
IOPin(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 iopin.
 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.
 boolean getState()
          Return the current state of this (output) 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.
 boolean isOutput()
          Ask if this pin is an output.
 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 setAsOutput(boolean b)
          Set whether the pin should be an input or an output.
 void setHigh()
          Sets pin output high
 void setHigh(boolean high)
          Sets pin output.
 void setLow()
          Sets pin output low
 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

IOPin

public IOPin(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

setHigh

public void setHigh()
Description copied from interface: IOutputPin
Sets pin output high

Specified by:
setHigh in interface IOutputPin

setLow

public void setLow()
Description copied from interface: IOutputPin
Sets pin output low

Specified by:
setLow in interface IOutputPin

setHigh

public void setHigh(boolean high)
Description copied from interface: IOutputPin
Sets pin output.

Specified by:
setHigh in interface IOutputPin
Parameters:
high - boolean. If true, output is set high, otherwise output is set low.

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.

getState

public boolean getState()
Return the current state of this (output) pin.

Specified by:
getState in interface IOutputPin
Returns:
current state of this pin

waitForChange

public void waitForChange()
Description copied from interface: IInputPin
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

isOutput

public boolean isOutput()
Description copied from interface: IIOPin
Ask if this pin is an output. Pins are initially inputs. Note that it is possible to query the current pin setting of an output pin using isHigh() and isLow().

Specified by:
isOutput in interface IIOPin
Returns:
true if this pin is currently set to be an output

setAsOutput

public void setAsOutput(boolean b)
Description copied from interface: IIOPin
Set whether the pin should be an input or an output.

Specified by:
setAsOutput in interface IIOPin
Parameters:
b - if b is true the pin becomes an output, if false it becomes an input

getIndex

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

Specified by:
getIndex in interface IInputPin
Specified by:
getIndex in interface IOutputPin
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.

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 iopin.

Overrides:
equals in class Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this iopin 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.