| | |
- __builtin__.object
-
- BaseGPIO
-
- BaseDigitalInput
- exceptions.Exception(exceptions.BaseException)
-
- GPIOError
class BaseDigitalInput(BaseGPIO) |
| |
A class for creating digital input type peripherals.
BaseDigitalInput adds interrupt functionality to BaseGPIO. |
| |
- Method resolution order:
- BaseDigitalInput
- BaseGPIO
- __builtin__.object
Methods defined here:
- add_interrupt(self, type, callback=None, debounce_time_ms=0)
- Adds an interrupt to the digital input pin.
Args:
type: FALLING, RISING, or BOTH. Edge to trigger the interrupt on.
callback: Function. The function to call when the interrupt fires.
(default=None)
debounce_time_ms: Integer. Debounce time to put on the interrupt.
(default=0)
- remove_interrupt(self)
- Removes all interrupts from the digital input pin.
- wait_for_edge(self, type)
- Blocks until the edge is detected.
Args:
type: RISING, FALLING, or BOTH. Edge to detect before unblocking.
Data and other attributes defined here:
- INTERRUPT_BOTH = None
- INTERRUPT_FALLING = None
- INTERRUPT_RISING = None
- __abstractmethods__ = frozenset(['_read', '_write', 'add_interrupt', 'wait_for_edge'])
Methods inherited from BaseGPIO:
- __init__(self, pin, mode, pull_up_down)
- Creates a GPIO pin.
Args:
pin: Integer. The pin to create the GPIO on.
mode: INPUT, OUTPUT, or BIDIRECTIONAL. The type of pin mode to use.
pull_up_down: PUD_UP or PUD_DOWN. Enable pull up or pull down resistors.
- set_high(self)
- Writes a value of HIGH to the GPIO pin.
Raises:
GPIOError: Trying to write to a pin in INPUT mode will throw an
exception.
- set_low(self)
- Writes a value of LOW to the GPIO pin.
Raises:
GPIOError: Trying to write to a pin in INPUT mode will throw an
exception.
Data descriptors inherited from BaseGPIO:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- is_high
- Checks if the GPIO pin has a value of HIGH.
Returns:
True if the pin is in a HIGH state, False otherwise.
- is_low
- Checks if the GPIO pin has a value of LOW.
Returns:
True if the GPIO pin is in a LOW state, False otherwise.
- mode
- Gets the mode the GPIO pin is in.
Returns:
The mode being used by the GPIO pin.
- pin_number
- Gets the pin number of the GPIO.
Returns:
The GPIO's pin number.
- pull_up_down
- Gets the state of the GPIO pull up or pull down resistors.
Returns:
The state of the GPIO pull up or pull down resistors.
Data and other attributes inherited from BaseGPIO:
- BIDIRECTIONAL = 2
- INPUT = 1
- OUTPUT = 0
- PUD_DOWN = 2
- PUD_UP = 1
- __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()).
|
class BaseGPIO(__builtin__.object) |
| |
A class for creating GPIO type peripherals.
BaseGPIO implements basic GPIO functionality such as reading pin values
and setting pins high or low. Platforms are expected to subclass BaseGPIO
and provide platform specific implementations of _write and _read. Platforms
will likely also have to override the constructor to do platform specific
initialization tasks like setting the pin to INPUT or OUTPUT.
Attributes:
_pin: The GPIO pin being used. For example a pin number.
_mode: The mode the pin is in. For example INPUT or OUTPUT. |
| |
Methods defined here:
- __init__(self, pin, mode, pull_up_down)
- Creates a GPIO pin.
Args:
pin: Integer. The pin to create the GPIO on.
mode: INPUT, OUTPUT, or BIDIRECTIONAL. The type of pin mode to use.
pull_up_down: PUD_UP or PUD_DOWN. Enable pull up or pull down resistors.
- set_high(self)
- Writes a value of HIGH to the GPIO pin.
Raises:
GPIOError: Trying to write to a pin in INPUT mode will throw an
exception.
- set_low(self)
- Writes a value of LOW to the GPIO pin.
Raises:
GPIOError: Trying to write to a pin in INPUT mode will throw an
exception.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- is_high
- Checks if the GPIO pin has a value of HIGH.
Returns:
True if the pin is in a HIGH state, False otherwise.
- is_low
- Checks if the GPIO pin has a value of LOW.
Returns:
True if the GPIO pin is in a LOW state, False otherwise.
- mode
- Gets the mode the GPIO pin is in.
Returns:
The mode being used by the GPIO pin.
- pin_number
- Gets the pin number of the GPIO.
Returns:
The GPIO's pin number.
- pull_up_down
- Gets the state of the GPIO pull up or pull down resistors.
Returns:
The state of the GPIO pull up or pull down resistors.
Data and other attributes defined here:
- BIDIRECTIONAL = 2
- INPUT = 1
- OUTPUT = 0
- PUD_DOWN = 2
- PUD_UP = 1
- __abstractmethods__ = frozenset(['_read', '_write'])
- __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()).
|
|