|
SunSPOT API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.spot.sensorboard.peripheral.Switch
public class Switch
Class implementing simple switches, assuming a mapping of open=LOW, closed=HIGH. If the sense of the switch is reversed compose an InvertingInputPin onto the pin input.
Constructor Summary | |
---|---|
Switch(IInputPin input)
Constructor. |
Method Summary | |
---|---|
void |
addISwitchListener(ISwitchListener who)
Adds the specified switch listener to receive callbacks from this switch. |
ISwitchListener[] |
getISwitchListeners()
Returns an array of all the switch listeners registered on this switch. |
boolean |
isClosed()
Return true if the switch IS pressed. |
boolean |
isOpen()
Return true if the switch is NOT pressed |
void |
pinSetHigh(IInputPin pin)
Callback from associated InputPin to when switch released. |
void |
pinSetLow(IInputPin pin)
Callback from associated InputPin to when switch pressed. |
void |
removeISwitchListener(ISwitchListener who)
Removes the specified switch listener so that it no longer receives callbacks from this switch. |
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 |
---|
public Switch(IInputPin input)
input
- the single-bit input to be usedMethod Detail |
---|
public boolean isOpen()
isOpen
in interface ISwitch
public boolean isClosed()
isClosed
in interface ISwitch
public void waitForChange()
waitForChange
in interface ISwitch
public void addISwitchListener(ISwitchListener who)
addISwitchListener
in interface ISwitch
who
- the switch listener to add.public void removeISwitchListener(ISwitchListener who)
removeISwitchListener
in interface ISwitch
who
- the switch listener to remove.public ISwitchListener[] getISwitchListeners()
getISwitchListeners
in interface ISwitch
public void pinSetLow(IInputPin pin)
pinSetLow
in interface IInputPinListener
public void pinSetHigh(IInputPin pin)
pinSetHigh
in interface IInputPinListener
|
SunSPOT API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |