X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/blobdiff_plain/98f4a4378478d11e514acd7ff22a9c674f3cbca3..b64fb9de3dc4ee8acd64d47f0e747a3301bb09a3:/src/adafruit_blinka/microcontroller/nxp_lpc4330/pwmout.py diff --git a/src/adafruit_blinka/microcontroller/nxp_lpc4330/pwmout.py b/src/adafruit_blinka/microcontroller/nxp_lpc4330/pwmout.py index 08a31b7..01bdb42 100644 --- a/src/adafruit_blinka/microcontroller/nxp_lpc4330/pwmout.py +++ b/src/adafruit_blinka/microcontroller/nxp_lpc4330/pwmout.py @@ -14,6 +14,7 @@ from microcontroller.pin import Pin # pylint: disable=unnecessary-pass class PWMError(IOError): """Base class for PWM errors.""" + pass @@ -125,7 +126,6 @@ class PWMOut: period = property(_get_period, _set_period) - def _get_duty_cycle(self): """Get or set the PWM's output duty cycle as a ratio from 0.0 to 1.0. @@ -146,12 +146,14 @@ class PWMOut: if isinstance(duty_cycle, int): duty_cycle /= 65535.0 if not 0.0 <= duty_cycle <= 1.0: - raise ValueError("Invalid duty cycle value, should be between 0.0 and 1.0.") - + raise ValueError("Invalid duty cycle value, should be between 0.0 and 1.0.") + # Generate a pattern for 1024 samples of the duty cycle pattern = [(1 << self._channel)] * round(PWMOut.MAX_CYCLE_LEVEL * duty_cycle) - pattern += [(0 << self._channel)] * round(PWMOut.MAX_CYCLE_LEVEL * (1.0 - duty_cycle)) - + pattern += [(0 << self._channel)] * round( + PWMOut.MAX_CYCLE_LEVEL * (1.0 - duty_cycle) + ) + self._pattern = pattern self._duty_cycle = duty_cycle if self._enable: