|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface AnalogInput
A pin used for analog input.
An analog input pin can be used to measure voltage. AnalogInput instances are
obtained by calling IOIO.openAnalogInput(int)
.
Floating-point values scaled from 0 to 1 can be obtained by calling
read()
. Absolute voltage levels can be obtained by calling
getVoltage()
.
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:
AnalogInput potentiometer = ioio.openAnalogInput(40); float value = potentiometer.read(); ... potentiometer.close(); // pin 40 can now be used for something else.
IOIO.openAnalogInput(int)
Method Summary | |
---|---|
float |
getReference()
Gets the maximum value against which read() values are scaled. |
float |
getVoltage()
Gets the analog input reading, as an absolute voltage in Volt units. |
float |
read()
Gets the analog input reading, as a scaled real value between 0 and 1. |
Methods inherited from interface ioio.lib.api.Closeable |
---|
close |
Method Detail |
---|
float getVoltage() throws java.lang.InterruptedException, ConnectionLostException
It typically takes a few milliseconds between when the instance is created and until the first value can be read. In this case, the method may block shortly. If this is a problem, the calling thread can be interrupted.
If a scaled value is desired, consider using read()
.
java.lang.InterruptedException
- The calling thread has been interrupted.
ConnectionLostException
- The connection with the IOIO is lost.read()
float getReference()
read()
values are scaled.
float read() throws java.lang.InterruptedException, ConnectionLostException
It typically takes a few milliseconds between when the instance is created and until the first value can be read. In this case, the method may block shortly. If this is a problem, the calling thread can be interrupted.
If an absolute value is desired, consider using getVoltage()
.
java.lang.InterruptedException
- The calling thread has been interrupted.
ConnectionLostException
- The connection with the IOIO is lost.getVoltage()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |