Skip to content
Snippets Groups Projects
Select Git revision
  • 9ffc7edef7fc9f33fdc969081ffedd4af76b43bf
  • develop default protected
  • feature/module-gpiod
  • 0.5.6
  • 0.5.5
  • 0.5.4
  • 0.5.3
  • 0.5.2
  • 0.5.1
  • 0.5.0
  • 0.4.1
  • 0.4.0
  • 0.3.2
  • 0.3.1
  • 0.3.0
  • 0.2.8
  • 0.2.7
  • 0.2.6
  • 0.2.5
  • 0.2.4
  • 0.2.3
  • 0.2.2
  • 0.2.1
23 results

__init__.py

Blame
  • __init__.py 960 B
    import abc
    
    from enum import Enum
    
    
    BASE_SCHEMA = {
        "name": {
            "required": True,
            "empty": False
        },
        "module": {
            "required": True,
            "empty": False
        },
        "cleanup": {
            "required": False,
            "type": "boolean",
            "default": True
        }
    }
    
    
    class PinDirection(Enum):
        INPUT = 0
        OUTPUT = 1
    
    
    class PinPullup(Enum):
        OFF = 0
        UP = 1
        DOWN = 2
    
    
    class GenericGPIO(object):
        """
        Abstracts a generic GPIO interface to be implemented by the modules in this
        directory.
        """
        __metaclass__ = abc.ABCMeta
    
        @abc.abstractmethod
        def setup_pin(self, pin, direction, pullup, pin_config):
            pass
    
        @abc.abstractmethod
        def set_pin(self, pin, value):
            pass
    
        @abc.abstractmethod
        def get_pin(self, pin):
            pass
    
        def cleanup(self):
            """
            Called when closing the program to handle any cleanup operations.
            """
            pass