Mercurial > templog
annotate py/gpio_rpi.py @ 235:4cbcbba567ab
missing sensor.py
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 05 May 2015 21:29:19 +0800 |
parents | d9e81a563923 |
children | d9b819dcac53 |
rev | line source |
---|---|
228 | 1 import os |
2 | |
3 import RPi.GPIO as GPIO | |
4 | |
5 from utils import L,D,EX,W | |
6 | |
7 __all__ = ["Gpio"] | |
8 | |
9 class Gpio(object): | |
10 def __init__(self, pin, name): | |
11 self.pin = pin | |
12 self.name = name | |
13 GPIO.setmode(GPIO.BOARD) | |
14 GPIO.setup(self.pin, GPIO.OUT) | |
15 | |
16 def turn(self, value): | |
17 self.state = bool(value) | |
18 GPIO.output(self.pin, self.state) | |
19 | |
20 def get_state(self): | |
21 return GPIO.input(self.pin) |