22 lines
605 B
Python
Raw Permalink Normal View History

class IOPi(object):
address = None
used_pins = [0 for i in range(17)]
pin_directions = [0 for i in range(17)]
pin_values = [0 for i in range(17)]
def __init__(self, address):
self.address = address
def set_pin_direction(self, pin, direction):
self.used_pins[pin] = 1
self.pin_directions[pin] = direction
def write_pin(self, pin, value):
self.used_pins[pin] = 1
self.pin_values[pin] = value
def read_pin(self, pin):
if self.used_pins[pin] == 1:
return self.pin_values[pin]
else:
return None