Mercurial > templog
annotate py/gpio_rpi.py @ 252:3e6f82347eab
uwsgi bits
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 06 Jun 2015 15:34:03 +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) |