X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/blobdiff_plain/8fe9bc8bda76d6f0202ae5aacc7dab6d103f89fc..f24cd41e8d3dd8bd9e752fc450fff2d01afe1092:/src/adafruit_blinka/microcontroller/generic_linux/sysfs_pwmout.py diff --git a/src/adafruit_blinka/microcontroller/generic_linux/sysfs_pwmout.py b/src/adafruit_blinka/microcontroller/generic_linux/sysfs_pwmout.py index de663e9..3ce2ee3 100644 --- a/src/adafruit_blinka/microcontroller/generic_linux/sysfs_pwmout.py +++ b/src/adafruit_blinka/microcontroller/generic_linux/sysfs_pwmout.py @@ -90,12 +90,12 @@ class PWMOut(object): except IOError as e: raise PWMError(e.errno, "Exporting PWM pin: " + e.strerror) - self._set_enabled(False) + #self._set_enabled(False) # This line causes a write error when trying to enable # Look up the period, for fast duty cycle updates self._period = self._get_period() - self.duty_cycle = 0 + #self.duty_cycle = 0 # This line causes a write error when trying to enable # set frequency self.frequency = freq @@ -118,7 +118,15 @@ class PWMOut(object): self._channel = None self._pwmpin = None + def _is_deinited(self): + if self._pwmpin is None: + raise ValueError("Object has been deinitialize and can no longer " + "be used. Create a new object.") + def _write_pin_attr(self, attr, value): + # Make sure the pin is active + self._is_deinited() + path = os.path.join( self._sysfs_path, self._channel_path.format(self._channel), @@ -130,6 +138,9 @@ class PWMOut(object): f_attr.write(value + "\n") def _read_pin_attr(self, attr): + # Make sure the pin is active + self._is_deinited() + path = os.path.join( self._sysfs_path, self._channel_path.format(self._channel),