X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/blobdiff_plain/f24cd41e8d3dd8bd9e752fc450fff2d01afe1092..c4584b61465986a4adf80121be18eb33d4afc2c3:/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 3ce2ee3..fa72667 100644 --- a/src/adafruit_blinka/microcontroller/generic_linux/sysfs_pwmout.py +++ b/src/adafruit_blinka/microcontroller/generic_linux/sysfs_pwmout.py @@ -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)