aboutsummaryrefslogtreecommitdiffstats
path: root/cphidgetinterfacekit.h
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2012-04-14 12:56:48 +0100
committerJonathan McCrohan <jmccrohan@gmail.com>2012-04-14 12:56:48 +0100
commit0b624384cd52be20e61284551d832b499d7b7707 (patch)
tree6f95a4bbef47abc9720b96c0722e8f632aef228a /cphidgetinterfacekit.h
downloadlibphidget21-0b624384cd52be20e61284551d832b499d7b7707.tar.gz
Imported Upstream version 2.1.8.20120216upstream/2.1.8.20120216
Diffstat (limited to '')
-rw-r--r--cphidgetinterfacekit.h219
1 files changed, 219 insertions, 0 deletions
diff --git a/cphidgetinterfacekit.h b/cphidgetinterfacekit.h
new file mode 100644
index 0000000..b4024cf
--- /dev/null
+++ b/cphidgetinterfacekit.h
@@ -0,0 +1,219 @@
+#ifndef __CPHIDGETINTERFACEKIT
+#define __CPHIDGETINTERFACEKIT
+#include "cphidget.h"
+
+/** \defgroup phidifkit Phidget InterfaceKit
+ * \ingroup phidgets
+ * Calls specific to the Phidget InterfaceKit. See the product manual for more specific API details, supported functionality, units, etc.
+ * @{
+ */
+
+DPHANDLE(InterfaceKit)
+CHDRSTANDARD(InterfaceKit)
+
+/**
+ * Gets the number of digital inputs supported by this board.
+ * @param phid An attached phidget interface kit handle.
+ * @param count The ditial input count.
+ */
+CHDRGET(InterfaceKit, InputCount, int *count)
+/**
+ * Gets the state of a digital input.
+ * @param phid An attached phidget interface kit handle.
+ * @param index The input index.
+ * @param inputState The input state. Possible values are \ref PTRUE and \ref PFALSE.
+ */
+CHDRGETINDEX(InterfaceKit, InputState, int *inputState)
+/**
+ * Set a digital input change handler. This is called when a digital input changes.
+ * @param phid An attached phidget interface kit handle.
+ * @param fptr Callback function pointer.
+ * @param userPtr A pointer for use by the user - this value is passed back into the callback function.
+ */
+CHDREVENTINDEX(InterfaceKit, InputChange, int inputState)
+
+/**
+ * Gets the number of digital outputs supported by this board.
+ * @param phid An attached phidget interface kit handle.
+ * @param count The output count.
+ */
+CHDRGET(InterfaceKit, OutputCount, int *count)
+/**
+ * Gets the state of a digital output.
+ * @param phid An attached phidget interface kit handle.
+ * @param index The output index.
+ * @param outputState The output state. Possible values are \ref PTRUE and \ref PFALSE.
+ */
+CHDRGETINDEX(InterfaceKit, OutputState, int *outputState)
+/**
+ * Sets the state of a digital output.
+ * @param phid An attached phidget interface kit handle.
+ * @param index The otuput index.
+ * @param outputState The output state. Possible values are \ref PTRUE and \ref PFALSE.
+ */
+CHDRSETINDEX(InterfaceKit, OutputState, int outputState)
+/**
+ * Set a digital output change handler. This is called when a digital output changes.
+ * @param phid An attached phidget interface kit handle.
+ * @param fptr Callback function pointer.
+ * @param userPtr A pointer for use by the user - this value is passed back into the callback function.
+ */
+CHDREVENTINDEX(InterfaceKit, OutputChange, int outputState)
+
+/**
+ * Gets the number of sensor (analog) inputs supported by this board.
+ * @param phid An attached phidget interface kit handle.
+ * @param count The sensor input count.
+ */
+CHDRGET(InterfaceKit, SensorCount, int *count)
+/**
+ * Gets a sensor value (0-1000).
+ * @param phid An attached phidget interface kit handle.
+ * @param index The sensor index.
+ * @param sensorValue The sensor value.
+ */
+CHDRGETINDEX(InterfaceKit, SensorValue, int *sensorValue)
+/**
+ * Gets a sensor raw value (12-bit).
+ * @param phid An attached phidget interface kit handle.
+ * @param index The sensor index.
+ * @param sensorRawValue The sensor value.
+ */
+CHDRGETINDEX(InterfaceKit, SensorRawValue, int *sensorRawValue)
+/**
+ * Set a sensor change handler. This is called when a sensor value changes by more then the change trigger.
+ * @param phid An attached phidget interface kit handle.
+ * @param fptr Callback function pointer.
+ * @param userPtr A pointer for use by the user - this value is passed back into the callback function.
+ */
+CHDREVENTINDEX(InterfaceKit, SensorChange, int sensorValue)
+/**
+ * Gets a sensor change trigger.
+ * @param phid An attached phidget interface kit handle.
+ * @param index The sensor index.
+ * @param trigger The change trigger.
+ */
+CHDRGETINDEX(InterfaceKit, SensorChangeTrigger, int *trigger)
+/**
+ * Sets a sensor change trigger.
+ * @param phid An attached phidget interface kit handle.
+ * @param index The sensor index.
+ * @param trigger The change trigger.
+ */
+CHDRSETINDEX(InterfaceKit, SensorChangeTrigger, int trigger)
+/**
+ * Gets the ratiometric state for this board.
+ * @param phid An attached phidget interface kit handle.
+ * @param ratiometric The ratiometric state. Possible values are \ref PTRUE and \ref PFALSE.
+ */
+CHDRGET(InterfaceKit, Ratiometric, int *ratiometric)
+/**
+ * Sets the ratiometric state for this board.
+ * @param phid An attached phidget interface kit handle.
+ * @param ratiometric The ratiometric state. Possible values are \ref PTRUE and \ref PFALSE.
+ */
+CHDRSET(InterfaceKit, Ratiometric, int ratiometric)
+
+//This is the event rate
+//since we're not going to run an extra thread, the accuracy of the data rate is limited by the interrupt endpoint data rate (>=8ms)
+/**
+ * Gets the Data Rate for an analog input.
+ * @param phid An attached phidget interface kit handle.
+ * @param index The sensor index.
+ * @param milliseconds Data rate in ms.
+ */
+CHDRGETINDEX(InterfaceKit, DataRate, int *milliseconds)
+/**
+ * Sets the Data Rate for an analog input.
+ * @param phid An attached phidget interface kit handle.
+ * @param index The sensor index.
+ * @param milliseconds Data rate in ms.
+ */
+CHDRSETINDEX(InterfaceKit, DataRate, int milliseconds)
+/**
+ * Gets the maximum supported data rate for an analog input
+ * @param phid An attached phidget interface kit handle.
+ * @param index The sensor index.
+ * @param max Data rate in ms.
+ */
+CHDRGETINDEX(InterfaceKit, DataRateMax, int *max)
+/**
+ * Gets the minimum supported data rate for an analog input
+ * @param phid An attached phidget interface kit handle.
+ * @param index The sensor index.
+ * @param min Data rate in ms.
+ */
+CHDRGETINDEX(InterfaceKit, DataRateMin, int *min)
+
+#ifndef REMOVE_DEPRECATED
+DEP_CHDRGET("Deprecated - use CPhidgetInterfaceKit_getInputCount",InterfaceKit, NumInputs, int *)
+DEP_CHDRGET("Deprecated - use CPhidgetInterfaceKit_getOutputCount",InterfaceKit, NumOutputs, int *)
+DEP_CHDRGET("Deprecated - use CPhidgetInterfaceKit_getSensorCount",InterfaceKit, NumSensors, int *)
+#endif
+
+#ifndef EXTERNALPROTO
+#define IFKIT_MAXINPUTS 32
+#define IFKIT_MAXOUTPUTS 32
+#define IFKIT_MAXSENSORS 8
+
+#define IFKIT_MAXSENSORCHANGE 1000 //BL: Had to check for this, might as well use a define
+
+//usually it is <=8, but could be bigger if a packet gets missed.
+#define IFKIT_MAX_DATA_PER_PACKET 16
+//in milliseconds - this is the fastest hardware rate of any device
+#define IFKIT_MAX_DATA_RATE 1
+//1 second is the longest between events that we support
+#define IFKIT_MIN_DATA_RATE 1000
+//add 200ms for timing differences (late events, etc) - should be plenty
+#define IFKIT_DATA_BUFFER_SIZE ((IFKIT_MIN_DATA_RATE + 200)/IFKIT_MAX_DATA_RATE)
+
+struct _CPhidgetInterfaceKit {
+ CPhidget phid;
+
+ int (CCONV *fptrOutputChange)(CPhidgetInterfaceKitHandle, void *, int, int);
+ int (CCONV *fptrInputChange)(CPhidgetInterfaceKitHandle, void *, int, int);
+ int (CCONV *fptrSensorChange)(CPhidgetInterfaceKitHandle, void *, int, int);
+
+ void *fptrOutputChangeptr;
+ void *fptrInputChangeptr;
+ void *fptrSensorChangeptr;
+
+ unsigned char ratiometric;
+ unsigned char ratiometricEcho;
+ unsigned char ratiometricSwitching;
+
+ // output fields all protected by outputLock
+ unsigned char outputStates[IFKIT_MAXOUTPUTS];
+ unsigned char nextOutputStates[IFKIT_MAXOUTPUTS];
+ unsigned char changedOutputs[IFKIT_MAXOUTPUTS];
+ int lastChangedOutput;
+
+ unsigned char outputEchoStates[IFKIT_MAXOUTPUTS]; // Values returned from the device
+ unsigned char physicalState[IFKIT_MAXINPUTS];
+
+ int sensorChangeTrigger[IFKIT_MAXSENSORS];
+ int sensorRawValue[IFKIT_MAXSENSORS];
+ int sensorValue[IFKIT_MAXSENSORS];
+ int sensorLastValue[IFKIT_MAXSENSORS];
+
+ int sensorRawValueAccumulator[IFKIT_MAXSENSORS];
+ int sensorRawValueAccumulatorCount[IFKIT_MAXSENSORS];
+
+ int dataRate[IFKIT_MAXSENSORS];
+ int interruptRate;
+ int dataRateMax, dataRateMin;
+
+ int lastPacketCount;
+ int maxDataPerPacket;
+
+ int dataSinceAttach;
+
+ CPhidget_EventMode eventMode[IFKIT_MAXSENSORS];
+
+ unsigned char fullStateEcho;
+} typedef CPhidgetInterfaceKitInfo;
+#endif
+
+/** @} */
+
+#endif