Using the Phidget22 API: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{Recommended_Flow_Links|{{Flow Page Number|{{PAGENAME}} }} }} | [[Category:Programming]]{{Recommended_Flow_Links|{{Flow Page Number|{{PAGENAME}} }} }} | ||
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. | 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. |
Latest revision as of 16:59, 15 March 2021
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:
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
.
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 likeMaxCurrentLimit
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.