]> Repositories - Adafruit_Blinka-hackapet.git/blobdiff - src/adafruit_blinka/microcontroller/generic_linux/sysfs_pwmout.py
Merge pull request #136 from makermelissa/master
[Adafruit_Blinka-hackapet.git] / src / adafruit_blinka / microcontroller / generic_linux / sysfs_pwmout.py
index 3ce2ee3a195f2f1f3b26fb35b2af5976c9905bf6..fa7266710cbec98c61b5772757e11a29f0a5437c 100644 (file)
@@ -153,8 +153,9 @@ class PWMOut(object):
     # Mutable properties
 
     def _get_period(self):
+        period_ns = self._read_pin_attr(self._pin_period_path)
         try:
-            period_ns = int(self._read_pin_attr(self._pin_period_path))
+            period_ns = int(period_ns)
         except ValueError:
             raise PWMError(None, "Unknown period value: \"%s\"" % period_ns)
 
@@ -178,6 +179,8 @@ class PWMOut(object):
         # Update our cached period
         self._period = float(period)
 
+    period = property(_get_period, _set_period)
+
     """Get or set the PWM's output period in seconds.
 
     Raises:
@@ -188,8 +191,9 @@ class PWMOut(object):
     """
 
     def _get_duty_cycle(self):
+        duty_cycle_ns = self._read_pin_attr(self._pin_duty_cycle_path)
         try:
-            duty_cycle_ns = int(self._read_pin_attr(self._pin_duty_cycle_path))
+            duty_cycle_ns = int(duty_cycle_ns)
         except ValueError:
             raise PWMError(None, "Unknown duty cycle value: \"%s\"" % duty_cycle_ns)