SunSPOT API V2.0


com.sun.spot.sensorboard.peripheral
Class Switch

java.lang.Object
  extended by com.sun.spot.sensorboard.peripheral.Switch
All Implemented Interfaces:
ISwitch

public class Switch
extends Object
implements ISwitch

Class implementing simple switches, assuming a mapping of open=LOW, closed=HIGH. If the sense of the switch is reversed compose an InvertingSingleBitInput onto the pin input.

Author:
Syntropy

Constructor Summary
Switch(IInputPin input)
          Constructor.
 
Method Summary
 boolean isClosed()
          Answer true if the switch IS pressed
 boolean isOpen()
          Answer true if the switch is NOT pressed
 void waitForChange()
          Block the current thread until the switch's state changes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Switch

public Switch(IInputPin input)
Constructor. Stores the single-bit input to be used.

Parameters:
input - the single-bit input to be used
Method Detail

isOpen

public boolean isOpen()
Description copied from interface: ISwitch
Answer true if the switch is NOT pressed

Specified by:
isOpen in interface ISwitch
Returns:
true if the input is low, i.e. the switch is open

isClosed

public boolean isClosed()
Description copied from interface: ISwitch
Answer true if the switch IS pressed

Specified by:
isClosed in interface ISwitch
Returns:
true if the input is high, i.e. the switch is closed

waitForChange

public void waitForChange()
Description copied from interface: ISwitch
Block the current thread until the switch's state changes. Note that this function may use a polling implementation that prevents deep sleep. To avoid this, use EDemoBoard.waitForPinChange().

Specified by:
waitForChange in interface ISwitch
See Also:
ISwitch.waitForChange()

SunSPOT API V2.0


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