| | |
- __builtin__.object
-
- BasePWM
class BasePWM(__builtin__.object) |
| |
A class for creating PWM type peripherals.
BasePWM implements methods to interact with a PWM interface. Platforms are
expected to subclass BasePWM and provide platform specific implementations of
_enable, _disable, _set_duty_cycle, and _set_frequency_hz.
Attributes:
_enabled: Boolean. Whether or not the PWM is enabled.
_output_pin: DigitalOutput. The DigitalOutput GPIO pin being used for PWM.
_duty_cycle. Float from 0.0 to 100.0. The current duty cycle as a percent.
_frequency_hz: Float. The current PWM frequency in Hertz. |
| |
Methods defined here:
- __init__(self, output_pin)
- Creates a PWM output.
Args:
output_pin: A DigitalOutput to use for PWM output.
- disable(self)
- Disables the PWM output.
- enable(self)
- Enables the PWM output.
- set_duty_cycle(self, duty_cycle)
- Sets the duty cycle of the PWM output.
Args:
duty_cycle: Float from 0.0 to 100.0. Duty cycle to set the PWM output to.
Raises:
ValueError: Thrown if duty_cycle is not between 0.0 and 100.0
- set_frequency_hz(self, frequency_hz)
- Sets the PWM frequency used for PWM output.
Args:
frequency_hz: Float. The frequency to set the PWM output to.
Raises:
ValueError: Thrown if the frequency is negative.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- duty_cycle
- Gets the current value for the PWM output's duty cycle.
Returns:
The current duty cycle as a float.
- frequency_hz
- Gets the current frequency used by the PWM output.
Returns:
The current frequency in Hertz as a float.
- is_enabled
- Checks if the PWM output is enabled.
Returns:
True if the PWM output is enabled, Flase otherwise.
- pin_number
- Gets the pin number of the PWM output.
Returns:
The pin number as an integer.
Data and other attributes defined here:
- __abstractmethods__ = frozenset(['_disable', '_enable', '_set_duty_cycle', '_set_frequency_hz'])
- __metaclass__ = <class 'abc.ABCMeta'>
- Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed
directly, and then acts as a mix-in class. You can also register
unrelated concrete classes (even built-in classes) and unrelated
ABCs as 'virtual subclasses' -- these and their descendants will
be considered subclasses of the registering ABC by the built-in
issubclass() function, but the registering ABC won't show up in
their MRO (Method Resolution Order) nor will method
implementations defined by the registering ABC be callable (not
even via super()).
| |