Input Event Handling

In creapro processing library, the classes Arduino and AdMoVeo use callback functions (digitalAvailable(), analogAvaialbe() and inputAvailable()) for handling input events. One should keep in mind that the event handling takes place in the thread of Serial, which takes care of both input and output through the serial port. Once it enters the callback function, the thread is occupied until the callback function finishes. While the Serial thread is occupied by the call back function, all other input or output events will queue up -- this often results in delay in processing the input events.

A good strategy in practice is that the callback functions for input events only store the input data and do nothing else. This will ensure timely release the Serial thread for other events. The response to the input events can take place in another thread, usually the draw() function. The draw function runs in a thread in parallel with the Serial thread hence it won't delay the Serial input event handling.