예제 #1
0
 def getAcceleration(self, index):
     """Returns the acceleration of a particular axis.
     
     This value is returned in g's, where one g of acceleration is equal to gravity.
     This means that at a standstill each axis will measure between -1.0 and 1.0 g's depending on orientation.
     
     This value will always be between getAccelerationMin and getAccelerationMax.
     
     Index 0 is the x-axis, 1 is the y-axis, and 2 is the z-axis (where available).
     
     Parameters:
         index<int>: index of the axis.
     
     Returns:
         Acceleration of the selected axis <double>
     
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException: If this Phidget is not opened and attached, or if the index is out of range.
     """
     value = c_double()
     
     try:
         result = PhidgetLibrary.getDll().CPhidgetAccelerometer_getAcceleration(self.handle, c_int(index), byref(value))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
     else:
         return value.value
예제 #2
0
 def setOnAccelerationChangeHandler(self, accelChangeHandler):
     """Sets the acceleration change event handler.
     
     The acceleration change handler is a method that will be called when the acceleration of an axis has changed by at least the ChangeTrigger that has been set for that axis.
     
     Parameters:
         accelChangeHandler: hook to the accelChangeHandler callback function.
     
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException
     """
     if accelChangeHandler == None:
         self.__accelChange = None
         self.__onAccelChange = None
     else:
         self.__accelChange = accelChangeHandler
         self.__onAccelChange = self.__ACCELCHANGEHANDLER(self.__nativeAccelerationChangeEvent)
     
     try:
         result = PhidgetLibrary.getDll().CPhidgetAccelerometer_set_OnAccelerationChange_Handler(self.handle, self.__onAccelChange, None)
     except RuntimeError:
         self.__accelChange = None
         self.__onAccelChange = None
         raise
     
     if result > 0:
         raise PhidgetException(result)
예제 #3
0
 def getAccelChangeTrigger(self, index):
     """Returns the change trigger for an Axis.
     
     This value is in g's and is by default set to 0.
     
     Parameters:
         index<int>: index of the axis.
     
     Returns:
         The change trigger of the selected axis <double>.
     
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException: If this Phidget is not opened and attached, or if the index is out of range.
     """
     sensitivity = c_double()
     
     try:
         result = PhidgetLibrary.getDll().CPhidgetAccelerometer_getAccelerationChangeTrigger(self.handle, c_int(index), byref(sensitivity))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
     else:
         return sensitivity.value
예제 #4
0
 def setAccelChangeTrigger(self, index, sensitivity):
     """Sets the change trigger for an Axis.
     
     This value is in g's and is by default set to 0.
     This is the difference in acceleration that must appear between succesive calls to the OnAccelerationChange event handler.
     
     Parameters:
         index<int>: index of the axis.
         sensitivity<double>: the new change trigger for this axis.
     
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException: If this Phidget is not opened and attached, or if the index is out of range.
     """
     try:
         result = PhidgetLibrary.getDll().CPhidgetAccelerometer_setAccelerationChangeTrigger(self.handle, c_int(index), c_double(sensitivity))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
예제 #5
0
 def getAxisCount(self):
     """Returns the number of accelerometer axes.
     
     Currently all accelerometers provide two or three axes of acceleration - x, y, (and z).
     
     Returns:
         The number of Available Axes <int>.
     
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException: If this phidget is not opened or attached.
     """
     axisCount = c_int()
     try:
         result = PhidgetLibrary.getDll().CPhidgetAccelerometer_getAxisCount(self.handle, byref(axisCount))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
     else:
         return axisCount.value
예제 #6
0
 def getAccelerationMax(self, index):
     """Returns the maximum acceleration value that this axis will report.
     
     This will be set to just higher then the maximum acceleration that this axis can measure.
     If the acceleration is equal to this maximum, assume that that axis is saturated beyond what it can measure.
     
     Returns:
         The Maximum Accelration <double>.
     
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException: If this Phidget is not opened and attached, or if the index is out of range.
     """
     value = c_double()
     
     try:
         result = PhidgetLibrary.getDll().CPhidgetAccelerometer_getAccelerationMax(self.handle, c_int(index), byref(value))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
     else:
         return value.value