This is the Java JNI implementation of the Phidget library, based on the phidget21 C library.

## How to use Phidgets

Phidgets are an easy to use set of building blocks for low cost sensing and control from your PC. Using the Universal Serial Bus (USB) as the basis for all Phidgets, the complexity is managed behind this easy to use and robust Application Program Interface (API) library.

This library was written in Java as a JNI interface to the phidget21 C library. This base C library is available with the JNI extensions for Windows, MacOS and Linux, so Phidgets can be used with Java on all of these operating systems. The advantage of a JNI is that it is extremely fast compared to any sort of non-native interface. All of the functionality of the base library is provided through this JNI.

## Basic Architecture

Phidgets are controlled through an object interface, where each Phidget that is to be used has it's own object. Every type of Phidget is supported by it's own class type, each of which subclass the base type {@link com.phidgets.Phidget Phidget}.

To start using a Phidget, it's object must first be created, and then one of the {@link com.phidgets.Phidget#open open} methods must be called to create a connection. Open is an asynchronous call, so it's returning can not be tacken as meaning that the Phidget is available. To this end, there are both synchronous and asynchronous notification processes availabel for determining when a Phidget is connected. See {@link com.phidgets.Phidget#open(int) open} for more information.

Many events are supported for each Phidget, with the base events {@link com.phidgets.event.AttachEvent Attach}, {@link com.phidgets.event.DetachEvent Detach}, {@link com.phidgets.event.ServerConnectEvent ServerConnect}, {@link com.phidgets.event.ServerDisconnectEvent ServerDisconnect} and {@link com.phidgets.event.ErrorEvent Error} being available for every Phidget. These events should be registered before the call to open, so as to not miss any events.

Also, note that open is pervasive. This means that a Phidget can be opened when it is not plugged in, and stay opened even if it is unplugged multiple times during operation. Use the {@link com.phidgets.event.AttachEvent Attach} and {@link com.phidgets.event.DetachEvent Detach} events to keep track of this. When the phidget is no longer required, {@link com.phidgets.Phidget#close close} should be called.

## Examples

Examples are available on the Phidgets website, in the downloads section.