def __init__(self): self.setPinMapping() GPIOPort.__init__(self, max(self.pins) + 1) self.post_value = True self.post_function = True self.gpio_setup = [] self.gpio_reset = [] self.gpio_map = None self.pinFunctionSet = set() self.valueFile = {pin: None for pin in self.pins} self.functionFile = {pin: None for pin in self.pins} for pin in self.pins: # Export the pins here to prevent a delay when accessing the values for the # first time while waiting for the file group to be set self.__checkFilesystemExport__(pin) if gpio_library: gpio_library.setmode(gpio_library.ASUS) else: try: with open('/dev/gpiomem', 'rb') as gpiomem: self.gpio_map = mmap.mmap(gpiomem.fileno(), BLOCK_SIZE, prot=mmap.PROT_READ) except FileNotFoundError: pass except OSError as err: error(err)
def __init__(self): self.setPinMapping() GPIOPort.__init__(self, max(self.pins) + 1) self.post_value = True self.post_function = True self.gpio_setup = [] self.gpio_reset = [] self.gpio_map = None self.pinFunctionSet = set() self.valueFile = {pin:None for pin in self.pins} self.functionFile = {pin:None for pin in self.pins} self.callbacks = {} self.edge_poll = select.epoll() thread = Thread(target=self.pollEdges, daemon=True) thread.start() for pin in self.pins: # Export the pins here to prevent a delay when accessing the values for the # first time while waiting for the file group to be set self.__checkFilesystemExport__(pin) if gpio_library: gpio_library.setmode(gpio_library.ASUS) elif not Hardware().isRaspberryPi3(): # On the Pi 3 the memory mapped /dev/gpiomem file seems to give strange, inconsistent readings, like duplicated # 4 byte sequences and "oipg" ASCII values. This might be some issue with the way Python mmap works since it didn't # seem to happen with the wiringPi C library using uint32_t pointers. For now we just avoid using /dev/gpiomem on Pi 3. try: with open('/dev/gpiomem', 'rb') as gpiomem: self.gpio_map = mmap.mmap(gpiomem.fileno(), BLOCK_SIZE, prot=mmap.PROT_READ) except FileNotFoundError: pass except OSError as err: error(err)
def __init__(self, channel_count): """Initializes MCP3XXX device. Arguments: channel_count: Number of channels on the device """ GPIOPort.__init__(self, channel_count) self.banks = int(channel_count / 8)
def __init__(self, slave=0x20): slave = toint(slave) if slave in range(0x20, 0x28): self.name = "PCF8574" elif slave in range(0x38, 0x40): self.name = "PCF8574A" else: raise ValueError( "Bad slave address for PCF8574(A) : 0x%02X not in range [0x20..0x27, 0x38..0x3F]" % slave) I2C.__init__(self, slave) GPIOPort.__init__(self, 8) self.portWrite(0xFF) self.portRead()
def __init__(self, slave=0x20): """Initializes PCF8574 device. Arguments: slave: The slave address """ slave = int(slave) if slave in range(0x20, 0x28): self.name = "PCF8574" elif slave in range(0x38, 0x40): self.name = "PCF8574A" else: raise ValueError("Bad slave address for PCF8574(A) : 0x%02X not in range [0x20..0x27, 0x38..0x3F]" % slave) I2C.__init__(self, slave) GPIOPort.__init__(self, 8) self.portWrite(0xFF) self.portRead()
def __init__(self): if not NativeGPIO.instance: GPIOPort.__init__(self, 54) self.export = range(54) self.post_value = True self.post_function = True self.gpio_setup = [] self.gpio_reset = [] self.valueFile = [0 for i in range(54)] self.functionFile = [0 for i in range(54)] for i in range(54): # Export the pins here to prevent a delay when accessing the values for the # first time while waiting for the file group to be set self.__checkFilesystemExport__(i) try: with open('/dev/gpiomem', 'rb') as gpiomem: self.gpio_map = mmap.mmap(gpiomem.fileno(), BLOCK_SIZE, prot=mmap.PROT_READ) except OSError as err: error(err) NativeGPIO.instance = self
def __init__(self, slave=None): OneWire.__init__(self, slave, 0x29, "2408") GPIOPort.__init__(self, 8) self.portWrite(0x00)
def __init__(self, channelCount): GPIOPort.__init__(self, channelCount) self.banks = int(channelCount / 8)