API Manual - Actionscript 3.0 - Phidget21

anthropologistbarrenSoftware and s/w Development

Jul 4, 2012 (5 years and 1 month ago)

697 views

Actionscript 3.0
API Manual
Phidget21
Describes the Application Program Interface (API)
for each Phidget device. The API can be used by
a number of languages; this manual discusses use
via Flash and the code examples reflect this.
Library Version: 2.1.1
Phidgets Actionscript 3.0 API Reference
Version 21.2
© Phidgets Inc. 2007
Contents
How to use Phidgets
5
Basic Architecture
5
Basic Example
5
Phidget Class
6
Phidget Methods
7
Phidget Events
8
PhidgetAccelerometer
9
Phidget Accelerometer Methods
9
Phidget Accelerometer Events 1
0
PhidgetEncoder
1
1
Phidget Encoder Methods 1
1
Phidget Encoder Events 1
2
PhidgetInterfaceKit 1
3
Phidget InterfaceKit Methods
1
3
Phidget InterfaceKit Events 1
5
PhidgetLED 1
6
Phidget LED Methods 1
6
PhidgetMotorControl 1
7
Phidget Motor Control Methods 1
7
Phidget Motor Control Events 1
9
PhidgetPHSensor 2
0
Phidget PH Sensor Events 2
0
PhidgetRFID 2
1
Phidget RFID Methods 2
1
Phidget RFID Events 2
2
PhidgetServo 2
3
Phidget Servo Methods 2
3
Phidget Servo Events 2
4
PhidgetTemperatureSensor 2
5
Phidget Temperature Sensor Methods 2
5
Phidget Temperature Sensor Events 2
6
PhidgetTextLCD 2
7
Phidget Text LCD Methods 2
7
The Phidget Dictionary 2
8
Phidget Dictionary Methods 2
8
Phidget Dictionary Events 2
9
The Phidget Manager 3
1
Phidget Manager Methods 3
1
Phidget Manager Events 3
2
Appendix I: Regular Expressions 3
3
Extended Regular Expressions: 3
4
Appendix II: Error Codes and Descriptions 3
5
Appendix III: Special Values 3
7
Appendix IV: Event Handlers 3
8
Appendix V: Change Triggers 3
9
Appendix VII: Generating Custom Characters 4
0
How to use Phidgets
Phidgets are an easy to use set of building blocks for low cost sensing and control from your PC.
Using the Universal Serial Bus (USB) as the basis for all Phidgets, the complexity is managed behind this
easy to use and robust Application Program Interface (API) library.
The library was written originally for Windows, but has been ported to MacOS and Linux. Although
the library is written in C, the functions can be called from a number of languages including C, C++,
Objective-C, Matlab, Flash, etc. The source code is freely available for reference/debugging purposes.
Basic Architecture
Phidgets are controlled at the
API Level using a specific object for
the type of Phidget you are using.
Operations are performed by
calling methods on this object. Objects
are registered, and associated with
a Phidget device using one of the
Phidget.open functions. After the
OnAttach event fires, commands can
be issued.
If the application needs data
from the device, event handlers can be used, or property get functions can be used to get specific values.
Lastly, the Phidget.close method is called to disconnect the object from the Phidget.
Basic Example
When programming for all Phidgets the basic procedure is always the same. First an object must be
declared as a Phidget. Then on Open command must be sent, after which the object will be attached. Only
after the attach occurs can any inputs be read or outputs changed.
This example contacts the Local Webservice on Port 5001 and attempts to open a Phidget IntefaceKit.
To use this code, paste it into the Actions pane for the first frame of a movie. You should see activity on the
Output pane when the Movie is Tested.
import com.phidgets.*;
import com.phidgets.events.*;
var blnInit;
var myPhidget:Phidget;
function onAttach(evt:PhidgetEvent):void{
trace(evt);
}
if (blnInit != true) {
trace('Performing Initialisation');
myPhidget= new PhidgetInterfaceKit();
myPhidget.addEventListener(PhidgetEvent.ATTACH, onAttach);
myPhidget.open("localhost", 5001);
blnInit = true;
}
More detailed examples for all the calls in this document can be found in the Downloads section of the Phidgets
website.
Client Machine
User Application
Phidget Library
Phidget Device
Device Firmware
Device Hardware
IO Devices
Sensors
Indicators
Actuators
USB
TCP/IP
Server / Phidget Host
Phidget Library
User
Application
Phidget
WebService
Phidget Class
The base class for interaction with Phidget devices is the Phidget Class. All Phidgets will have these properties,
methods and events in common
Class: Phidget
Package: com.phidgets
Extends: EventDispatcher
Base class for all Phidget device interaction
Properties
Label:string [get/set] Gets and Sets a user specified Identifying string for the phidget.
ServerID:String [get] DNS name of the server hosting the Phidget device
Port:int [get] Port of the Webservice on the Server
Address:String [get] IP Address of the Server that hosts this Phidget device
isConnected:Boolean [get] Whether or not the device is physically connected
isAttached:Boolean [get] Returns an integer indicating the status of the device.
serialNumber:int [get] Returns the unique serial number of this Phidget.
This number is set during manufacturing, and is unique across all Phidgets.
Version:int [get] Sets a pointer to a null terminated string describing the Device Version of
the Phidget
Name:String [get] Sets a pointer to a null terminated string describing the name of the
Phidget.. For example, “Phidget InterfaceKit 8/8/8”, “Phidget InterfaceKit
0/0/4”, etc.
Type:String [get] Sets a pointer to a null terminated string describing the type of the Phidget.
All PhidgetInterfaceKits will return "PhidgetInterfaceKit", PhidgetRFID returns
"PhidgetRFID" and so on.
Phidget Methods
Phidget.open
Creates a connection between a CPhidgetHandle and a physical Phidget. The CPhidgetHandle should be a valid handle previously
allocated by CPhidget
(device)
_create. Before calling CPhidget_open, we recommend registering the event handlers your application will
use.
Open is pervasive. What this means is that you can call open on a device before it is plugged in, and keep the device opened across
device dis- and re-connections.
Open is Asynchronous. What this means is that open will return immediately – before the device being opened is actually available.
What this means is that you need to either poll CPhidget_getDeviceStatus for an attached status, or handle the attach event, in order
to wait for the device to become available before trying to use it.
open (address:String, port:Number, password:String,
serialNumber:Number):void
Input
address:string IP Address of the server hosting the Phidget
port:Number Port- number of the webservice running on the server
password:String Password to the server
Can be empty if password is not used on server
serialNumber:Number Serial Number of the phidget you wish to open
Setting to -1 will open the first available Phidget device matching the object
type you are calling open upon. This can be empty if only device exists.
Phidget.close
Closes the file handles for this device. You can call this while reads and writes are still outstanding; they will fail quickly
close():void
Phidget.toString()
Returns a string containing the Phidget Device Name, Device Version and Serial Number.
This should allow one to uniquely identify a particular Phidget device.
toString():String
Output
return value:String
Phidget Events
com.phidgets.events.PhidgetEvent
com.phidgets.events.PhidgetErrorEvent
onConnected
An event raised by a Phidget object when it has established communication with a Phidget device after an Open request.
PhidgetEvent (PhidgetEvent.CONNECT, myphidget:Phidget)
Parameters
PhidgetEvent.CONNECT The type of event raised by the Phidget. In this case a Connect event
myphidget:Phidget The Phidget object that raised the event
onDisconnected
An event raised by a Phidget object when it has lost communication with a Phidget device.
PhidgetEvent (PhidgetEvent.DISCONNECT, myphidget:Phidget)
Parameters
PhidgetEvent:DISCONNECT The type of event raised by the Phidget. In this case a Disconnect event
myphidget:Phidget The Phidget object that raised the event
onError
An event raised by a Phidget object when it encounters an error, either in the parameters of a request made to the object or an error
being raised by the Phidget device itself.
PhidgetErrorEvent (PhidgetErrorEvent.ERROR, myphidget:Phidget,
error:PhidgetError)
Parameters
PhidgetErrorEvent:ERROR The type of event raised by the Phidget In this case an Error event
myphidget:Phidget The Phidget object that raised the event
error:PhidgetError The error code being raised. Corresponds to one of the PhidgetErrors
See the Appendices for a list of these error codes.
onAttach
An event raised by a Phidget object when the Phdiget device is physically connected to the host machine.
PhidgetEvent (PhidgetEvent.ATTACH, myphidget:Phidget)
Parameters
PhidgetEvent.ATTACH The type of event raised by the Phidget.
In this case a Attach event
myphidget:Phidget The Phidget object that raised the event
onDetach
An event raised by the Phidget object when the Phidget device is physically disconnect from the host machine.
PhidgetEvent (PhidgetEvent.DETACH, myphidget:Phidget)
Parameters
PhidgetEvent.DETACH The type of event raised by the Phidget. In this case a Detach event
myphidget:Phidget The Phidget object that raised the event
PhidgetAccelerometer
The PhidgetAccelerometer is a component that provides a high-level programmer interface to control a
PhidgetAccelerometer device connected through a USB port. The product is available as a dual axis or a 3-axis
module. With this component, the programmer can:
Measure up to 5 Gravity (5*9.8 m/s2) change per axis, depending on unit purchased.

Measures both dynamic acceleration (e.g., vibration) and static acceleration (e.g., gravity or tilt) on 2 or 3

axis.
Class: PhidgetAccelerometer
Package: com.phidgets
Extends: Phidget
Specialised class for PhidgetAccelerometer Device interaction
Properties
NumberOfAxes:int [get] Get the number of axes available from the PhidgetAccelerometer.
Please view the Phidget’s Product Manual to determine if functionality varies
from this document.
Phidget Accelerometer Methods
PhidgetAccelerometer.getAcceleration
Gets the last acceleration value received from the PhidgetAccelerometer for a particular axis.
Please view the Phidget’s Product Manual to determine if functionality varies from this document.
getAcceleration(index:int):Number
Input
index:int Index of Axis to query
Output
return value:Number Current value of the Acceleration
PhidgetAccelerometer.getAccelerationChangeTrigger
Gets the amount of change that should exist between the last reported value and the current value before an OnAccelerationChange
event is fired.
For additional information please view the Appendix on Change Triggers.
getAccelerationChangeTrigger(index:int):Number
Input
index:int Index of the Axis to query for Change Trigger
Output
return value:Number Current value of the Change Trigger
PhidgetAccelerometer.setAccelerationChangeTrigger
Specifies the amount of change that should exist between the last reported value and the current value before an OnAccelerationChange
event is fired. If the AccelerationChangeTrigger is set to 0, an event will be triggered for every measurement of acceleration taken.
For additional information please view the Appendix on Change Triggers
setAccelerationChangeTrigger(index:int, val:Number):void
Input
index:int Index of the Axis to set the Change Trigger on
val:Number Value to set the Change Trigger to
Phidget Accelerometer Events
com.phidgets.events.PhidgetDataEvent
onAccelerationChange
An event raised by the Phidget when the Acceleratin exceeds the Acceleration Change Trigger threshold
PhidgetDataEvent( PhidgetDataEvent.ACCELERATION_CHANGE,
myPhidget:Phidget, acceleration:Number, index:int)
Parameters
PhidgetDataEvent.ACCELERATION_CHANGE The type of event being raised by the Phidget.
In this case an Acceleration Change.
myPhidget:Phidget The Phidget object raising the event
acceleration:Number The current value of the Acceleration
index:int The index of the Axis raising the event
PhidgetEncoder
The PhidgetEncoder is a component that provides a high-level programmer interface to control a
PhidgetEncoder device connected through a USB port.
With this component, the programmer can:
Detect changes in position of incremental and absolute encoders.

Easily track the changes with respect to time.

Class: PhidgetEncoder
Package: com.phidgets
Extends: Phidget
Specialised class for PhidgetEncoder device interaction
Properties
NumberOfInputs:int [get] Returns the number of inputs on this particular Phidget device.
Please view the Phidget’s Product Manual to determine if functionality varies
from this document.
NumberOfEncoders:int [get] Gets the number of encoders available on the Phidget.
Please view the Phidget’s Product Manual to determine if functionality varies
from this document.
Phidget Encoder Methods
PhidgetEncoder.getInputState
Returns the state of the designated input.
In the case of a switch or button which is normally open, True would correspond to when the switch is pressed.
Please view the Phidget’s Product Manual to determine if functionality varies from this document.
Note this is not available on the PhidgetEncoder HighSpeed device.
getInputState(index:int):Boolean
Input
index:int Index of input to query
Output
return value:Boolean Current input state
PhidgetEncoder.getEncoderPosition
Gets the last position value received from the encoder for the particular encoder selected.
Please view the Phidget’s Product Manual to determine if functionality varies from this document.
getEncoderPosition
(index:int):Number
Input
index:int Index of encoder to query
Output
return value:int Current position of encoder
PhidgetEncoder.setEncoderPosition
Specifies a new value for the current position of the encoder.
Please view the Phidget’s Product Manual to determine if functionality varies from this document.
setEncoderPosition(index:int, val:Number):void
Input
index:int Index of encoder to set
val:Number New position of encoder
Phidget Encoder Events
com.phidgets.events.PhidgetDataEvent
onInputChange
An event raised when a digital input changes state.
PhidgetDataEvent (PhidgetDataEvent.INPUT_CHANGE, myPhidget;Phidget,
input:Boolean, index:int)
Parameters
PhidgetDataEvent.INPUT_CHANGE The type of event being raised by the Phidget.
In this case an Input Change event
myPhidget:Phidget The Phidget object raising the event
input:Boolean The current value of the Input
index:int The index of the Input raising the event
onPositionChange
An event raised when the Position of the Encoder is changed.
PhidgetDataEvent ( PhidgetDataEvent.POSITION_CHANGE, myPhidget:Phidget,
position:int, index:int)
Parameters
PhidgetDataEvent.POSITION_CHANGE The type of event being raised by the Phidget.
In this case a Position Change event.
myPhidget:Phidget The Phidget object raising the event
position:int The current value of the Position
index:int The index of the Encoder raising the event
PhidgetInterfaceKit
The PhidgetInterfaceKit is a component that provides a high-level programmer interface to control a
PhidgetInterfaceKit device connected through a USB port.
With this component, the programmer can:
Turn particular outputs on and off.

Get notified of changes of state of the inputs as events.

Configure events to fire when the analog inputs change.

The PhidgetInterfaceKit devices provide a combination of:
Digital outputs.

Digital inputs.

Analog inputs.

Note that any implementation details that vary from this document will be noted in the Product Manual for the
specific device.
Class: PhidgetInterfaceKit
Package: com.phidgets
Extends: Phidget
A specialised class that handles interaction with an InterfcaeKit device.
Properties
NumberOfInputs:int [get] Gets the number of Inputs on the device
NumberOfOutputs:int [get] Gets the number of Outputs on the device
NumberOfSensors:int [get] Gets the number of analog inputs available on the given PhidgetInterface Kit
Please view the Phidget’s Product Manual to determine if functionality varies
from this document.
Ratiometric:Boolean [get/set] Some of the PhidgetInterfaceKits with Analog Inputs have to ability to
measure voltage by comparing to a fixed 5 Volt reference, or comparing to
the voltage supplied to the sensor.
If your sensor operates as a voltage divider, or the output is described as
ratiometric, SensorValue will be most accurate if Ratiometric is set to true.
If your sensor is described as non-ratiometric, set Ratiometric to false.
Sensors manufactured by Phidgets Inc. will typically have a small R printed
on them if they are Ratiometric, or N if they are non-ratiometric.
Note that this value is never actually returned from the Device only
maintained by the Phidgets Library.
Applications that use this value should set it explicitly.
Please view the Phidget’s Product Manual to determine if functionality varies
from this document.
Phidget InterfaceKit Methods
PhidgetInterfaceKit.getInputState
Retrieves the state of a didgital input
getInputState(index:int):Boolean
Input
index:int Index of Input to query
Output
return value:Boolean Current value of input
PhidgetInterfaceKit.getOutputState
Retrieves the state of a digital output
getOutputState(index:int):Boolean
Input
index:int Index of output to query
Output
return value:Boolean Current value of output
PhidgetInterfaceKit.setOutputState
Sets the state of a digital output
setOutputState(index:int, val:Boolean):void
Input
index:int Index of output to set
val:Boolean Value to set output to
PhidgetInterfaceKit.getSensorValue
Gets the last reported sensor value for the given index as a value from 0-1000
Note that this value defaults to 65535 for an unitialised state. Applications that do not wish to encounter this value should use
ChangeTrigger handlers as opposed to polling the device for new data.
Please view the Phidget’s Product Manual to determine if functionality varies from this document.
getSensorValue(index:int):int
Input
index:int Index of sensor to query
Output
return value:int Current value of sensor
PhidgetInterfaceKit.getSensorChangeTrigger
Gets the amount of change that should exist between the last reported value and the current value before an OnSensorChange event is
fired.
To receive all events, set the SensorChangeTrigger to zero.
For additional details on Change Triggers please view the Appendices.
getSensorChangeTrigger(index:int):int
Input
index:int Index of Sensor to find change trigger from
Output
return value:int Current value of Change Trigger
PhidgetInterfaceKit.setSensorChangeTrigger
Specifies the amount of change that should exist between the last reported value and the current value before an
OnSensorChange event is fired
Additional information can be found in the Change Triggers section of the Appendices.
setSensorChangeTrigger(index:int, val:int):void
Input
index:int Index of Sensor to apply change trigger to
val:int Value to set the change trigger to
Phidget InterfaceKit Events
com.phidgets.events.PhidgetDataEvent
onInputChange
An event raised by the PhidgetInterfaceKit object when the digital input changes.
PhidgetDataEvent (PhidgetDataEvent.INPUT_CHANGE, myphidget:Phidget,
input:Boolean, index:int)
Parameters
PhidgetDataEvent.INPUT_CHANGE The type of Data event raised by the Phidget.
In this case, an Input Change event.
myphidget:Phidget The Phidget object that raised the event
input:Boolean The state of the Input that raised the event
index:int=-1 The index of the input that raised the event.
onOutputChange
An event raised by the PhidgetInterfaceKit when a digital output changes.
PhidgetDataEvent (PhidgetDataEvent.OUTPUT_CHANGE, myphidget:Phidget,
output:Boolean, index:int)
Parameters
PhidgetDataEvent.OUTPUT_CHANGE The type of Data event raised by the Phidget.
In this case, an Output Change event.
myphidget:Phidget The Phidget object that raised the event
output:Boolean The state of the Input that raised the event
index:int=-1 The index of the input that raised the event.
onSensorChange
An event raised by the PhidgetInterfaceKit object when a Sensor passes it's Change Trigger threshold
PhidgetDataEvent (PhidgetDataEvent.SENSOR_CHANGE, myphidget:Phidget,

sensor:int, index:int)
Parameters
PhidgetDataEvent.SENSOR_CHANGE The type of Data event raised by the Phidget.
In this case, a Sensor Change event.
myphidget:Phidget The Phidget object that raised the event
sensor:int The state of the Sensor that raised the event
index:int=-1 The index of the input that raised the event.
PhidgetLED
The PhidgetLED is a component that provides a high-level programmer interface to control a PhidgetLED device
connected through a USB port.
With this component, the programmer can:
Control each led individually, On/Off and Brightness.

Class: PhidgetLED
Package: com.phidgets
Extends: Phidget
Base class for all Phidget device interaction
Properties
NumberOfLEDs:int [get] Returns the number of LED positions available in this Phidget.
This property does not return the number of LEDs actually attached.
Please view the Phidget’s Product Manual to determine if functionality varies
from this document
Phidget LED Methods
PhidgetInterfaceKit.getDiscreteLED
Gets the brightness of an individual LED.
Range of brightness is 0-100.
Please view the Phidget’s Product Manual to determine if functionality varies from this document.
getDiscreteLED(index:int):int
Input
index:int Index of the LED to query
Output
return value:int Current value of the LED
PhidgetInterfaceKit.setDiscreteLED
Sets the brightness of an individual LED.
Please view the Phidget’s Product Manual to determine if functionality varies from this document.
setDiscreteLED(index:int, val:int):void
Input
index:int Index of the LED to set
val:int Value to set the LED to
Valid from 0-100
PhidgetMotorControl
The PhidgetMotorControl is a component that provides a high-level programmer interface to control a
PhidgetMotorControl device connected through a USB port.
With this component, the programmer can:
Contro

l direction, and start and stop DC motors.
Control the velocity and acceleration of each DC motor.

Read the limit switch.

Class: PhidgetMotorControl
Package: com.phidgets
Extends: Phidget
Specialised class for PhdigetMotorControl device interactuibs
Properties
NumberOfInputs:int [get] Returns the number of inputs on this particular Phidget device.
Please see the hardware description for the details of device variations.
NumberOfMotors: int [get] Returns the maximum number of motors on this particular Phidget device.
This depends on the actual hardware. Please view the Phidget’s Product
Manual to determine if functionality varies from this document.
Note: that there is no way of programmatically determining how many
motors are actually plugged into the hardware.
Phidget Motor Control Methods
PhidgetMotorControl.getInputState
Returns the state of the designated input.
In the case of a switch or button which is normally open, True would correspond to when the switch is pressed.
Note that this device will report PUNKNOWN until data has been received. Applications wishing not to see this value should use Change
Handlers as opposed to polling the device for new data.
Please view the Phidget’s Product Manual to determine if functionality varies from this document.
getInputState(index:int):Boolean
Input
index:int Index of the input to query
Output
return value:Boolean Current value of the input
PhidgetMotorControl.getCurrent
Returns the current value for current consumption of a motor
getCurrent(index:int):Number
Input
index:int Index of the Motor to query
Output
return value:Number Current value of current to the motor
PhidgetMotorControl.getAcceleration
Gets the current acceleration
Note that this value defaults to 10 upon initialisation.
Please view the Phidget’s Product Manual to determine if functionality varies from this document.
getAcceleration(index:int):Number
Input
index:int Index of the motor to query
Output
return value:Number Current value of the Acceleration
PhidgetMotorControl.setAcceleration
Sets the Motor’s Maximum accesleration.
Valid values are 0-100
Please view the Phidget’s Product Manual to determine if functionality varies from this document.
setAcceleration(index:int, val:Number):void
Input
index:int Index of the motor to set
val:Number New maximum acceleration value
PhidgetMotorControl.getMotorSpeed
Gets the current motor speed.
Please view the Phidget’s Product Manual to determine if functionality varies from this document.
getMotorSpeed(index:int):Number
Input
index:int Index of the motor to query
Output
return value:Number Current motor speed
PhidgetMotorControl.setMotorSpeed
Sets the Motor Speed.
Valid values are (–100 – 100)
Please view the Phidget’s Product Manual to determine if functionality varies from this document.
setMotorSpeed(index:int, val:Number):void
Input
index:int Index of the motor to set
val:Number New value for the motor's speed
Phidget Motor Control Events
com.phidgets.events.PhidgetDataEvent
onInputChange
An event raised when a digital Input changes state
PhidgetDataEvent( PhidgetDataEvent.INPUT_CHANGE, myPhidget:Phidget,
input:Boolean, index:int)
Parameters
PhidgetDataEvent.INPUT_CHANGE The type of event being raised by the Phidget.
In this case an Input Change event
myPhdiget:Phidget The Phidget object raising the event
input:Boolean The current value of the input
index:int The index of the input raising the event
onVelocityChange
An event raised when a Motor velocity changes
PhidgetDataEvent( PhidgetDataEvent.VELOCITY_CHANGE, myPhidget:Phidget,
velocity:Number, index:int)
Parameters
PhidgetDataEvent.VELOCITY_CHANGE The type of event being raised by the Phidget.
In this case a Velocity Change event
myPhdiget:Phidget The Phidget object raising the event
velocity:Number The current Velocity value
index:int The index of the Motor raising the event
onCurrentChange
An event raised when a Motor's current consumption changes
Note that this may not be available on all device models.
Please see your device documentation for information on variation from this document.
PhidgetDataEvent ( PhidgetDataEvent.CURRENT_CHANGE, myPhdiget:Phidget,
current:Number, index:int)
Parameters
Input
PhdigetDataEvent.CURRENT_CHANGE The type of event being raised by the Phidget.
In this case a Current Change event.
myPhdiget:Phidget The Phidget object raising the event
current:Number The current value of the Motor's Current consumption
index:int The index of the Motor raising the event
PhidgetPHSensor
The PhidgetPHSensor is a component that provides a high-level programmer interface to control a
PhidgetPHSensor device connected through a USB port.
With this component, the programmer can:
Read the pH of a liquid with a pH sensor.

Class: PhidgetPHSensor
Package: com.phidgets
Extends: Phidget
Specialised class for PhidgetPHSensor device interaction
Properties
PH:Number [get] Returns the current pH.
Valid range is 0-14
Note that this value defaults to -20. Applications not wishing to encounter
this value should use Change Handlers instead of polling the device for data.
Please view the Phidget’s Product Manual to determine if functionality varies
from this document.
Potential:Number [get] Returns the current potential in volts.
Range is 0.414 to -0.414 volts for a range of 0 to 14 pH
0v corresponds to a pH of 7.0
Please view the Phidget’s Product Manual to determine if functionality varies
from this document.
PHChangeTrigger:Number [get/set] Gets the amount of change that should exist between the last reported value
and the current value before an OnPHChange event is fired.
For additional information see the Appendix on Change Triggers
Temperature:Number [set] Sets the ambient temperature of the PH sensor for increased accuracy.
This value defaults to 20 degrees celcius which is applicable for most
applications
Phidget PH Sensor Events
com.phidgets.events.PhidgetDataEvent
onPH_Change
An event raised by the Phidget when the PH changes more than the PH Change Trigger threshold
PhidgetDataEvent(PhidgetDat
aEvent.PH_CHANGE, myPhidget:Phidget,
ph:Number)
Parameters
PhidgetDataEvent.PH_CHANGE The type of event being raised by a Phidget.In this case a PH Change event
myPhidget:Phidget The Phidget object raising the event
ph:Number The current value of the PH sensor
PhidgetRFID
The PhidgetRFID is a component that provides a high-level programmer interface to control a PhidgetRFID
device connected through a USB port.
With this component, the programmer can:
Read Radio Frequency Identification tags that use the EM4102 125Khz protocol

Radio Frequency Identification or RFID, is a non-contact identification technology which uses a reader to read
data stored on low cost tags.
The particular instance of the technology we use stores a 40-bit number on the tag. Every tag that is
purchased from Phidgets Inc. is guaranteed unique.
When a RFID tag is read, the component returns the unique number contained in the RFID tag.
Class: PhidgetRFID
Package: com.phidgets
Extends: Phidget
Specialised class for PhidgetRFID device interaction
Properties
NumberOfOutputs:int [get] Returns the number of outputs on this particular Phidget device.
Please view the Phidget’s Product Manual to determine if functionality varies
from this document.
LastTag:String[get] The RFID tag value of the Last Tag to come within range of the tag reader
Antenna:Boolean [get/set] Sets the state of the antenna to True or False.
Please view the Phidget’s Product Manual to determine if functionality varies
from this document.
LED:Boolean [get/set] Sets the state of the LED to True or False.
Please view the Phidget’s Product Manual to determine if functionality varies
from this document.
TagPresent:Boolean [get] Whether or not an RFID tag is currently present
Phidget RFID Methods
PhidgetRFID.getOutputState
Returns the state of the designated digital output as True or False.
Depending on the type of output available, the specified output goes to a high value or completes a connection.
Note that this value defaults to PUNKNOWN. Applications not wishing to see this value should use Change Handlers instead of polling
the device for data.
Please view the Phidget’s Product Manual to determine if functionality varies from this document.
getOutputState(index:int):Boolean
Input
index:int Index of the output to query
Output
return value:Boolean Current value of the output
PhidgetRFID.setOutputState
Sets the state of the designated output to True or False.
Please view the Phidget’s Product Manual to determine if functionality varies from this document.
setOutputState(index:int, val:Boolean):void
Input
index:int Index of the output to set
val:Boolean New value of the output
Phidget RFID Events
com.phidgets.events.PhidgetDataEvent
onTag
An event raised when a compatible RFID tage comes within range of the PhdigetRFID device
PhidgetDataEvent (PhidgetDataEvent.TAG, myPhidget:Phidget, Tag:String)
Parameters
PhidgetDataEvent.TAG The type of event being raised by the Phidget
In this case a Tag detection event
myPhidget:Phidget The Phidget object raising the event
Tag:String The Internal Tag value of the last RFID tag to come within range of the
PhidgetRFID device
onTagLoss
An event raised when a compatible RFID tag leaves the detection range of the PhidgetRFID device
PhidgetDataEvent( PhidgetDataEvent.TAG_LOST, myPhidget:Phidget, Tag:String)
Parameters
PhidgetDataEvent.TAG_LOST The type of event being raised by the Phidget. In this case a Tag Loss event
myPhidget:Phidget The Phidget object raising the event
Tag:String The Internal Tag value of the RFID leaving range of the PhidgetRFID device
onOutputChange
An event raised when an output is changed.
PhidgetDataEvent( PhidgetDataEvent.OUTPUT_CHANGE, myPhdiget:Phidget,
output:Boolean, index:int)
Parameters
PhidgetDataEvent.OUTPUT_CHANGE The type of event being raised by the Phidget.
In this case an Output Change event
myPhdiget:Phidget The Phidget object raising the event
output:Boolean The current state of the output
index:int The index of the output raising the event
PhidgetServo
The PhidgetServo is a component that provides a high-level programmer interface to control a PhidgetServo
device connected through a USB port.
With this component, the programmer can:
Set the desired position for a servo motor, ranging from 0 to 180 degrees.

Class: PhidgetServo
Package: com.phidgets
Extends: Phidget
Specialised class for PhidgetServo device interaction
Properties
NumberOfMotors: int [get] Returns the maximum number of motors on this particular Phidget device.
This depends on the actual hardware. Please see the hardware description
for the details of device variations.
Note that there is no way of programmatically determining how many
motors are actually plugged into the hardware.
Phidget Servo Methods
PhidgetServo.getMotorPosition
Gets the desired servo motor position for a particular servo motor.
Note that this defaults to -23. Applications not wishing to see this value should use Change Handlers instead of polling the device for
data.
Please view the Phidget’s Product Manual to determine if functionality varies from this document.
getMotorPosition(index:int):Number
Input
index:int Index of the motor to query for position
Output
return value:Number Value of the Motor's current position
PhidgetServo.setMotorPosition
Sets the desired servo motor position for a particular servo motor.
This value may range from -23 to 231, corresponding to time width of the control pulse, the angle that the Servo motor moves to
depends on the characteristic of individual motors.
Please read the PhidgetServo documentation to understand what behaviour you can expect from your motors.
setMotorPosition(index:int, val:Number):void
Input
index:int Index of the Motor to set
val:Number New value for position
PhidgetServo.setMotorOff
Turns a Motor On & Off
setMotorOff(index:int):void
Input
index:int Index of a Motor to toggle
Phidget Servo Events
com.phidgets.events.PhidgetDataEvent
onPositionChange
An event raised when a Servo's Position changes
PhidgetDataEvent( PhidgetDataEvent.POSITION_CHANGE, myPhidget:Phidget,
position:Number, index:int)
Parameters
PhidgetDataEvent.POSITION_CHANGE The type of event being raised the Phidget.
In this case Position Change event
myPhdiget:Phidget The Phidget object raising the event
position:Number The current position of the Servo
index:int The index of the Servo raising the event
PhidgetTemperatureSensor
The PhidgetTemperatureSensor is a component that provides a high-level programmer interface to control a
PhidgetTemperatureSensor device connected through a USB port.
With this component, the programmer can:
Read the temperature of Thermocouple device.

Read cold junction temperature.

Get notification of temperature change.

Class: PhidgetTemperatureSensor
Package: com.phidgets
Extends: Phidget
Specialised class for PhdigetTemperatureSensor interaction
Properties
NumberOfTemperatureInputs:int [get] Returns the number of temperature inputs.
Please view the Phidget’s Product Manual to determine if functionality varies
from this document.
Phidget Temperature Sensor Methods
PhidgetTemperatureSensor.getPotential
Returns the current potential of the Thermocouple in volts.
Range is -0.0065 to 0.0550 milliVolts for a range of -260 °C to 1372 °C
Please view the Phidget’s Product Manual to determine if functionality varies from this document.
getPotential(index:int):Number
Input
index:int Index of the sensor to query
Output
return value:Number Current value of the Sensor's potential
PhidgetTemperatureSensor.getTemperature
Returns the current temperature in Celsius or Fahrenheit (depending on UseImperial property).
Index = 0 returns the temperature of the cold junction.
Index = 1 returns the temperatrue of the thermocouple.
Note that this value defaults to -500. Applications that do not wish to see this value should use Change Handlers instead of polling the
device for data.
Please view the Phidget’s Product Manual to determine if functionality varies from this document.
getTemperature(index:int):Number
Input
index:int Index of the sensor to query
Output
return value:Number Current temperature of the sensor
PhidgetTemperatureSensor.getTemperatureChangeTrigger
Gets the amount of change that should exist between the last reported value and the current value before an OnTemperatureChange
event is fired.
For additional information see the Appendix on Change Triggers.
getTemperatureChangeTrigger(index:int):Number
Input
index:int Index of the sensor to query for change trigger
Output
return value:Number Current value of the change trigger
PhidgetTemperatureSensor.setTemperatureChangeTrigger
Specifies the amount of change that should exist between the last reported value and the current value before an
OnTemperatureChange event is fired.
For addtional information see the Appendix on Change Triggers.
setTemperatureChangeTrigger(index:int, val:Number):void
Input
index:int Index of the sensor to set a change trigger on
val:Number New value for the change trigger
Phidget Temperature Sensor Events
com.phidgets.events.PhidgetDataEvent
onTemperatureChange
An event raised when the Temperature exceeds the Temperature Change Trigger threshold
PhidgetDataEvent ( PhidgetDataEvent.TEMPERATURE_CHANGE,
myPhidget:Phidget, temperature:Number, index:int)
Parameters
PhidgetDataEvent.TEMPERATURE_CHANGE The type of event being raised by the Phidget.
In this case a Temperature Change event
myPhidget:Phidget The Phidget object raising the event
temperature:Number The current value of the Temperature
inddex:int The index of the Temperature sensor raising the event
PhidgetTextLCD
The PhidgetTextLCD is a component that provides a high-level programmer interface to control a
PhidgetTextLCD device connected through a USB port.
With this component, the programmer can:
Display text on a PhidgetTextLCD module.

Class: PhidgetTextLCD
Package: com.phidgets
Extends: Phidget
Specialised calss for PhidgetTextLCS device interation
Properties
NumberOfRows:int [get] Returns number of rows of text that may be presented on the display.
NumberOfColumns:int [get] Returns number of columns of text that may be used on the display.
Backlight:Boolean [get/set] Determines if the backlight for this LCD is on or off.
Note that this defaults to True
Cursor:Boolean [get/set] Determines if the cursor is on or off.
Note that this defaults to False
CursorBlink:Boolean [get/set] Determines if the cursor's blinking is on or off.
Note that this defaults to False
Contrast:int [get/set] Gets the contrast value from 0-255.
Note that this defaults to 0
Phidget Text LCD Methods
PhidgetTextLCD.setDisplayString
Sets the text to display on a particular row of the display. The text will be clipped at the right edge of the display.
Please view the Phidget’s Product Manual to determine if functionality varies from this document.
setDisplayString(index:int, val:String):void
Input
index:int+ Row to set string to
val:String ASCII string to display
PhidgetTextLCD.setCustomCharacter
Sets a custom character.
With existing hardware, there is space for 8 custom characters : Index can range from 8 to 15.
Each character is described by a set of integers.
For more information, have a look at the TextLCD example in the examples.zip for Phidget21.
setCustomCharacter(index:int, val1:int, val2:int):void
Input
index:int Custom Character Index
val1:int Part 1 of Character Description Field
val2:int Part 2 of Character Description Field
The Phidget Dictionary
The Phidget Dictionary is a service provided by the Phidget Webservice. The Webservice maintains a
centralized dictionary of key-value pairs that can be accessed and changed from any number of clients through
the PhidgetDictionary object.
Note that the Webservice uses this dictionary to control access to Phidgets through the openRemoteIP
interface, and as such, you should never add or modify a key that starts with /PSK/ or /PCK/, unless you
want to explicitly modify Phidget specific data – and this is highly discouraged, as it’s very easy to break things.
Listening to these keys is fine if so desired.
The intended use for the dictionary is as a central repository for communication and persistent storage
of data between several client applications. As an example - a higher level interface exposed by one application
– which controls the Phidgets, for others to access – rather then every client talking directly to the Phidgets
themselves.
The dictionary makes use of extended regular expressions for key matching. See the end of this document
for the rules of regular expressions.
Class: PhidgetDictionary
Package: com.phidgets
Extends: EventDispatcher
Specialised class for interaction with the Phidget Dictionary webservice
Properties
ServerID:String [get] DNS Name of the Server
Port:int [get] Port of the Webservice running on the server
Address:String [get] IP Address of the Server
isConnected:Boolean [get] Whether the Phidget is physically connected or not
Phidget Dictionary Methods
PhidgetDictionary.open
Opens a connection to the Dictionary service on the specified webserver
open (address:String, port:Number, password:String):void
Input
address:string IP Address of the Server
port:Number Port of the Webservice running on the server
password:String Password to the Webservice
The Password may be empty if a password is not used on the webservice
PhidgetDictionary.close
Closes the file handles for this device. You should always call this when finished with a Dictionary.
close():void
PhidgetDictionary.addKey
Adds a new key to the Dictionary, or modifies the value of an existing key.
The key can only contain numbers, letters, ‘/’, ‘.’, ‘-‘, ‘_’, and must begin with a letter, ‘_’ or ‘/’.
The value can contain any value.
The persistent value controls whether a key will stay in the dictionary after the client that created it disconnects. If persistent == 0, the
key is removed when the connection closes. Otherwise the key remains in the dictionary until it is explicitly removed.
addKey(key:String, value:String, persistent:Boolean):void
Input
key:String Key Tag name
value:String Value of Key
persistent:Boolean Whether or not to keep the key in the Dictionary after session has
completed
This defaults to True
PhidgetDictionary.removeKey
Removes a key, or set of keys, from the Dictionary.
The key name is a regular expressions pattern, and so care must be taken to only have it match the specific keys you want to remove.
removeKey(pattern:String):void
Input
pattern:String A regular expression by which to match keys
Phidget Dictionary Events
flash.events.Event
com.phidgets.events.PhidgetEvent
com.phidgets.events.PhidgetErrorEvent
onConnected
An event raised by a PhidgetDictionary object when it has connected to a remote Dictionary Service, ie. after an Open request.
PhidgetDictionaryEvent (PhidgetDictionaryEvent.CONNECT,
myDictionary:PhidgetDictionary, key:String,
value:String )
Parameters
PhidgetDictionaryEvent.CONNECT The type of event being raised by the PhidgetDictionary object.
In this case a Connect event
myDictionary:PhidgetDictionary The PhidgetDictionary object raising the event.
key:String=null A string value containing a Key code.
value:String=null A string value containing a Key value.
onDisconnected
An event raised by a PhidgetDictionary object when it has been disconnected from the remote Dictionary Service
PhidgetDictionaryEvent (PhidgetDictionaryEvent.DISCONNECT,
myDictionary:PhidgetDictionary, key:String,
value:String)
Parameters
PhidgetDictionaryEvent.DISCONNECT The type of event being raised by the PhidgetDictionary object.
In this case a Disconnect event
myDictionary:PhidgetDictionary The PhidgetDictionary object raising the event.
key:String=null A string value containing a Key code.
value:String=null A string value containing a Key value.
onError
An event raised by a Phidget object when it encounters an error, either in the parameters of a request made to the object or an error
being raised by the Phidget device itself.
PhidgetErrorEvent (PhidgetErrorEvent.ERROR, myphidget:Phidget,
error:PhidgetError)
Parameters
PhidgetErrorEvent:ERROR The type of event raised by the Phidget. In this case an Error event
myphidget:Phidget The Phidget object that raised the event
error:PhidgetError The error code being raised. Corresponds to one of the PhidgetErrors
See the Appendices for a list of these error codes.
onKeyChange
An event raised by a PhidgetDictionary object when a Key it is monitoring is changed.
PhidgetDictionaryEvent (PhidgetDictionaryEvent.KEY_CHANGE,
myDictionary:PhidgetDictionary, key:String,
value:String)
Parameters
PhidgetDictionaryEvent.KEY_CHANGE The type of event being raised by the PhidgetDictionary object.
In this case a Key Change event
myDictionary:PhidgetDictionary The PhidgetDictionary object raising the event.
key:String=null A string value containing a Key code.
value:String=null A string value containing a Key value.
onKeyRemoval
An event raised by a PhidgetDictionary object when a key it is monitoring is Removed.
PhidgetDictionaryEvent (PhidgetDictionaryEvent.KEY_REMOVAL,
myDictionary:PhidgetDictionary, key:String,
value:String)
Parameters
PhidgetDictionaryEvent.KEY_REMOVAL The type of event being raised by the PhidgetDictionary object.
In this case a Key Removal event
myDictionary:PhidgetDictionary The PhidgetDictionary object raising the event.
key:String=null A string value containing a Key code.
value:String=null A string value containing a Key value.
The Phidget Manager
The Phidget manager is an interface that allows for monitoring of all phidgets connected to a system, without
opening them.
Class: PhidgetManager
Package: com.phidgets
Extends: EventDispatcher
Specialised class for device interaction via the Phidget Manager
Properties
ServerID:String [get] The DNS name of the server
Port:int [get] The Port of the Webservice running on the server
Address:String [get] Address of the server
isConnected:Boolean [get] Whether or not the phidget is physically connected
Phidget Manager Methods
PhidgetManager.open
Opens a connection to the local Phidget Manager.
The CPhidgetManagerHandle should be a valid handle previously allocated by CphidgetManager_create.
Before calling CPhidgetManager_open, we recommend registering the event handlers your application will use.
open (address:String, port:Number, password:String):void
Parameters
address:string IP Address of the Server
port:Number Port of the Webservice running on the Server
password:String Password for the Webservice
Password may be empty if a password is not used on the webservice
PhidgetManager.close
Closes a Phidget opened via PhidgetManager
close():void
Phidget Manager Events
flash.events.Event
com.phidgets.events.PhidgetManagerEvent
com.phidgets.events.PhidgetErrorEvent
onConnected
An event raised by the Phidget Manager when it has connected to a Server
PhidgetManagerEvent(PhidgetManagerEvent.CONNECT, myphidget:Phidget)
Parameters
PhidgetManagerEvent.DETACH The type of event raised by the Phidget.In this case a Connect event
myphidget:Phidget The Phidget object that raised the event
onDisconnected
An event raised by the Phidget Manager when it has disconnected from a Server
PhidgetManagerEvent(PhidgetManagerEvent.DISCONNECT, myphidget:Phidget)
Parameters
PhidgetManagerEvent.DISCONNECT The type of event raised by the Phidget.In this case a Disconnect event
myphidget:Phidget The Phidget object that raised the event
onError
An event raised by a Phidget object when it encounters an error, either in the parameters of a request made to the object or an error
being raised by the Phidget device itself.
PhidgetErrorEvent (PhidgetErrorEvent.ERROR, myphidget:Phidget,
error:PhidgetError)
Parameters
PhidgetErrorEvent:ERROR The type of event raised by the Phidget. In this case an Error event
myphidget:Phidget The Phidget object that raised the event
error:PhidgetError The error code being raised. Corresponds to one of the PhidgetErrors
See the Appendices for a list of these error codes.
onAttach
An event raised by the Phidget Manager when a Phidget Device is physically connected to the host machine
PhidgetManagerEvent(PhidgetManagerEvent.ATTACH, myphidget:Phidget)
Parameters
PhidgetManagerEvent.ATTACH The type of event raised by the Phidget.In this case an Attach event
myphidget:Phidget The Phidget object that raised the event
onDetach
An event raised by the Phidget Manager when a Phidget Device is physically disconnected from the host machine
PhidgetManagerEvent(PhidgetManagerEvent.DETACH, myphidget:Phidget)
Parameters
PhidgetManagerEvent.DETACH The type of event raised by the Phidget.
In this case an Detach event
myphidget:Phidget The Phidget object that raised the event
Appendix I: Regular Expressions

Regular Expressions are used with the Phidget Dictionary Object to perform Key Matching.They are a
powerful method for performing searchs that can vary from extremely specific to extremely general matches.
Please see the Examples for additional information on using the Dictionary object and Regular Expressions
(available on the Downloads page from http://Phidgets.com )
Definitions:
. Matches any single character. Into [ ] this character has its habitual meaning.
[ ] Matches a single character that is contained within the brackets. For example, [abc] matches "a", "b", or "c".
[a-z] matches any lowercase letter. These can be mixed: [abcq-z] matches a, b, c, q, r, s, t, u, v, w, x, y, z, and
so does [a-cq-z].
The '-' character should be literal only if it is the last or the first character within the brackets: [abc-] or [-abc].
To match an '[' or ']' character, the easiest way is to make sure the closing bracket is first in the enclosing
square brackets: [][ab] matches ']', '[', 'a' or 'b'.
[^ ] Matches a single character that is not contained within the brackets. For example, [^abc] matches any
character other than "a", "b", or "c". [^a-z] matches any single character that is not a lowercase letter. As
above, these can be mixed.
^ Matches the start of the line (or any line, when applied in multiline mode)
$ Matches the end of the line (or any line, when applied in multiline mode)
( ) Defines a "marked subexpression". What the enclosed expression matched can be recalled later. See
the next entry, \n. Note that a "marked subexpression" is also a "block". Note that this is not found in some
instances of regex.
\n Where n is a digit from 1 to 9; matches what the nth marked subexpression matched. This construct is
theoretically irregular and has not been adopted in the extended regular expression syntax.
* A single character expression followed by "*" matches zero or more copies of the expression. For example,
"[xyz]*" matches "", "x", "y", "zx", "zyx", and so on.
\n*, where n is a digit from 1 to 9, matches zero or more iterations of what the nth marked subexpression
matched. For example, "(a.)c\1*" matches "abcab" and "abcabab" but not "abcac".
An expression enclosed in "\(" and "\)" followed by "*" is deemed to be invalid. In some cases (e.g. /usr/
bin/xpg4/grep of SunOS 5.8), it matches zero or more iterations of the string that the enclosed expression
matches. In other cases (e.g. /usr/bin/grep of SunOS 5.8), it matches what the enclosed expression
matches, followed by a literal "*".
+ A single character expression followed by "+" matches one or more copies of the expression. For example,
"[xyz]+" matches "x", "y", "zx", "zyx", and so on.
\n+, where n is a digit from 1 to 9, matches one or more iterations of what the nth marked subexpression
matched.
An expression enclosed in "\(" and "\)" followed by "+" is deemed to be invalid.
{x,y} Match the last "block" at least x and not more than y times. For example, "a\{3,5\}" matches "aaa", "aaaa"
or "aaaaa". Note that this is not found in some instances of regex.
Extended Regular Expressions:
+ Match the last "block" one or more times - "ba+" matches "ba", "baa", "baaa" and so on
? Match the last "block" zero or one times - "ba?" matches "b" or "ba"
| The choice (or set union) operator: match either the expression before or the expression after the
operator - "abc|def" matches "abc" or "def".
Also, backslashes are removed: \{...\} becomes {...} and \(...\) becomes (...). Examples:
"[hc]+at" matches with "hat", "cat", "hhat", "chat", "hcat", "ccchat" etc.
"[hc]?at" matches "hat", "cat" and "at"
"([cC]at)|([dD]og)" matches "cat", "Cat", "dog" and "Dog"
Since the characters '(', ')', '[', ']', '.', '*', '?', '+', '^' and '$' are used as special symbols they have to be escaped
if they are meant literally. This is done by preceding them with '\' which therefore also has to be escaped this
way if meant literally. Examples:
"a\.(\(|\))" matches with the string "a.)" or "a.("
Appendix II: Error Codes and Descriptions
Error Code
Value
Error Description
PHIDGET_NOTFOUND
1
"A Phidget matching the type and or se
-
rial number could not be found."
This indicates that a Phidget being
searched for (ie. via Open) could not be
located.
PHIDGET_NOMEMORY
2
"Memory could not be allocated."
This indicates that there is not enough
memory for the Phidgets library to create
the object requested.
PHIDGET_UNEXPECTED
3
"Unexpected Error. Contact Phidgets Inc.
for support."
Indicates that a serious error has oc
-
curred, or a severe bug exists within the
library.
PHIDGET_INVALIDARG
4
"Invalid argument passed to function."
An argument is not valid to the require
-
ments of the function. In many cases this
refers to an invalid Phidget Handle.
PHIDGET_NOTATTACHED
5
"Phidget not physically attached."
Indicates the function requires an attached
Phidget to operate.
PHIDGET_INTERRUPTED
6
"Read/Write operation was interrupted"
An error occurred while attempting to com
-
municate with the Phidget over USB.
PHIDGET_INVALID
7
"The Error Code is not defined."
Indicates that a serious error has oc
-
curred, or a severe bug exists within the
library.
PHIDGET_NETWORK
8
"Network Error."
Attempting to communicate with the
Phidget via the Network has failed.
PHIDGET_UNKNOWNVAL
9
"Value is Unknown (State not yet received
from device)."
A query to a value on the Phidget device
has failed as the Phidget has not returned
data yet.
PHIDGET_BADPASSWORD
10
"Authorization Failed."
The remote access method has failed it’s
authorization.
PHIDGET_UNSUPPORTED
11
"Not Supported"
This is a bad or unsupported function call.
Error Code
Value
Error Description
PHIDGET_DUPLICATE
12
"Duplicated request"
A previous request to the device has al
-
ready performed this function, and it is not
valid to perform twice.
PHIDGET_TIMEOUT
13
"Given timeout has been exceeded"
A synchronous request has failed it’s time
limits. Usually this is returned when at
-
tempting WaitForConnect.
PHIDGET_OUTOFBOUNDS
14
"Index out of Bounds"
An index into the function is above or below
the recognized bounds of the device. ie.
when accessing a single sensor on a multi-
sensor device.
PHIDGET_EVENT
15
"A non-null error code was returned from
an event handler"
An error code was passed to a function
handler. Note that correct decoding of the
actual error would have to be done within
the event handler itself.
PHIDGET_NETWORK_NOTCONNECTED
16
"A connection to the server does not ex
-
ist."
An attempt to connect to a remotely con
-
nected device or service failed due to net
-
work connectivity problems.
PHIDGET_WRONGDEVICE
17
"Function is not applicable for this de
-
vice."
The wrong type of device handle was
passed as an argument to a function. (ie.
calling
CPhidgetWeightSensor_getWeight
with an Accelerometer handle)
Appendix III: Special Values
The Phidgets Library uses some special values internally to track things that are not de
-
fined in the Actionscript 3.0 language or applicable only to Phidget devices.
Group
Constant Name
Value
Description
Attachment State
PHIDGET_ATTACHED
0x1
The Phidget has been at
-
tached
PHIDGET_NOTATTACHED
0x0
The Phidget is not at
-
tached
PHIDGET_CONNECTIONERROR
0x2
The Phidget experienced
a connection error
Booleans
PFALSE
0x00
Evaluate as FALSE
PTRUE
0x01
Evaluate as TRUE
PUNK
0x02
Evaluate as UNKNOWN

Appendix IV: Event Handlers

Event Handlers are used to notify your application that a noteworthy event has occured
with a Phidget. By creating a function accepting the proper parameters (the Event Handler),
and registering that function with the library, the library is able to call your function whenever
events occur.
Because your Event Handler can be run at anytime, it's best to register them before
calling Phidget.open().
Event Handlers have to conform to a standard that the Phidget library understands. As
a minimum, all callbacks have a Phidget Object, and an Event Type as arguments.
The Phidget Object argument provides a link to the Phidget that raised the event. This
allows properties of the Phidget to be avaluated within the Callback.
The Event Type identifies the kind of event being fired, this allows the user to make a
choice of how to handle the event.
Setting up an Event Handler involves:
Setting up a Phidget object
1.
Creating a function to handle your event
2.
Passing the type of event to trigger on
3.
Passing the name of the function to call when
4.
Please see the Examples for additional information on using Event Handlers
(available on the Downloads page from http://Phidgets.com )
Event Handler Example
import com.phidgets.*;
import com.phidgets.events.*;
var blnInit;
var myPhidget:Phidget;
function onAttach(evt:PhidgetEvent):void{
trace(evt);
}
if (blnInit != true) {
trace('Performing Initialisation');
myPhidget= new PhidgetInterfaceKit();
myPhidget.addEventListener(PhidgetEvent.ATTACH, onAttach);
myPhidget.open("localhost", 5001);
blnInit = true;
}
Create Phidget
Object
Register Event
Handlers
Open Phidget
Device creates
attach event
Event Handler
fires
User function
performs
processing and
returns
Wait for
attach event
Appendix V: Change Triggers
Change Triggers are used to filter the
number of events that are returned to an
Application, by setting a minimum amount of
activity before a Change Event is sent to the
Client.
The Change Trigger routine uses 3 values.
i) The Last Reported (or default) value
is used as the reference point by which to
compare future values.
ii) The Last Reported value + & --- the
Change Trigger value provide the valid range
of values before a Change event is fired
iii) The Current Data value, is com
-
pared to the valid range of operation to de
-
termine whether a Change Event is fired
When each new data point is acquired by the Phidget, it must answer several questions:
i) Is the New Value > (Last Reported Value + Change Trigger)?
ii) Is the New Value < (Last Reported Value - Change Trigger)?
If either is True:
i) Reported Value is updated to the Current Data value
ii) Change Event is fired
Value
Time
Reported Value
Last Value +
Change Trigger
Change Event
Last Value –
Change Trigger
Actual Value
Appendix VII: Generating Custom Characters
This is only a simple example showing how to generate custom characters. For detailed information please see
your Phdget manual.
For an easy method to generate characters without the formula, visit
http://www.phidgets.com/documentation/customchar.html
Each Custom Character is comprised of two numbers; one for the top 4 rows of pixels, one for the bottom 4
rows of pixels.
They are evaluated as powers of 2 from the top right corner going left and continuing at the left side of each row.
Value 1 (Upper Half):
=2^1 + 2^2 + 2^3 + 2^5 + 2^6 + 2^7 + 2^8 + 2^9 + 2^10 + 2^12 + 2^14 + 2^15 + 2^16 + 2^17
+ 2^18 + 2^19
= 103818
Value 2 (Lower Half):
=2^0 + 2^2 + 2^4 + 2^5 + 2^9
+ 2^10 + 2^11 + 2^12 + 2^13 +
2^14 + 2^16 + 2^17 + 2^18
= 491061