예제 #1
0
    def _set_function(self, value):
        if value == 'input':
            if self.pwm_active:
                raise InputDeviceError('PWM Pin cannot be set to input')
            self._enable_gpio()
        elif value == 'pwm':
            if self.gpio_active:
                raise PinPWMUnsupported('GPIO Pin cannot be set to pwm')
            self._enable_pwm()
        elif self._active_pin() is None:
            self._enable_gpio()

        if value != 'input':
            self._poller.stop_polling()
        self._active_pin().set_function(value)