Alert.png

Notice: This page contains information for the legacy Phidget21 Library.

Phidget21 is out of support. Bugfixes may be considered on a case by case basis.

Phidget21 does not support VINT Phidgets, or new USB Phidgets released after 2020. We maintain a selection of legacy devices for sale that are supported in Phidget21.

We recommend that new projects be developed against the Phidget22 Library.


Click on the 2phidget22.jpg button in the menu bar to go to the Phidget22 version of this page.

Alert.png

Template:ExamplePseudocode: Difference between revisions

From Phidgets Legacy Support
No edit summary
No edit summary
Line 27: Line 27:
|  
|  
<font face="courier new" family="monospace">
<font face="courier new" family="monospace">
{{{1}}}
<span style="color:#00F;">{{{1}}}</span>
</font>
</font>
|- valign="top"
|<font face="courier new" family="monospace">


|}
<span style="color:#090;">// ----- Main Code -----</span>
</font>
Create Device Software Object
</div>
Hook Event Functions created above to Device
  // --- Main Code ---
Open Device


  Create Device Software Object
Loop waiting on events and user input:
  Hook Event Functions created above to Device
:Get and Print various device statuses on request by input
  Open Device
:Handle on-going attach and detach events
:Exit upon specific user input


  Loop waiting on events and user input:
Close Device
      Get and Print various device statuses on request by input
Delete Device
      Handle on-going attach and detach events
      Exit upon specific user input


  Close Device
</font>
  Delete Device
| width="15px" | &nbsp;
 
|
</source>
<font face="courier new" family="monospace">
<span style="color:#00F;">{{{2}}}</span>
</font>
|}
</font>
</font>
</div>
</div>

Revision as of 22:11, 8 December 2011

You can learn about the flow and the functions within the examples by reading about General Phidget Programming, which will walk you through the concepts in each example, regardless of your device or language.

The examples for each device all have this general structure so you can follow along:


// ----- Event Functions -----

Create any Language-Specific Functions (exception handling)

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)

 

{{{1}}}

// ----- Main Code ----- Create Device Software Object Hook Event Functions created above to Device Open Device

Loop waiting on events and user input:

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

 

{{{2}}}