Beispiel #1
0
    def __init__(self, button_pins=[], **kwargs):
        """Initialises the ``InputDevice`` object. 

        Kwargs:
        
        * ``button_pins``: GPIO mubers which to treat as buttons (GPIO.BCM numbering)
        * ``debug``: enables printing button press and release events when set to True
        """
        self.button_pins = button_pins
        self.init_hw()
        InputSkeleton.__init__(self, **kwargs)
Beispiel #2
0
    def __init__(self, cols=[5, 6, 13], rows=[12, 16, 20, 21], **kwargs):
        """Initialises the ``InputDevice`` object. 

        Kwargs:
        
        * ``button_pins``: GPIO mubers which to treat as buttons (GPIO.BCM numbering)
        * ``debug``: enables printing button press and release events when set to True
        """
        self.cols = cols
        self.rows = rows
        InputSkeleton.__init__(self, **kwargs)
Beispiel #3
0
    def __init__(self, button_pins=[], **kwargs):
        """Initialises the ``InputDevice`` object. 

        Kwargs:
        
        * ``button_pins``: GPIO mubers which to treat as buttons (GPIO.BCM numbering)
        * ``debug``: enables printing button press and release events when set to True
        """
        self.button_pins = button_pins
        self.init_hw()
        InputSkeleton.__init__(self, **kwargs)
Beispiel #4
0
    def __init__(self, button_pins=[], pullups=True, **kwargs):
        """Initialises the ``InputDevice`` object.

        Kwargs:

        * ``button_pins``: GPIO numbers which to treat as buttons (GPIO.BCM numbering)
        * ``pullups``: if True, enables pullups on all pins, if False, doesn't. Default: True
        * ``debug``: enables printing button press and release events when set to True
        """
        self.button_pins = button_pins
        self.pullups = pullups
        InputSkeleton.__init__(self, **kwargs)
Beispiel #5
0
    def __init__(self, addr = 0x20, bus = 1, **kwargs):
        """Initialises the ``InputDevice`` object.  
                                                                               
        Kwargs:                                                                  
                                                                                 
            * ``bus``: I2C bus number.
            * ``addr``: I2C address of the expander.

        """
        self.bus_num = bus
        self.bus = smbus.SMBus(self.bus_num)
        if type(addr) in [str, unicode]:
            addr = int(addr, 16)
        self.addr = addr
        self.init_expander()
        InputSkeleton.__init__(self, **kwargs)
Beispiel #6
0
    def __init__(self, addr = 0x20, bus = 1, **kwargs):
        """Initialises the ``InputDevice`` object.  
                                                                               
        Kwargs:                                                                  
                                                                                 
            * ``bus``: I2C bus number.
            * ``addr``: I2C address of the expander.

        """
        self.bus_num = bus
        self.bus = smbus.SMBus(self.bus_num)
        if type(addr) in [str, unicode]:
            addr = int(addr, 16)
        self.addr = addr
        self.init_expander()
        InputSkeleton.__init__(self, **kwargs)
Beispiel #7
0
    def __init__(self, addr=0x12, bus=1, int_pin=16, **kwargs):
        """Initialises the ``InputDevice`` object.

        Kwargs:

            * ``bus``: I2C bus number.
            * ``addr``: I2C address of the device.
            * ``int_pin``: GPIO pin for interrupt mode.

        """
        self.bus_num = bus
        if isinstance(addr, basestring):
            addr = int(addr, 16)
        self.addr = addr
        self.int_pin = int_pin
        InputSkeleton.__init__(self, **kwargs)
Beispiel #8
0
    def __init__(self, path=None, name=None, **kwargs):
        """Initialises the ``InputDevice`` object.

        Kwargs:

            * ``path``: path to the input device. If not specified, you need to specify ``name``.
            * ``name``: input device name

        """
        if not name and not path:  #No necessary arguments supplied
            raise TypeError(
                "HID device driver: expected at least path or name; got nothing. =("
            )
        self.path = path
        self.name = name
        InputSkeleton.__init__(self, mapping=[], **kwargs)
        self.hid_device_error_filter = False
Beispiel #9
0
    def __init__(self, addr=0x12, bus=1, int_pin=16, **kwargs):
        """Initialises the ``InputDevice`` object.  
                                                                               
        Kwargs:                                                                  
                                                                                 
            * ``bus``: I2C bus number.
            * ``addr``: I2C address of the device.
            * ``int_pin``: GPIO pin for interrupt mode. 

        """
        self.bus_num = bus
        self.bus = smbus.SMBus(self.bus_num)
        if type(addr) in [str, unicode]:
            addr = int(addr, 16)
        self.addr = addr
        self.int_pin = int_pin
        InputSkeleton.__init__(self, **kwargs)
Beispiel #10
0
    def __init__(self, addr=0x20, bus=1, int_pin=None, **kwargs):
        """Initialises the ``InputDevice`` object.  
                                                                               
        Kwargs:                                                                  
                                                                                 
            * ``bus``: I2C bus number.
            * ``addr``: I2C address of the expander.
            * ``int_pin``: GPIO pin to which INT pin of the expander is connected. If supplied, interrupt-driven mode is used, otherwise, library reverts to polling mode.

        """
        self.bus_num = bus
        self.bus = smbus.SMBus(self.bus_num)
        if type(addr) in [str, unicode]:
            addr = int(addr, 16)
        self.addr = addr
        self.int_pin = int_pin
        self.init_expander()
        InputSkeleton.__init__(self, **kwargs)
Beispiel #11
0
    def __init__(self, addr = 0x20, bus = 1, int_pin = None, **kwargs):
        """Initialises the ``InputDevice`` object.  
                                                                               
        Kwargs:                                                                  
                                                                                 
            * ``bus``: I2C bus number.
            * ``addr``: I2C address of the expander.
            * ``int_pin``: GPIO pin to which INT pin of the expander is connected. If supplied, interrupt-driven mode is used, otherwise, library reverts to polling mode.

        """
        self.bus_num = bus
        self.bus = smbus.SMBus(self.bus_num)
        if type(addr) in [str, unicode]:
            addr = int(addr, 16)
        self.addr = addr
        self.int_pin = int_pin
        self.init_expander()
        InputSkeleton.__init__(self, **kwargs)
Beispiel #12
0
    def __init__(self, addr = 0x12, bus = 1, int_pin = 21, **kwargs):
        """Initialises the ``InputDevice`` object.  
                                                                               
        Kwargs:                                                                  
                                                                                 
            * ``bus``: I2C bus number.
            * ``addr``: I2C address of the device.
            * ``int_pin``: GPIO pin for interrupt mode. 

        """
        self.bus_num = bus
        self.bus = smbus.SMBus(self.bus_num)
        if type(addr) in [str, unicode]:
            addr = int(addr, 16)
        self.addr = addr
        self.int_pin = int_pin
        self.init_expander()
        InputSkeleton.__init__(self, **kwargs)
Beispiel #13
0
    def __init__(self, path=None, name=None, **kwargs):
        """Initialises the ``InputDevice`` object.

        Kwargs:

            * ``path``: path to the input device. If not specified, you need to specify ``name``.
            * ``name``: input device name

        """
        if not name and not path:  #No necessary arguments supplied
            raise TypeError("Expected at least path or name; got nothing. =(")
        if not path:
            path = get_path_by_name(name)
        if not name:
            name = get_name_by_path(path)
        if not name and not path:  #Seems like nothing was found by get_input_devices
            raise IOError("Device not found")
        self.path = path
        self.name = name
        InputSkeleton.__init__(self, mapping=[], **kwargs)
Beispiel #14
0
    def __init__(self, path=None, name=None, **kwargs):
        """Initialises the ``InputDevice`` object.  
                                                                               
        Kwargs:                                                                  
                                                                                 
            * ``path``: path to the input device. If not specified, you need to specify ``name``.
            * ``name``: input device name

        """
        if not name and not path: #No necessary arguments supplied
            raise TypeError("Expected at least path or name; got nothing. =(")
        if not path:
            path = get_path_by_name(name)
        if not name:
            name = get_name_by_path(path)
        if not name and not path: #Seems like nothing was found by get_input_devices
            raise IOError("Device not found")
        self.path = path
        self.name = name
        self.init_hw()
        InputSkeleton.__init__(self, mapping = [], **kwargs)
Beispiel #15
0
 def atexit(self):
     InputSkeleton.atexit(self)
Beispiel #16
0
 def __init__(self, **kwargs):
     InputSkeleton.__init__(self, mapping=[], **kwargs)
Beispiel #17
0
 def __init__(self, **kwargs):
     """Initialises the ``InputDevice`` object - basically, does nothing. """
     InputSkeleton.__init__(self, **kwargs)
Beispiel #18
0
 def atexit(self):
     InputSkeleton.atexit(self)
     try:
         self.device.ungrab()
     except:
         pass
Beispiel #19
0
 def atexit(self):
     InputSkeleton.atexit(self)
     try:
         self.device.ungrab()
     except:
         pass