comparison py/gpio_rpi.py @ 228:d9e81a563923

porting to asyncio
author Matt Johnston <matt@ucc.asn.au>
date Fri, 20 Mar 2015 20:12:25 +0800
parents
children d9b819dcac53
comparison
equal deleted inserted replaced
227:efb5cad2e98b 228:d9e81a563923
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)