Phidget Examples for Delphi
Last Updated: August 17, 2006

----------------------------------------------------------------------------------------
Requirements:

Supported: Delphi 7, Delphi 2005, Delphi 2006
Unsupported: Delphi 6 and lower, Delphi 8
Delphi support is based on Phidget21COM.dll - The Phidget 21 COM library

Note: Delphi 6 and lower operation might be poissible, but we aren't able to aquire these old versions of Delphi for testing. Any confirmation of these versions working or not would be welcomed.

----------------------------------------------------------------------------------------
Usage:

Quick:

1. Add PHIDGET_TLB.pas and PHIDGETEvents.pas to your project
2. Add PHIDGETEvents, PHIDGET_TLB to your uses statement
3. Install the correct PhidgetEvents .bpl for your version of Delphi by choosing "Install Packages..." from the Component menu, and clicking on the "Add..." button.
4. Your environment is now set up for phidgets. Have a look at the examples for more information.

Explained a bit more:

The easiest way to get started with Phidgets and Delphi is to simply include the PHIDGET_TLB.pas file found in the Delphifolder into your project - This will give you access to phidgets. If you need to use events, which you most likely will, then you should also include PHIDGETEvents.pas

Once those two files are referenced, you have to add them to your uses statement in the following order: PHIDGETEvents, PHIDGET_TLB

You now have access to Phidgets and their events.

In order to make the events easier to use, you can access them as ActiveX components in the toolbox. 

To install PhidgetEvents, choose "Component->Install Packages...", click the 'Add...' button, and select the correct .bpl file (Either PhidgetEvents - Delphi 7.bpl, PhidgetEvents - Delphi 2005.bpl, or PhidgetEvents - Delphi 2005.bpl).

This component package must be installed before you try to open the examples, or they will complain about missing components.

At this point you should be able to open the Examples. They are probably your best starting point to using Phidgets with Delphi.

----------------------------------------------------------------------------------------
Basic Example Usage:

To control something, create an instantiantion of it's class, and open the device:

var
	Servo : IPhidgetServo;

...

begin
	Servo:=CoPhidgetServo.Create;
	servo.Open(false,-1);
end;

If you are dealing with events, you will want to connect them to your object before you open it, so as to not miss any events:

var
	Servo : IPhidgetServo;
    	PHIDGETIPhidgetServoEvents1: TPHIDGETIPhidgetServoEvents;

...

begin
	Servo:=CoPhidgetServo.Create;
    	PHIDGETIPhidgetServoEvents1.Connect(Servo1);
	servo.Open(false,-1);
end;

More complete examples are included for the Interfacekit, the RFID reader and the Servo Controller.

----------------------------------------------------------------------------------------
Other considerations:

Where I got the PHIDGET_TLB.pas file from:

-This was simply created by importing from the Phidget COM library. In Delphi 2005, this is done by choosing  "Component->import Component..." Then "Import a Type Library". From the list choose "Phidget Library 2.1".

Where I got the PHIDGETEvents.pas file from:

-This was automatically generated from the Phidgets Library using the utility "EventSinkImp". I have included the installer: "EventSinkImp.msi". The program originated here: http://www.techvanguards.com/products/eventsinkimp/
-To use it, you simply choose your library (Phidget Library 2.1), choose an output folder, and make sure the the TLibImp Location in Options is filled in (for me this location is: C:\Program Files\Borland\BDS\3.0\Bin\tlibimp.exe). Then choose "Import" and it will create both PHIDGET_TLB.pas and PHIDGETEvents.pas
-This program is not specific to Delphi 2005 and the .pas files that it generates should be compatible with earlier versions.

More about the ActiveX components (Events):

-These ActiveX components, once properly installed, will show up in your toolbox, under the ActiveX tab, as TPHIDGETIPhidgetServoEvents, TPHIDGETIPhidgetInterfaceKitEvents, etc. You use them, just like any other control, by dragging the events you wish to use onto your form, and then selecting the events on the Object Inspector, which will take care of creating event handlers for you.
-As far as I know, these are supported by earlier versions of Delphi. What has chages in that way in which you must import them. In Delphi 7 and higher, components have to be added from packages rather then from source files. That's why we've included phidget.bpl. I believe that older versions of Delphi are capable of installing components directly from a source file. This would be done by choosing some sort of "Install Components" from the Component or equivalent menu, and choosing the PHIDGETEvents.pas file as the source of these components.

Some advice for older versions of Delphi:

-You might need to recreate PHIDGET_TLB.pas
-You could try recreating the phidget.blp package installer. To do this, you just need to create a new package and add "phidget_TLB.pas" and "PhidgetEvents.pas" into the project, then compile. I'm not sure how far back Delphi has support for Package type projects.
-You might be able to install the ActiveX Controls (components) without using a package installer: See the privious point - "More about the ActiveX components (Events)"
