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

See:
          Description

Packages
com.phidgets This package contains classes for each type of Phidget, as well as a Phidget Manager.
com.phidgets.event This package contains interfaces and data classes for all Phidget related events.

 

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 Phidget.

To start using a Phidget, it's object must first be created, and then one of the 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 open for more information.

Many events are supported for each Phidget, with the base events Attach, Detach, ServerConnect, ServerDisconnect and 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 Attach and Detach events to keep track of this. When the phidget is no longer required, close should be called.

Examples

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