ioio.lib.impl
Class IOIOImpl

java.lang.Object
  extended by ioio.lib.impl.IOIOImpl
All Implemented Interfaces:
IOIO

public class IOIOImpl
extends java.lang.Object
implements IOIO


Nested Class Summary
 
Nested classes/interfaces inherited from interface ioio.lib.api.IOIO
IOIO.VersionType
 
Field Summary
 
Fields inherited from interface ioio.lib.api.IOIO
INVALID_PIN, LED_PIN
 
Constructor Summary
IOIOImpl(IOIOConnection con)
           
 
Method Summary
 void disconnect()
          Closes the connection to the board, or aborts a connection process started with waitForConnect().
 void disconnected()
           
 java.lang.String getImplVersion(IOIO.VersionType v)
          Query the implementation version of the system's components.
 void hardReset()
          Equivalent to disconnecting and reconnecting the board power supply.
 AnalogInput openAnalogInput(int pin)
          Open a pin for analog input.
 DigitalInput openDigitalInput(DigitalInput.Spec spec)
          Open a pin for digital input.
 DigitalInput openDigitalInput(int pin)
          Shorthand for openDigitalInput(new DigitalInput.Spec(pin)).
 DigitalInput openDigitalInput(int pin, DigitalInput.Spec.Mode mode)
          Shorthand for openDigitalInput(new DigitalInput.Spec(pin, mode)).
 DigitalOutput openDigitalOutput(DigitalOutput.Spec spec, boolean startValue)
          Open a pin for digital output.
 DigitalOutput openDigitalOutput(int pin)
          Shorthand for openDigitalOutput(new DigitalOutput.Spec(pin), false).
 DigitalOutput openDigitalOutput(int pin, boolean startValue)
          Shorthand for openDigitalOutput(new DigitalOutput.Spec(pin), startValue).
 DigitalOutput openDigitalOutput(int pin, DigitalOutput.Spec.Mode mode, boolean startValue)
          Shorthand for openDigitalOutput(new DigitalOutput.Spec(pin, mode), startValue).
 IcspMaster openIcspMaster()
          Open an ICSP channel, enabling Flash programming of an external PIC MCU, and in particular, another IOIO board.
 PulseInput openPulseInput(DigitalInput.Spec spec, PulseInput.ClockRate rate, PulseInput.PulseMode mode, boolean doublePrecision)
          Open a pin for pulse input.
 PulseInput openPulseInput(int pin, PulseInput.PulseMode mode)
          Shorthand for openPulseInput(new DigitalInput.Spec(pin), rate, mode, true), i.e.
 PwmOutput openPwmOutput(DigitalOutput.Spec spec, int freqHz)
          Open a pin for PWM (Pulse-Width Modulation) output.
 PwmOutput openPwmOutput(int pin, int freqHz)
          Shorthand for openPwmOutput(new DigitalOutput.Spec(pin), freqHz).
 SpiMaster openSpiMaster(DigitalInput.Spec miso, DigitalOutput.Spec mosi, DigitalOutput.Spec clk, DigitalOutput.Spec[] slaveSelect, SpiMaster.Config config)
          Open a SPI master module, enabling communication with multiple SPI-enabled slave modules.
 SpiMaster openSpiMaster(int miso, int mosi, int clk, int[] slaveSelect, SpiMaster.Rate rate)
          Shorthand for {@link #openSpiMaster(ioio.lib.api.DigitalInput.Spec, ioio.lib.api.DigitalOutput.Spec, ioio.lib.api.DigitalOutput.Spec, ioio.lib.api.DigitalOutput.Spec[], ioio.lib.api.SpiMaster.Config), where the pins are all open with the default modes and default configuration values are used.
 SpiMaster openSpiMaster(int miso, int mosi, int clk, int slaveSelect, SpiMaster.Rate rate)
          Shorthand for {@link #openSpiMaster(ioio.lib.api.DigitalInput.Spec, ioio.lib.api.DigitalOutput.Spec, ioio.lib.api.DigitalOutput.Spec, ioio.lib.api.DigitalOutput.Spec[], ioio.lib.api.SpiMaster.Config), where the MISO pins is opened with pull up, and the other pins are open with the default modes and default configuration values are used.
 TwiMaster openTwiMaster(int twiNum, TwiMaster.Rate rate, boolean smbus)
          Open a TWI (Two-Wire Interface, such as I2C/SMBus) master module, enabling communication with multiple TWI-enabled slave modules.
 Uart openUart(DigitalInput.Spec rx, DigitalOutput.Spec tx, int baud, Uart.Parity parity, Uart.StopBits stopbits)
          Open a UART module, enabling a bulk transfer of byte buffers.
 Uart openUart(int rx, int tx, int baud, Uart.Parity parity, Uart.StopBits stopbits)
          Shorthand for #openUart(ioio.lib.api.DigitalInput.Spec, ioio.lib.api.DigitalOutput.Spec, int, Parity, StopBits) , where the input pins use their default specs.
 void softReset()
          Resets the entire state (returning to initial state), without dropping the connection.
 void waitForConnect()
          Establishes connection with the IOIO board.
 void waitForDisconnect()
          Blocks until IOIO has been disconnected and all connection-related resources have been freed, so that a new connection can be attempted.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IOIOImpl

public IOIOImpl(IOIOConnection con)
Method Detail

waitForConnect

public void waitForConnect()
                    throws ConnectionLostException,
                           IncompatibilityException
Description copied from interface: IOIO
Establishes connection with the IOIO board.

This method is blocking until connection is established. This method can be aborted by calling IOIO.disconnect(). In this case, it will throw a ConnectionLostException.

Specified by:
waitForConnect in interface IOIO
Throws:
ConnectionLostException - An error occurred during connection or disconnect() has been called during connection. The instance state is disconnected.
IncompatibilityException - An incompatible board firmware of hardware has been detected. The instance state is disconnected.
See Also:
IOIO.disconnect(), IOIO.waitForDisconnect()

disconnect

public void disconnect()
Description copied from interface: IOIO
Closes the connection to the board, or aborts a connection process started with waitForConnect().

Once this method is called, this IOIO instance and all the instances obtain from it become invalid and will throw an exception on every operation.

This method is asynchronous, i.e. it returns immediately, but it is not guaranteed that all connection-related resources has already been freed and can be reused upon return. In cases when this is important, client can call IOIO.waitForDisconnect(), which will block until all resources have been freed.

Specified by:
disconnect in interface IOIO

disconnected

public void disconnected()

waitForDisconnect

public void waitForDisconnect()
                       throws java.lang.InterruptedException
Description copied from interface: IOIO
Blocks until IOIO has been disconnected and all connection-related resources have been freed, so that a new connection can be attempted.

Specified by:
waitForDisconnect in interface IOIO
Throws:
java.lang.InterruptedException - When interrupt() has been called on this thread. This might mean that an immediate attempt to create and connect a new IOIO object might fail for resource contention.
See Also:
IOIO.disconnect(), IOIO.waitForConnect()

softReset

public void softReset()
               throws ConnectionLostException
Description copied from interface: IOIO
Resets the entire state (returning to initial state), without dropping the connection.

It is equivalent to calling Closeable.close() on every interface obtained from this instance. A connection must have been established prior to calling this method, by invoking IOIO.waitForConnect().

Specified by:
softReset in interface IOIO
Throws:
ConnectionLostException - Connection was lost before or during the execution of this method.
See Also:
IOIO.hardReset()

hardReset

public void hardReset()
               throws ConnectionLostException
Description copied from interface: IOIO
Equivalent to disconnecting and reconnecting the board power supply.

The connection will be dropped and not reestablished. Full boot sequence will take place, so firmware upgrades can be performed. A connection must have been established prior to calling this method, by invoking IOIO.waitForConnect().

Specified by:
hardReset in interface IOIO
Throws:
ConnectionLostException - Connection was lost before or during the execution of this method.
See Also:
IOIO.softReset()

getImplVersion

public java.lang.String getImplVersion(IOIO.VersionType v)
                                throws ConnectionLostException
Description copied from interface: IOIO
Query the implementation version of the system's components. The implementation version uniquely identifies a hardware revision or a software build. Returned version IDs are always 8-character long, according to the IOIO versioning system: first 4 characters are the version authority and last 4 characters are the revision.

Specified by:
getImplVersion in interface IOIO
Parameters:
v - The component whose version we query.
Returns:
An 8-character implementation version ID.
Throws:
ConnectionLostException - Connection was lost before or during the execution of this method.

openDigitalInput

public DigitalInput openDigitalInput(int pin)
                              throws ConnectionLostException
Description copied from interface: IOIO
Shorthand for openDigitalInput(new DigitalInput.Spec(pin)).

Specified by:
openDigitalInput in interface IOIO
Throws:
ConnectionLostException
See Also:
IOIO.openDigitalInput(ioio.lib.api.DigitalInput.Spec)

openDigitalInput

public DigitalInput openDigitalInput(int pin,
                                     DigitalInput.Spec.Mode mode)
                              throws ConnectionLostException
Description copied from interface: IOIO
Shorthand for openDigitalInput(new DigitalInput.Spec(pin, mode)).

Specified by:
openDigitalInput in interface IOIO
Throws:
ConnectionLostException
See Also:
IOIO.openDigitalInput(ioio.lib.api.DigitalInput.Spec)

openDigitalInput

public DigitalInput openDigitalInput(DigitalInput.Spec spec)
                              throws ConnectionLostException
Description copied from interface: IOIO
Open a pin for digital input.

A digital input pin can be used to read logic-level signals. The pin will operate in this mode until close() is invoked on the returned interface. It is illegal to open a pin that has already been opened and has not been closed. A connection must have been established prior to calling this method, by invoking IOIO.waitForConnect().

Specified by:
openDigitalInput in interface IOIO
Parameters:
spec - Pin specification, consisting of the pin number, as labeled on the board, and the mode, which determines whether the pin will be floating, pull-up or pull-down. See DigitalInput.Spec.Mode for more information.
Returns:
Interface of the assigned pin.
Throws:
ConnectionLostException - Connection was lost before or during the execution of this method.
See Also:
DigitalInput

openDigitalOutput

public DigitalOutput openDigitalOutput(int pin,
                                       DigitalOutput.Spec.Mode mode,
                                       boolean startValue)
                                throws ConnectionLostException
Description copied from interface: IOIO
Shorthand for openDigitalOutput(new DigitalOutput.Spec(pin, mode), startValue).

Specified by:
openDigitalOutput in interface IOIO
Throws:
ConnectionLostException
See Also:
IOIO.openDigitalOutput(ioio.lib.api.DigitalOutput.Spec, boolean)

openDigitalOutput

public DigitalOutput openDigitalOutput(DigitalOutput.Spec spec,
                                       boolean startValue)
                                throws ConnectionLostException
Description copied from interface: IOIO
Open a pin for digital output.

A digital output pin can be used to generate logic-level signals. The pin will operate in this mode until close() is invoked on the returned interface. It is illegal to open a pin that has already been opened and has not been closed. A connection must have been established prior to calling this method, by invoking IOIO.waitForConnect().

Specified by:
openDigitalOutput in interface IOIO
Parameters:
spec - Pin specification, consisting of the pin number, as labeled on the board, and the mode, which determines whether the pin will be normal or open-drain. See DigitalOutput.Spec.Mode for more information.
startValue - The initial logic level this pin will generate as soon at it is open.
Returns:
Interface of the assigned pin.
Throws:
ConnectionLostException - Connection was lost before or during the execution of this method.
See Also:
DigitalOutput

openDigitalOutput

public DigitalOutput openDigitalOutput(int pin,
                                       boolean startValue)
                                throws ConnectionLostException
Description copied from interface: IOIO
Shorthand for openDigitalOutput(new DigitalOutput.Spec(pin), startValue). Pin mode will be "normal" (as opposed to "open-drain".

Specified by:
openDigitalOutput in interface IOIO
Throws:
ConnectionLostException
See Also:
IOIO.openDigitalOutput(ioio.lib.api.DigitalOutput.Spec, boolean)

openDigitalOutput

public DigitalOutput openDigitalOutput(int pin)
                                throws ConnectionLostException
Description copied from interface: IOIO
Shorthand for openDigitalOutput(new DigitalOutput.Spec(pin), false). Pin mode will be "normal" (as opposed to "open-drain".

Specified by:
openDigitalOutput in interface IOIO
Throws:
ConnectionLostException
See Also:
IOIO.openDigitalOutput(ioio.lib.api.DigitalOutput.Spec, boolean)

openAnalogInput

public AnalogInput openAnalogInput(int pin)
                            throws ConnectionLostException
Description copied from interface: IOIO
Open a pin for analog input.

An analog input pin can be used to measure voltage. Note that not every pin can be used as an analog input. See board documentation for the legal pins and permitted voltage range.

The pin will operate in this mode until close() is invoked on the returned interface. It is illegal to open a pin that has already been opened and has not been closed. A connection must have been established prior to calling this method, by invoking IOIO.waitForConnect().

Specified by:
openAnalogInput in interface IOIO
Parameters:
pin - Pin number, as labeled on the board.
Returns:
Interface of the assigned pin.
Throws:
ConnectionLostException - Connection was lost before or during the execution of this method.
See Also:
AnalogInput

openPwmOutput

public PwmOutput openPwmOutput(int pin,
                               int freqHz)
                        throws ConnectionLostException
Description copied from interface: IOIO
Shorthand for openPwmOutput(new DigitalOutput.Spec(pin), freqHz).

Specified by:
openPwmOutput in interface IOIO
Throws:
ConnectionLostException
See Also:
IOIO.openPwmOutput(ioio.lib.api.DigitalOutput.Spec, int)

openPwmOutput

public PwmOutput openPwmOutput(DigitalOutput.Spec spec,
                               int freqHz)
                        throws ConnectionLostException
Description copied from interface: IOIO
Open a pin for PWM (Pulse-Width Modulation) output.

A PWM pin produces a logic-level PWM signal. These signals are typically used for simulating analog outputs for controlling the intensity of LEDs, the rotation speed of motors, etc. They are also frequently used for controlling hobby servo motors.

Note that not every pin can be used as PWM output. In addition, the total number of concurrent PWM modules in use is limited. See board documentation for the legal pins and limit on concurrent usage.

The pin will operate in this mode until close() is invoked on the returned interface. It is illegal to open a pin that has already been opened and has not been closed. A connection must have been established prior to calling this method, by invoking IOIO.waitForConnect().

Specified by:
openPwmOutput in interface IOIO
Parameters:
spec - Pin specification, consisting of the pin number, as labeled on the board, and the mode, which determines whether the pin will be normal or open-drain. See DigitalOutput.Spec.Mode for more information.
freqHz - PWM frequency, in Hertz.
Returns:
Interface of the assigned pin.
Throws:
ConnectionLostException - Connection was lost before or during the execution of this method.
See Also:
PwmOutput

openUart

public Uart openUart(int rx,
                     int tx,
                     int baud,
                     Uart.Parity parity,
                     Uart.StopBits stopbits)
              throws ConnectionLostException
Description copied from interface: IOIO
Shorthand for #openUart(ioio.lib.api.DigitalInput.Spec, ioio.lib.api.DigitalOutput.Spec, int, Parity, StopBits) , where the input pins use their default specs. IOIO.INVALID_PIN can be used on either pin if a TX- or RX-only UART is needed.

Specified by:
openUart in interface IOIO
Throws:
ConnectionLostException
See Also:
#openUart(ioio.lib.api.DigitalInput.Spec, ioio.lib.api.DigitalOutput.Spec, int, Parity, StopBits)

openUart

public Uart openUart(DigitalInput.Spec rx,
                     DigitalOutput.Spec tx,
                     int baud,
                     Uart.Parity parity,
                     Uart.StopBits stopbits)
              throws ConnectionLostException
Description copied from interface: IOIO
Open a UART module, enabling a bulk transfer of byte buffers.

UART is a very common hardware communication protocol, enabling full- duplex, asynchronous point-to-point data transfer. It typically serves for opening consoles or as a basis for higher-level protocols, such as MIDI RS-232, and RS-485.

Note that not every pin can be used for UART RX or TX. In addition, the total number of concurrent UART modules in use is limited. See board documentation for the legal pins and limit on concurrent usage.

The UART module will operate, and the pins will work in their respective modes until close() is invoked on the returned interface. It is illegal to use pins that have already been opened and has not been closed. A connection must have been established prior to calling this method, by invoking IOIO.waitForConnect().

Specified by:
openUart in interface IOIO
Parameters:
rx - Pin specification for the RX pin, consisting of the pin number, as labeled on the board, and the mode, which determines whether the pin will be floating, pull-up or pull-down. See DigitalInput.Spec.Mode for more information. null can be passed to designate that we do not want RX input to this module.
tx - Pin specification for the TX pin, consisting of the pin number, as labeled on the board, and the mode, which determines whether the pin will be normal or open-drain. See DigitalOutput.Spec.Mode for more information. null can be passed to designate that we do not want TX output to this module.
baud - The clock frequency of the UART module in Hz.
parity - The parity mode, as in Uart.Parity.
stopbits - Number of stop bits, as in Uart.StopBits.
Returns:
Interface of the assigned module.
Throws:
ConnectionLostException - Connection was lost before or during the execution of this method.
See Also:
Uart

openTwiMaster

public TwiMaster openTwiMaster(int twiNum,
                               TwiMaster.Rate rate,
                               boolean smbus)
                        throws ConnectionLostException
Description copied from interface: IOIO
Open a TWI (Two-Wire Interface, such as I2C/SMBus) master module, enabling communication with multiple TWI-enabled slave modules.

TWI is a common hardware communication protocol, enabling half-duplex, synchronous point-to-multi-point data transfer. It requires a physical connection of two lines (SDA, SCL) shared by all the bus nodes, where the SDA is open-drain and externally pulled-up.

Note that there is a fixed number of TWI modules, and the pins they use are static. Client has to make sure these pins are not already opened before calling this method. See board documentation for the number of modules and the respective pins they use.

The TWI module will operate, and the pins will work in their respective modes until close() is invoked on the returned interface. It is illegal to use pins that have already been opened and has not been closed. A connection must have been established prior to calling this method, by invoking IOIO.waitForConnect().

Specified by:
openTwiMaster in interface IOIO
Parameters:
twiNum - The TWI module index to use. Will also determine the pins used.
rate - The clock rate. Can be 100KHz / 400KHz / 1MHz.
smbus - When true, will use SMBus voltage levels. When false, I2C voltage levels.
Returns:
Interface of the assigned module.
Throws:
ConnectionLostException - Connection was lost before or during the execution of this method.
See Also:
TwiMaster

openIcspMaster

public IcspMaster openIcspMaster()
                          throws ConnectionLostException
Description copied from interface: IOIO
Open an ICSP channel, enabling Flash programming of an external PIC MCU, and in particular, another IOIO board.

ICSP (In-Circuit Serial Programming) is a protocol intended for programming of PIC MCUs. It is a serial protocol over three wires: PGC (clock), PGD (data) and MCLR (reset), where PGC and MCLR are controlled by the master and PGD is shared by the master and slave, depending on the transaction state.

Note that there is only one ICSP modules, and the pins it uses are static. Client has to make sure that the ICSP module is not already in use, as well as those dedicated pins. See board documentation for the actual pins used for ICSP.

Specified by:
openIcspMaster in interface IOIO
Returns:
Interface of the ICSP module.
Throws:
ConnectionLostException - Connection was lost before or during the execution of this method.
See Also:
IcspMaster

openSpiMaster

public SpiMaster openSpiMaster(int miso,
                               int mosi,
                               int clk,
                               int slaveSelect,
                               SpiMaster.Rate rate)
                        throws ConnectionLostException
Description copied from interface: IOIO
Shorthand for {@link #openSpiMaster(ioio.lib.api.DigitalInput.Spec, ioio.lib.api.DigitalOutput.Spec, ioio.lib.api.DigitalOutput.Spec, ioio.lib.api.DigitalOutput.Spec[], ioio.lib.api.SpiMaster.Config), where the MISO pins is opened with pull up, and the other pins are open with the default modes and default configuration values are used. In this version, a single slave is used.

Specified by:
openSpiMaster in interface IOIO
Throws:
ConnectionLostException
See Also:
IOIO.openSpiMaster(ioio.lib.api.DigitalInput.Spec, ioio.lib.api.DigitalOutput.Spec, ioio.lib.api.DigitalOutput.Spec, ioio.lib.api.DigitalOutput.Spec[], ioio.lib.api.SpiMaster.Config)

openSpiMaster

public SpiMaster openSpiMaster(int miso,
                               int mosi,
                               int clk,
                               int[] slaveSelect,
                               SpiMaster.Rate rate)
                        throws ConnectionLostException
Description copied from interface: IOIO
Shorthand for {@link #openSpiMaster(ioio.lib.api.DigitalInput.Spec, ioio.lib.api.DigitalOutput.Spec, ioio.lib.api.DigitalOutput.Spec, ioio.lib.api.DigitalOutput.Spec[], ioio.lib.api.SpiMaster.Config), where the pins are all open with the default modes and default configuration values are used.

Specified by:
openSpiMaster in interface IOIO
Throws:
ConnectionLostException
See Also:
IOIO.openSpiMaster(ioio.lib.api.DigitalInput.Spec, ioio.lib.api.DigitalOutput.Spec, ioio.lib.api.DigitalOutput.Spec, ioio.lib.api.DigitalOutput.Spec[], ioio.lib.api.SpiMaster.Config)

openSpiMaster

public SpiMaster openSpiMaster(DigitalInput.Spec miso,
                               DigitalOutput.Spec mosi,
                               DigitalOutput.Spec clk,
                               DigitalOutput.Spec[] slaveSelect,
                               SpiMaster.Config config)
                        throws ConnectionLostException
Description copied from interface: IOIO
Open a SPI master module, enabling communication with multiple SPI-enabled slave modules.

SPI is a common hardware communication protocol, enabling full-duplex, synchronous point-to-multi-point data transfer. It requires MOSI, MISO and CLK lines shared by all nodes, as well as a SS line per slave, connected between this slave and a respective pin on the master. The MISO line should operate in pull-up mode, using either the internal pull-up or an external resistor.

Note that not every pin can be used for SPI MISO, MOSI or CLK. In addition, the total number of concurrent SPI modules in use is limited. See board documentation for the legal pins and limit on concurrent usage.

The SPI module will operate, and the pins will work in their respective modes until close() is invoked on the returned interface. It is illegal to use pins that have already been opened and has not been closed. A connection must have been established prior to calling this method, by invoking IOIO.waitForConnect().

Specified by:
openSpiMaster in interface IOIO
Parameters:
miso - Pin specification for the MISO (Master In Slave Out) pin, consisting of the pin number, as labeled on the board, and the mode, which determines whether the pin will be floating, pull-up or pull-down. See DigitalInput.Spec.Mode for more information.
mosi - Pin specification for the MOSI (Master Out Slave In) pin, consisting of the pin number, as labeled on the board, and the mode, which determines whether the pin will be normal or open-drain. See DigitalOutput.Spec.Mode for more information.
clk - Pin specification for the CLK pin, consisting of the pin number, as labeled on the board, and the mode, which determines whether the pin will be normal or open-drain. See DigitalOutput.Spec.Mode for more information.
slaveSelect - An array of pin specifications for each of the slaves' SS (Slave Select) pin. The index of this array designates the slave index, used later to refer to this slave. The spec is consisting of the pin number, as labeled on the board, and the mode, which determines whether the pin will be normal or open-drain. See DigitalOutput.Spec.Mode for more information.
config - The configuration of the SPI module. See SpiMaster.Config for details.
Returns:
Interface of the assigned module.
Throws:
ConnectionLostException - Connection was lost before or during the execution of this method.
See Also:
SpiMaster

openPulseInput

public PulseInput openPulseInput(DigitalInput.Spec spec,
                                 PulseInput.ClockRate rate,
                                 PulseInput.PulseMode mode,
                                 boolean doublePrecision)
                          throws ConnectionLostException
Description copied from interface: IOIO
Open a pin for pulse input.

The pulse input module is quite flexible. It enables several kinds of timing measurements on a digital signal: pulse width measurement (positive or negative pulse), and frequency of a periodic signal.

Note that not every pin can be used as pulse input. In addition, the total number of concurrent pulse input modules in use is limited. See board documentation for the legal pins and limit on concurrent usage.

The pin will operate in this mode until close() is invoked on the returned interface. It is illegal to open a pin that has already been opened and has not been closed. A connection must have been established prior to calling this method, by invoking IOIO.waitForConnect().

Specified by:
openPulseInput in interface IOIO
Parameters:
spec - Pin specification, consisting of the pin number, as labeled on the board, and the mode, which determines whether the pin will be floating, pull-up or pull-down. See DigitalInput.Spec.Mode for more information.
rate - The clock rate to use for timing the signal. A faster clock rate will result in better precision but will only be able to measure narrow pulses / high frequencies.
mode - The mode in which to operate. Determines whether the module will measure pulse durations or frequency.
doublePrecision - Whether to open a double-precision pulse input module. Double- precision modules enable reading of much longer pulses and lower frequencies with high accuracy than single precision modules. However, their number is limited, so when possible, and if the resources are all needed, use single-precision. For more details on the exact spec of single- vs. double- precision, see PulseInput.
Returns:
An instance of the PulseInput, which can be used to obtain the data.
Throws:
ConnectionLostException - Connection was lost before or during the execution of this method.
See Also:
PulseInput

openPulseInput

public PulseInput openPulseInput(int pin,
                                 PulseInput.PulseMode mode)
                          throws ConnectionLostException
Description copied from interface: IOIO
Shorthand for openPulseInput(new DigitalInput.Spec(pin), rate, mode, true), i.e. opens a double-precision, 16MHz pulse input on the given pin with the given mode.

Specified by:
openPulseInput in interface IOIO
Throws:
ConnectionLostException
See Also:
#openPulseInput(ioio.lib.api.DigitalInput.Spec, ioio.lib.api.PulseInput.ClockRate, PulseMode, boolean))