Mercurial > templog
diff py/gpio_test.py @ 228:d9e81a563923
porting to asyncio
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 20 Mar 2015 20:12:25 +0800 |
parents | |
children | e39ed85d87a5 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/py/gpio_test.py Fri Mar 20 20:12:25 2015 +0800 @@ -0,0 +1,23 @@ +import os + +from utils import L,D,EX,W + +__all__ = ["Gpio"] + +class Gpio(object): + def __init__(self, pin, name): + self.name = name + self.pin = name + self.state = False + L("Test GPIO %s pin %d started, set off." % (name, pin)) + + def turn(self, value): + self.state = bool(value) + onoff = ("off", "on")[int(self.state)] + L("Test GPIO %s pin %d turned %s" % (self.name, self.pin, onoff)) + + def get_state(self): + return self.state + + +