Skip to content

Latest commit

 

History

History
40 lines (27 loc) · 731 Bytes

README.md

File metadata and controls

40 lines (27 loc) · 731 Bytes

txgpio

Twisted-based asynchronous library for using GPIO (over Sysfs) implemented in pure python.

Reading

Define protocol

class SysfsGPIOProtocol(Protocol):

    def dataReceived(self, data):
        self.factory.on_receive(data)

Define factory

class SysfsGPIOFactory(Factory):
    protocol = SysfsGPIOProtocol

    def on_receive(self, data):
        log.msg('Read value: {}'.format(data))

Create instances

    factory = SysfsGPIOFactory()
    protocol = factory.buildProtocol(None)
    GPIO(protocol, reactor=reactor, gpio_no=21, edge='both')

Let the reactor run

reactor.run()

See examples/ directory for reader & writer applications.