annotate py/gpio_test.py @ 549:0baa57b6d9ca

working zoom
author Matt Johnston <matt@ucc.asn.au>
date Wed, 27 May 2015 23:45:03 +0800
parents 73257bae83ea
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
527
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 import os
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3 from utils import L,D,EX,W
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5 __all__ = ["Gpio"]
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7 class Gpio(object):
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8 def __init__(self, pin, name):
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
9 self.name = name
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
10 self.pin = name
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
11 self.state = False
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
12 L("Test GPIO %s pin %d started, set off." % (name, pin))
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14 def turn(self, value):
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
15 self.state = bool(value)
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
16 onoff = ("off", "on")[int(self.state)]
530
73257bae83ea fix a few python3 issues
Matt Johnston <matt@ucc.asn.au>
parents: 527
diff changeset
17 L("Test GPIO %s pin %s turned %s" % (self.name, self.pin, onoff))
527
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
18
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
19 def get_state(self):
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
20 return self.state
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
21
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
22
dd8895652485 porting to asyncio
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
23