Mercurial > templog
annotate py/gpio_rpi.py @ 244:2071d939e4ff
use base64 data, faster
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 21 May 2015 00:00:10 +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) |