Ejemplo n.º 1
0
    def resetCompassCorrectionParameters(self):
        """Resets correction paramaters for the magnetometer triad. This returns magnetometer output to raw magnetic field strength.
        
        Exceptions:
            RuntimeError - If current platform is not supported/phidget c dll cannot be found
            PhidgetException: If this Phidget is not opened and attached.
        """
        try:
            result = PhidgetLibrary.getDll(
            ).CPhidgetSpatial_resetCompassCorrectionParameters(self.handle)
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
Ejemplo n.º 2
0
    def getDiscreteLED(self, index):
        """Deprecated: use getBrightness
        """
        ledVal = c_int()

        try:
            result = PhidgetLibrary.getDll().CPhidgetLED_getDiscreteLED(
                self.handle, c_int(index), byref(ledVal))
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
        else:
            return ledVal.value
Ejemplo n.º 3
0
    def getEncoderCount(self):
        """

        """
        encoderCount = c_int()

        try:
            result = PhidgetLibrary.getDll().CPhidgetMotorControl_getEncoderCount(self.handle, byref(encoderCount))
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
        else:
            return encoderCount.value
Ejemplo n.º 4
0
    def getEncoderPosition(self, index):
        """

        """
        encoderPosition = c_int()

        try:
            result = PhidgetLibrary.getDll().CPhidgetMotorControl_getEncoderPosition(self.handle, c_int(index), byref(encoderPosition))
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
        else:
            return encoderPosition.value
Ejemplo n.º 5
0
 def zeroGyro(self):
     """Zeroes the gyro.
     
     This takes 1-2 seconds to complete and should only be called when the board is stationary.
     
     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 Phidget does not have a gyro.
     """
     try:
         result = PhidgetLibrary.getDll().CPhidgetSpatial_zeroGyro(self.handle)
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
Ejemplo n.º 6
0
 def stop(self):
     """Stop this key listener.
     
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException: If this Dictionary is not opened.
     """
     try:
         result = PhidgetLibrary.getDll().CPhidgetDictionary_remove_OnKeyChange_Handler(self.__listenerHandle)
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
     
     self.__listenerHandle = None
Ejemplo n.º 7
0
    def closePhidget(self):
        """Closes this Phidget.
        
        This will shut down all threads dealing with this Phidget and you won't recieve any more events.
        
        Exceptions:
            RuntimeError - If current platform is not supported/phidget c dll cannot be found
            PhidgetException: If this Phidget is not opened.
        """
        try:
            result = PhidgetLibrary.getDll().CPhidget_close(self.handle)
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
Ejemplo n.º 8
0
    def disableLogging():
        """Turns off logging in the native C Library.
        
        This only needs to be called if enableLogging was called to turn logging on.
        This will turn logging back off.
        
        Exceptions:
            RuntimeError - If current platform is not supported/phidget c dll cannot be found
            PhidgetException
        """
        try:
            result = PhidgetLibrary.getDll().CPhidget_disableLogging()
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
Ejemplo n.º 9
0
Archivo: IR.py Proyecto: Jak23/modular
 def transmitRepeat(self):
     """Transmits a repeat of a previously transmitted code.
     
     his must be called within the gap period after transmitting the original code.
     This is required for codes that use seperate sequences for the code and the repeat identifier.
     
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException: If this Phidget is not opened and attached.
     """
     try:
         result = PhidgetLibrary.getDll().CPhidgetIR_TransmitRepeat(self.handle)
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
Ejemplo n.º 10
0
    def closeManager(self):
        """Shuts down the Phidget Manager.
        
        This method should be called to close down the Phidget Manager.
        Events will no longer be recieved. This method gets calledd automatically when the class is destroyed so calling it is not required.
        
        Exceptions:
            RuntimeError - If current platform is not supported/phidget c dll cannot be found
            PhidgetException: If this manager is not opened.
        """
        try:
            result = PhidgetLibrary.getDll().CPhidgetManager_close(self.handle)
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
Ejemplo n.º 11
0
    def setBraking(self, index, braking):
        """

        Parameters:
            braking<double>: 

        Exceptions:
            RuntimeError - If current platform is not supported/phidget c dll cannot be found
            PhidgetException: If this Phidget is not opened and attached, the supplied index is out of range, or if this Motor Controller does not support braking.
        """
        try:
            result = PhidgetLibrary.getDll().CPhidgetMotorControl_setBraking(self.handle, c_int(index), c_double(braking))
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
Ejemplo n.º 12
0
    def __init__(self):
        """The Constructor Method for the Manager Class
        
        Exceptions:
            RuntimeError - If current platform is not supported/phidget c dll cannot be found
            PhidgetException: If this Phidget is not opened.
        """

        self.handle = c_void_p()

        self.__attach = None
        self.__detach = None
        self.__error = None
        self.__serverConnect = None
        self.__serverDisconnect = None

        self.__onAttach = None
        self.__onDetach = None
        self.__onError = None
        self.__onServerConnect = None
        self.__onServerDisconnect = None

        if sys.platform == 'win32':
            self.__ATTACHHANDLER = WINFUNCTYPE(c_int, c_void_p, c_void_p)
            self.__DETACHHANDLER = WINFUNCTYPE(c_int, c_void_p, c_void_p)
            self.__ERRORHANDLER = WINFUNCTYPE(c_int, c_void_p, c_void_p, c_int,
                                              c_char_p)
            self.__SERVERATTACHHANDLER = WINFUNCTYPE(c_int, c_void_p, c_void_p)
            self.__SERVERDETACHHANDLER = WINFUNCTYPE(c_int, c_void_p, c_void_p)
        elif sys.platform == 'darwin' or sys.platform == 'linux2':
            self.__ATTACHHANDLER = CFUNCTYPE(c_int, c_void_p, c_void_p)
            self.__DETACHHANDLER = CFUNCTYPE(c_int, c_void_p, c_void_p)
            self.__ERRORHANDLER = CFUNCTYPE(c_int, c_void_p, c_void_p, c_int,
                                            c_char_p)
            self.__SERVERATTACHHANDLER = CFUNCTYPE(c_int, c_void_p, c_void_p)
            self.__SERVERDETACHHANDLER = CFUNCTYPE(c_int, c_void_p, c_void_p)

        try:
            result = PhidgetLibrary.getDll().CPhidgetManager_create(
                byref(self.handle))
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
Ejemplo n.º 13
0
    def getBraking(self, index):
        """

        Exceptions:
            RuntimeError - If current platform is not supported/phidget c dll cannot be found
            PhidgetException: If this Phidget is not opened and attached, the supplied index is out of range, or if this motor controller does not support braking.
        """
        braking = c_double()

        try:
            result = PhidgetLibrary.getDll().CPhidgetMotorControl_getBraking(self.handle, c_int(index), byref(braking))
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
        else:
            return braking.value
Ejemplo n.º 14
0
 def setServoType(self, index, servoType):
     """Sets the desired servo type for a specified motor.
     
     Parameters:
         index<int>: index of a servo motor.
         servoType<int>: The desired servo type for the motor.
     
     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().CPhidgetAdvancedServo_setServoType(self.handle, c_int(index), c_int(servoType))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
Ejemplo n.º 15
0
    def getBackEMF(self, index):
        """

        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 this Phidget does not support this feature.
        """
        voltage = c_double()

        try:
            result = PhidgetLibrary.getDll().CPhidgetMotorControl_getBackEMF(self.handle, c_int(index), byref(voltage))
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
        else:
            return voltage.value
Ejemplo n.º 16
0
    def openManager(self):
        """Starts the PhidgetManager.
        
        This method starts the phidget manager running in the base Phidget21 C library.
        If attach and detach listeners are to be used, they should be registered before start is called so that no events are missed.
        Once start is called, the Phidget Manager will be active until close is called.
        
        Exceptions:
            RuntimeError - If current platform is not supported/phidget c dll cannot be found
            PhidgetException
        """
        try:
            result = PhidgetLibrary.getDll().CPhidgetManager_open(self.handle)
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
Ejemplo n.º 17
0
 def getDataRateMin(self):
     """Gets the minimum supported data rate in ms.
     
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException: If this Phidget is not opened and attached.
     """
     dataRateMin = c_int()
     
     try:
         result = PhidgetLibrary.getDll().CPhidgetSpatial_getDataRateMin(self.handle, byref(dataRateMin))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
     else:
         return dataRateMin.value
Ejemplo n.º 18
0
 def setPositionMin(self, index, value):
     """Sets the minimum position of a servo motor.
     
     Parameters:
         index<int>: index of the motor.
         position<double>: desired minimum position limit for the motor.
     
     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 or position is out of range,
         or if the desired minimum position limit is out of range, or if the motor is not engaged.
     """
     try:
         result = PhidgetLibrary.getDll().CPhidgetAdvancedServo_setPositionMin(self.handle, c_int(index), c_double(value))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
Ejemplo n.º 19
0
    def setVoltage(self, index, voltage):
        """Sets the desired voltage for the specified analog output.

        Parameters:
            index<int>: index of the analog output
            voltage<double>: desired voltage level to set the output to

        Exceptions:
            RuntimeError - If current platform is not supported/phidget c dll cannot be found
            PhidgetException: If this Phidget is not opened and attached, if the index is out of range, or if the voltage level specified is out of range.
        """
        try:
            result = PhidgetLibrary.getDll().CPhidgetAnalog_setVoltage(
                self.handle, c_int(index), c_double(voltage))
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
Ejemplo n.º 20
0
 def setPHChangeTrigger(self, value):
     """Sets the pH change trigger.
     
     This is how much the pH much change between successive PHChangeEvents. By default this value is set to 0.05.
     
     Parameters:
         value<double>: The requested pH change trigger value.
     
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException: If this Phidget is not opened and attached, or the trigger value is out of range.
     """
     try:
         result = PhidgetLibrary.getDll().CPhidgetPHSensor_setPHChangeTrigger(self.handle, c_double(value))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
Ejemplo n.º 21
0
 def setDataRate(self, index, value):
     """
     Sets the maximum rate at which events will be fired, in ms.
     
     Parameters:
         index<int>: Index of the sensor.
         value<int>: The desired Data Rate Value.
     
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException: If this Phidget is not opened and attached, if the index is out of range, or the supplied data rate value is out of range.
     """
     try:
         result = PhidgetLibrary.getDll().CPhidgetInterfaceKit_setDataRate(self.handle, c_int(index), c_int(value))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
Ejemplo n.º 22
0
 def setDataRate(self, value):
     """Sets the event data rate in ms.
     
     Data rate needs to be between DataRateMin and DataRateMax.
     
     Parameters:
         value<int>: The desired event data rate value, in ms.
         
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException: If this Phidget is not opened and attached, or the data rate is out of range.
     """
     try:
         result = PhidgetLibrary.getDll().CPhidgetSpatial_setDataRate(self.handle, c_int(value))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
Ejemplo n.º 23
0
    def reset(self, index):
        """Resets the TotalCount and TotalTime counters to 0 for the specified channel.

        For best performance, this should be called when the channel is disabled.

        Parameters:
            index<int>: index of the frequency input channel

        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().CPhidgetFrequencyCounter_reset(self.handle, c_int(index))
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
Ejemplo n.º 24
0
    def getPositionFixStatus(self):
        """

        """
        positionFixStatus = c_int()

        try:
            result = PhidgetLibrary.getDll().CPhidgetGPS_getPositionFixStatus(
                self.handle, byref(positionFixStatus))
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
        else:
            if positionFixStatus.value == 1:
                return True
            else:
                return False
Ejemplo n.º 25
0
 def removeKey(self, pattern):
     """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.
     
     Parameters:
         pattern<string>: The regular expression pattern to match to the keys you want to remove from the Dictionary.
     
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException: if the Phidget Webservice cannot be contacted
     """
     try:
         result = PhidgetLibrary.getDll().CPhidgetDictionary_removeKey(self.handle, c_char_p(pattern))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
Ejemplo n.º 26
0
    def setScreenSize(self, screenSize):
        """Sets the active screen size.

        Only supported on the TextLCD Adapter.

        Parameters:
            screenIndex<int/TextLCD_ScreenSize>: The desired active screen index.

        Exceptions:
            RuntimeError - If current platform is not supported/phidget c dll cannot be found
            PhidgetException: If this Phidget is not opened and attached.
        """
        try:
            result = PhidgetLibrary.getDll().CPhidgetTextLCD_setScreenSize(self.handle, c_int(screenSize))
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
Ejemplo n.º 27
0
    def setScreenIndex(self, screenIndex):
        """Sets the active screen.

        This is the screen that all subsequent API calls will apply to.

        Parameters:
            screenIndex<int>: The desired active screen index.

        Exceptions:
            RuntimeError - If current platform is not supported/phidget c dll cannot be found
            PhidgetException: If this Phidget is not opened and attached.
        """
        try:
            result = PhidgetLibrary.getDll().CPhidgetTextLCD_setScreen(self.handle, c_int(screenIndex))
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
Ejemplo n.º 28
0
 def setBrightness(self, value):
     """Sets the brightness of the display.
     
     For devices that support a range of backlight brightnesses.
     The valid range is 0-255.
     
     Parameters:
         value<int>: the desired brightness value.
     
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException: If this Phidget is not opened and attached.
     """
     try:
         result = PhidgetLibrary.getDll().CPhidgetTextLCD_setBrightness(self.handle, c_int(value))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
Ejemplo n.º 29
0
 def setContrast(self, value):
     """Sets the contrast of the display.
     
     The valid range is 0-255.
     Changing the contrast can increase the readability of the display in certain viewing situation, such as at an odd angle.
     
     Parameters:
         value<int>: the desired contrast value.
     
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException: If this Phidget is not opened and attached.
     """
     try:
         result = PhidgetLibrary.getDll().CPhidgetTextLCD_setContrast(self.handle, c_int(value))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
Ejemplo n.º 30
0
    def setGain(self, index, gain):
        """Sets the gain for a selected bridge.
        Supported gains are 8, 16, 32, 64, 128, or no gain.
        Note that increasing the gains will reduce the measurable voltage difference by the gain factor, with +-1000mV/V being the maximum, with no gain.

        Parameters:
            index<int>: index of the Bridge input
            gain<int/BridgeGain>: desired gain to set the input to

        Exceptions:
            RuntimeError - If current platform is not supported/phidget c dll cannot be found
            PhidgetException: If this Phidget is not opened and attached, if the index is out of range, or if the gain specified is out of range.
        """
        try:
            result = PhidgetLibrary.getDll().CPhidgetBridge_setGain(self.handle, c_int(index), c_int(gain))
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)