|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface DigitalInput
A pin used for digital input.
A digital input pin can be used to read logic-level signals. DigitalInput
instances are obtained by calling IOIO.openDigitalInput(DigitalInput.Spec)
.
The value of the pin is obtained by calling read()
. It is also
possible for the client to block until a certain level is sensed, by using
waitForValue(boolean)
.
The instance is alive since its creation. The first read()
call
block for a few milliseconds until the initial value is updated. If the
connection with the IOIO drops at any point, the instance transitions to a
disconnected state, in which every attempt to use the pin (except
Closeable.close()
) will throw a ConnectionLostException
. Whenever
Closeable.close()
is invoked the instance may no longer be used. Any resources
associated with it are freed and can be reused.
Typical usage:
DigitalInput button = ioio.openDigitalInput(10); // used an external pull-up button.waitForValue(false); // wait for press ... button.close(); // pin 10 can now be used for something else.
Nested Class Summary | |
---|---|
static class |
DigitalInput.Spec
A digital input pin specification, used when opening digital inputs. |
Method Summary | |
---|---|
boolean |
read()
Read the value sensed on the pin. |
void |
waitForValue(boolean value)
Block until a desired logical level is sensed. |
Methods inherited from interface ioio.lib.api.Closeable |
---|
close |
Method Detail |
---|
boolean read() throws java.lang.InterruptedException, ConnectionLostException
java.lang.InterruptedException
- The calling thread has been interrupted.
ConnectionLostException
- The connection with the IOIO has been lost.void waitForValue(boolean value) throws java.lang.InterruptedException, ConnectionLostException
value
- The desired logical level. true for "HIGH", false for "LOW".
java.lang.InterruptedException
- The calling thread has been interrupted.
ConnectionLostException
- The connection with the IOIO has been lost.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |