annotate py/gpio_test.py @ 594:aff50ee77252 rust

rust working better now with streams and sinks.
author Matt Johnston <matt@ucc.asn.au>
date Wed, 04 Jan 2017 17:18:44 +0800
parents e39ed85d87a5
children
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)]
231
e39ed85d87a5 fix a few python3 issues
Matt Johnston <matt@ucc.asn.au>
parents: 228
diff changeset
17 L("Test GPIO %s pin %s turned %s" % (self.name, self.pin, onoff))
228
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