SunSPOT API V3.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)
           
 
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.
 boolean getState()
          Return the current state of this (output) pin.
 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)
           
 void setHigh()
          Sets pin output high
 void setHigh(boolean high)
           
 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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IOPin

public IOPin(PinDescriptor idx,
             IGPIOController cntrl)
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)
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)
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.

SunSPOT API V3.0


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