annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
228
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 import os
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3 from utils import L,D,EX,W
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5 __all__ = ["Gpio"]
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7 class Gpio(object):
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8 def __init__(self, pin, name):
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
9 self.name = name
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
10 self.pin = name
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
11 self.state = False
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
12 L("Test GPIO %s pin %d started, set off." % (name, pin))
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14 def turn(self, value):
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
15 self.state = bool(value)
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
16 onoff = ("off", "on")[int(self.state)]
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
17 L("Test GPIO %s pin %d turned %s" % (self.name, self.pin, onoff))
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
18
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
19 def get_state(self):
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
20 return self.state
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
21
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
22
d9e81a563923 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
23