Using the Phidget22 API

From Phidgets Support
 Phidget Programming Basics: Using the Phidget22 APITOC Icon.png Table of Contents

Nav Back Arrow.png Nav Back Hover.png WhiteTab1.png HoverTab1.jpg WhiteTab2.png HoverTab2.jpg WhiteTab3.png HoverTab3.jpg WhiteTab4.png HoverTab4.jpg WhiteTab5.png HoverTab5.jpg WhiteTab6.png HoverTab6.jpg WhiteTab7.png HoverTab7.jpg WhiteTab8.png HoverTab8.jpg WhiteTab9.png HoverTab9.jpg WhiteTab10.png HoverTab10.jpg WhiteTab11.png HoverTab11.jpg WhiteTab12.png HoverTab12.jpg GreenTab13.png WhiteTab14.png HoverTab14.jpg WhiteTab15.png HoverTab15.jpg WhiteTab16.png HoverTab16.jpg Nav Next Arrow.png Nav Next Hover.png


13 . Using the Phidget22 API

The Phidget22 API is the collection of properties, functions, events, and other tools that are at your disposal when programming with Phidgets. Our API documentation will define each of these items and guide you through their usage. Reading the API is a good way to learn what your device is capable of, and it also useful to have open when you're reading through the sample programs we provide.

To begin, we recommend that you go to the product page for your device and click on the API tab:

APItab.jpg

Firmware version found in the Phidget Control Panel.

From there, you can select your preferred programming language and specify the firmware version of your device (You can find the firmware version in the "version" column of the Phidget Control Panel). The final box selects which channel class you want to look at. Many Phidgets will have multiple different channel classes for differing parts of the physical device. For example, this DC motor controller has separate channel classes for its DCMotor, Encoder, and MotorPositionController functionalities. There is also a generic Phidget API for each one that contains common functions like open and close.

APIselect.jpg

Once you've selected a channel class, all of the members will be sorted into categories below

  • Properties - These are variables that can be "set" and/or "get" which control certain aspects of the device. Some properties like the DCMotor's CurrentLimit can be changed, and others like MaxCurrentLimit are constants. For languages that don't support properties, these are managed using functions or methods instead.
  • Functions / Methods - These are commands that do something with your device. (e.g. the Spatial's ZeroGyroscope command)
  • Events - These are triggers that you can assign to a piece of code that you want to execute every time something happens with your device, like when data comes in or when the channel attaches.
  • Constants and Enumerations - Constants are variable names that represent a static value. Using them instead of the numbers they represent makes your code more legible and cross-compatible with other devices of the same class. Enumerations are groups of numbers that represent options for a certain setting.
  • Structs - These are variables that a grouped together to make them easier to use.

Click on a member to expand the box and display in-depth information about it: Parameters, return values, minimum and maximum allowable values, code sample showing proper usage, and more.