ioio.lib.util
Interface IOIOLooper

All Known Implementing Classes:
BaseIOIOLooper

public interface IOIOLooper

A handler implementing interaction with a single IOIO over a single connection period. The interface utilizes a basic workflow for working with a IOIO instance: as soon as a connection is established, setup(IOIO) will be called. Then, the loop() method will be called repeatedly as long as the connection is alive. Last, the disconnected() method will be called upon losing the connection (as result of physical disconnection, closing the application, etc). In case a IOIO with an incompatible firmware is encountered, incompatible() will be called instead of setup(IOIO), and the IOIO instance is entirely useless, until eventually disconnected() gets called.


Method Summary
 void disconnected()
          Subclasses should override this method for performing operations to be done once as soon as IOIO communication is lost or closed.
 void incompatible()
          Subclasses should override this method for performing operations to be done if an incompatible IOIO firmware is detected.
 void loop()
          Subclasses should override this method for performing operations to be done repetitively as long as IOIO communication persists.
 void setup(IOIO ioio)
          Subclasses should override this method for performing operations to be done once as soon as IOIO communication is established.
 

Method Detail

setup

void setup(IOIO ioio)
           throws ConnectionLostException,
                  java.lang.InterruptedException
Subclasses should override this method for performing operations to be done once as soon as IOIO communication is established.

Throws:
ConnectionLostException
java.lang.InterruptedException

loop

void loop()
          throws ConnectionLostException,
                 java.lang.InterruptedException
Subclasses should override this method for performing operations to be done repetitively as long as IOIO communication persists. Typically, this will be the main logic of the application, processing inputs and producing outputs.

Throws:
ConnectionLostException
java.lang.InterruptedException

disconnected

void disconnected()
Subclasses should override this method for performing operations to be done once as soon as IOIO communication is lost or closed. Typically, this will include GUI changes corresponding to the change. This method will only be called if setup() has been called. The ioio argument passed to setup(IOIO) must not be used from within this method - it is invalid. This method should not block for long, since it may cause an ANR.


incompatible

void incompatible()
Subclasses should override this method for performing operations to be done if an incompatible IOIO firmware is detected. The ioio argument passed to setup(IOIO) must not be used from within this method - it is invalid. This method will only be called once, until a compatible IOIO is connected (i.e. setup(IOIO) gets called).