view py/gpio_rpi.py @ 233:19569cb5ed46

better arg parser. seems close to ready
author Matt Johnston <matt@ucc.asn.au>
date Sat, 11 Apr 2015 23:32:59 +0800
parents d9e81a563923
children d9b819dcac53
line wrap: on
line source

import os

import RPi.GPIO as GPIO

from utils import L,D,EX,W

__all__ = ["Gpio"]

class Gpio(object):
	def __init__(self, pin, name):
		self.pin = pin
		self.name = name
		GPIO.setmode(GPIO.BOARD)
		GPIO.setup(self.pin, GPIO.OUT)

	def turn(self, value):
		self.state = bool(value)
		GPIO.output(self.pin, self.state)

	def get_state(self):
		return GPIO.input(self.pin)