|
|
(299 intermediate revisions by 10 users not shown) |
Line 1: |
Line 1: |
| == Operating System Support ==
| | #REDIRECT [[Phidget Programming Basics]] |
| | |
| Phidgets can '''run directly''' on these operating systems:
| |
| | |
| * [[OS - Windows]]
| |
| * [[OS - Mac OSX]]
| |
| * [[OS - Linux]]
| |
| * [[OS - Windows CE]] ??
| |
| * [[OS - Android]] (3.1 and above)
| |
| | |
| Phidgets can be '''driven remotely''' by these operating systems:
| |
| | |
| * [[OS - Windows]]
| |
| * [[OS - Mac OSX]]
| |
| * [[OS - Linux]]
| |
| * [[OS - Windows CE]]
| |
| * [[OS - iOS]]
| |
| * [[OS - Android]]
| |
| | |
| == Language Support ==
| |
| | |
| Phidgets can be programmed either by an '''event-driven''' model, or by traditional '''linear code'''. All languages below support linear code. Some languages support our complete API, which includes support for event-driven design.
| |
| | |
| If you are flexible on what language you can use, we suggest choosing a language which supports event-driven code.
| |
| | |
| Phidgets have libraries to support [[#Event Driven Code|Event Driven Code]] in the following languages:
| |
| | |
| * [[Language - C/C++]]
| |
| * ...
| |
| | |
| Phidgets have libraries to support only [[#Linear Code|Linear Code]] in the following languages:
| |
| | |
| * [[Language - MATLAB]]
| |
| * ...
| |
| | |
| == Different Code Styles ==
| |
| | |
| User and device actions can be handled by either:
| |
| *Letting the program tell you when they happen and then doing something (event driven code)
| |
| *Waiting for them on your own and then and then doing something (linear code)
| |
| | |
| These styles can mix. For example, you can take a defined set of steps at first such as turning on an LED or antenna (linear code) and then doing nothing until an output change event is fired (event code).
| |
| | |
| With languages that support both styles, you can mix and match. For languages that support only linear code (see the [[#Language Support|Language Support Categories]] above) you can only use the linear style.
| |
| | |
| Examples in pseudo-code are given below for each style type so you can see how your language choice can affect your code design.
| |
| | |
| === Event Driven Code ===
| |
| | |
| Event driven code
| |
| | |
| <div style="background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;">
| |
| <font size="3">
| |
| <source lang=text>
| |
| | |
| // --- Event Functions ---
| |
| | |
| Create any Language-Specific Functions
| |
| | |
| Create General Attach, Detach, and Error Handling Functions
| |
| On attach: Initialize hardware (antennas, etc)
| |
| On detach: Reset any state variables
| |
| | |
| Create Hardware-Specific Functions
| |
| Print messages to notify they are called
| |
| Perform minor accompanying changes (turn on LED, etc)
| |
| | |
| // --- Main Code ---
| |
| | |
| Create Device Software Object
| |
| Attach Event Functions created above to Device
| |
| Open Device
| |
| | |
| Loop waiting for events and user input:
| |
| If device attached: Get and Print various device statuses on request by input
| |
| Handle on-going attach and detach events
| |
| Exit upon specific user input
| |
| | |
| Close Device
| |
| Delete Device
| |
| | |
| </source>
| |
| </font>
| |
| </div>
| |
| | |
| Then, to add your own functionality, you might make the following changes:
| |
| | |
| <div style="background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;">
| |
| <font size="3">
| |
| <source lang=text>
| |
| | |
| // --- Event Functions ---
| |
| | |
| Create any Language-Specific Functions
| |
| | |
| Create General Attach, Detach, and Error Handling Functions
| |
| On attach: Initialize hardware (antennas, etc)
| |
| On detach: Reset any state variables
| |
| | |
| Create Hardware-Specific Functions
| |
| Print messages to notify they are called
| |
| Perform minor accompanying changes (turn on LED, etc)
| |
| | |
| // --- Main Code ---
| |
| | |
| Create Device Software Object
| |
| Attach Event Functions created above to Device
| |
| Open Device
| |
| | |
| Loop waiting for events and user input:
| |
| </source>
| |
| <span style="color:red;"> Change this loop to your input</span>
| |
| <source lang=text>
| |
| If device attached: Get and Print various device statuses on request by input
| |
| Handle on-going attach and detach events
| |
| Exit upon specific user input
| |
| | |
| Close Device
| |
| Delete Device
| |
| | |
| </source>
| |
| </font>
| |
| </div>
| |
| | |
| === Linear Code ===
| |
| | |
| Linear code
| |
| | |
| <div style="background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;">
| |
| <font size="3">
| |
| <source lang=text>
| |
| | |
| Create Device Software Object
| |
| Open Device
| |
| Wait for Device Attachment
| |
| Initialize any hardware (antennas, etc)
| |
| | |
| Loop waiting for requests from user input:
| |
| Get and Print various device statuses on request by input
| |
| Exit upon specific user input
| |
| | |
| Close Device
| |
| Delete Device
| |
| | |
| </source>
| |
| </font>
| |
| </div>
| |