Metadata-Version: 1.1
Name: gpiochip2
Version: 0.9.2
Summary: Pythonic API for Linux's gpiochip chardev ABI v2.
Home-page: http://github.com/vpelletier/python-gpiochip2
Author: Vincent Pelletier
Author-email: plr.vincent@gmail.com
License: GPLv3+
Description: .. contents::
        
        Pythonic API for Linux's gpiochip chardev ABI v2.
        
        Features
        --------
        
        - Manage multiple GPIO lines at the same time, with bit operation affecting the
          entire line group at once (`|=`, `&=`, `^=`).
        - Get file event notification of timestamped line events (rising edge, falling
          edge).
        - Get file event notifications (select, poll, epoll...) of gpiochip-level and
          line-level events.
        - Control line parameters (pull-up, pull-down, active-low, debouncing, ...).
        - Pure python module: no compilation needed, not limited to CPython.
        
        Requirements
        ------------
        
        - Linux >=5.10.0 for GPIO chardev ABI v2
        - python stdlib >=3.7.10 (not tested with earlier versions, they may work)
        
        Examples
        --------
        
        Warning: this example is **not** meant to be executed as-is. Depending on what
        is connected to the GPIO lines used here (which is entirely board-dependent),
        this could cause all sort of problems, including permanent hardware damage.
        
        This is only to be taken as a quick overview of this module's API.
        
        .. code:: python
        
            from gpiochip2 import GPIOChip, GPIO_V2_LINE_FLAG
            with GPIOChip('/dev/gpiochip0', 'w+b') as gpiochip:
                # Get information about the gpio chip itself
                gpiochip.getInfo()
                # Get information about line 20
                gpiochip.getLineInfo(20)
                with gpiochip.openLines(
                    line_list=[20, 21, 26],
                    flags=GPIO_V2_LINE_FLAG.OUTPUT,
                    consumer='sample-name'.encode('ascii'),
                    flags_dict={
                        # Line 26 is an input and produces event on falling edges
                        2: GPIO_V2_LINE_FLAG.INPUT | GPIO_V2_LINE_FLAG.EDGE_FALLING,
                    },
                    default_dict={
                        # Drive line 20 low immediately on opening
                        0: False,
                    },
                ) as gpio_lines:
                    # Read lines state
                    value = gpio_lines.lines
                    # Change lines state
                    gpio_lines.lines = 0b11
                    # Invert line 20
                    gpio_lines ^= 1 # 1 << 0
                    # Set line 21
                    gpio_lines |= 2 # 1 << 1
                    # Clear line 21
                    gpio_lines &= 2 # 1 << 1
                    # Read event
                    lines.getEvent()
        
        Notes on bit operations:
        
        ``gpio_lines.lines |= some_mask`` will read then write the GPIO, while
        ``gpio_lines |= some_mask`` only needs to write, making it more efficient.
        
        The same applies to ``&=``, but not to other operators.
        
        See also the `examples` directory for more realistic code.
        
Keywords: linux gpiochip chardev
Platform: linux
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: System :: Hardware :: Hardware Drivers
