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
 
(16 intermediate revisions by 2 users not shown)
Line 1: Line 1:
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 Hello World example has this general structure so you can follow along.  We also have [[General Phidget Programming|an in-depth general introduction]] to writing Phidget code (like open, read data, etc), as well as the {{{3}}} for specific syntax:


The examples for each device all have this general structure so you can follow along:
<div class="source">
 
{| class="source" style="margin-left:15px;"
 
<div style="background-color: #f3f3f3; border-color: #1c9edb; border-width:1px; border-style: dashed;">
<font size="2">
{| style="border:0; padding-left:20px; margin-left:10px;"


|- valign="top"
|- valign="top"
|<font face="courier new" family="monospace">
|<font face="courier new" family="monospace">


<span style="color:#090;">// ----- Event Functions -----</span>
<span style="color:#090;">// ----- '''Event''' and Other Functions -----</span>


Create any Language-Specific Functions (exception handling)
Create any Language-Specific Functions (exception handling)


Create General Attach, Detach, and Error Handling Functions
Create General '''Attach''', '''Detach''', and '''Error''' Handling Functions:
:On attach: Initialize hardware (antennas, etc)
:On attach: Print Hello Message
:On detach: Reset any state variables
:On detach: Print Goodbye Message
 
Create Hardware-Specific Functions
:Print messages to notify they are called
:Perform minor accompanying changes (turn on LED, etc)


</font>
</font>
Line 27: Line 19:
|  
|  
<font face="courier new" family="monospace">
<font face="courier new" family="monospace">
{{{1}}}
<span style="color:#00F;">{{{1}}}</span>
</font>
</font>
|- valign="top"
|style=white-space:nowrap|<font face="courier new" family="monospace">


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


  Create Device Software Object
;Wait for 'Enter' key character input
  Hook Event Functions created above to Device
:Handle on-going attach and detach events
  Open Device
:Print Hello and Goodbye messages
:Exit upon input


  Loop waiting on events and user input:
'''Close''' Device
      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
  Delete Device


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

Latest revision as of 20:47, 25 April 2012

The Hello World example has this general structure so you can follow along. We also have an in-depth general introduction to writing Phidget code (like open, read data, etc), as well as the {{{3}}} for specific syntax:

// ----- Event and Other Functions -----

Create any Language-Specific Functions (exception handling)

Create General Attach, Detach, and Error Handling Functions:

On attach: Print Hello Message
On detach: Print Goodbye Message

 

{{{1}}}

// ----- Main Code -----

Create Manager Software Object
Hook Event Functions created above to Device
Open Device

Wait for 'Enter' key character input
Handle on-going attach and detach events
Print Hello and Goodbye messages
Exit upon input

Close Device

Delete Device

 

{{{2}}}