X-Git-Url: https://git.ayoreis.com/hackapet/Adafruit_Blinka.git/blobdiff_plain/4957fd7530674c6bbdd6324c9340ff5a4e1fbbc6..f7d33e4acfc4a1f6bdd5192bb44555928c01a179:/src/adafruit_blinka/microcontroller/rockchip/PWMOut.py diff --git a/src/adafruit_blinka/microcontroller/rockchip/PWMOut.py b/src/adafruit_blinka/microcontroller/rockchip/PWMOut.py index ae0f0ae..6de24f4 100644 --- a/src/adafruit_blinka/microcontroller/rockchip/PWMOut.py +++ b/src/adafruit_blinka/microcontroller/rockchip/PWMOut.py @@ -1,3 +1,9 @@ +""" +Much code from https://github.com/vsergeev/python-periphery/blob/master/periphery/pwm.py +Copyright (c) 2015-2016 vsergeev / Ivan (Vanya) A. Sergeev +License: MIT +""" + import os from time import sleep from errno import EACCES @@ -7,6 +13,8 @@ try: except ImportError: raise RuntimeError("No PWM outputs defined for this board.") from ImportError +# pylint: disable=unnecessary-pass + class PWMError(IOError): """Base class for PWM errors.""" @@ -14,6 +22,9 @@ class PWMError(IOError): pass +# pylint: enable=unnecessary-pass + + class PWMOut: """Pulse Width Modulation Output Class""" @@ -83,6 +94,9 @@ class PWMOut: self._chip_path, self._channel_path.format(self._channel) ) + if variable_frequency: + print("Variable Frequency is not supported, continuing without it...") + if not os.path.isdir(self._chip_path): raise LookupError("Opening PWM: PWM chip {} not found.".format(self._chip)) @@ -163,11 +177,11 @@ class PWMOut: # Methods def enable(self): - """Enable the PWM outout.""" + """Enable the PWM output.""" self.enabled = True def disable(self): - """Diable the PWM output.""" + """Disable the PWM output.""" self.enabled = False # Mutable properties @@ -183,11 +197,11 @@ class PWMOut: period = property(_get_period, _set_period) """Get or set the PWM's output period in seconds. - + Raises: PWMError: if an I/O or OS error occurs. TypeError: if value type is not int. - + :type: int, float """ @@ -201,11 +215,11 @@ class PWMOut: period_ms = property(_get_period_ms, _set_period_ms) """Get or set the PWM's output period in milliseconds. - + Raises: PWMError: if an I/O or OS error occurs. TypeError: if value type is not int. - + :type: int, float """ @@ -220,11 +234,11 @@ class PWMOut: period_us = property(_get_period_us, _set_period_us) """Get or set the PWM's output period in microseconds. - + Raises: PWMError: if an I/O or OS error occurs. TypeError: if value type is not int. - + :type: int """ @@ -252,11 +266,11 @@ class PWMOut: period_ns = property(_get_period_ns, _set_period_ns) """Get or set the PWM's output period in nanoseconds. - + Raises: PWMError: if an I/O or OS error occurs. TypeError: if value type is not int. - + :type: int """ @@ -280,11 +294,11 @@ class PWMOut: duty_cycle_ns = property(_get_duty_cycle_ns, _set_duty_cycle_ns) """Get or set the PWM's output duty cycle in nanoseconds. - + Raises: PWMError: if an I/O or OS error occurs. TypeError: if value type is not int. - + :type: int """