1 import Adafruit_BBIO.GPIO as GPIO
 
   3 # Pins dont exist in CPython so...lets make our own!
 
  17     def __init__(self, pin_name):
 
  23     def __eq__(self, other):
 
  24         return self.id == other
 
  26     def init(self, mode=IN, pull=None):
 
  30                 GPIO.setup(self.id, GPIO.IN)
 
  31             elif mode == self.OUT:
 
  33                 GPIO.setup(self.id, GPIO.OUT)
 
  35                 raise RuntimeError("Invalid mode for pin: %s" % self.id)
 
  37             if self._mode != self.IN:
 
  38                 raise RuntimeError("Cannot set pull resistor on output")
 
  39             if pull == self.PULL_UP:
 
  40                 GPIO.setup(self.id, GPIO.IN, pull_up_down=GPIO.PUD_UP)
 
  41             elif pull == self.PULL_DOWN:
 
  42                 GPIO.setup(self.id, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
 
  44                 raise RuntimeError("Invalid pull for pin: %s" % self.id)       
 
  46     def value(self, val=None):
 
  50                 GPIO.output(self.id, val)
 
  51             elif val == self.HIGH:
 
  53                 GPIO.output(self.id, val)
 
  55                 raise RuntimeError("Invalid value for pin")
 
  57             return GPIO.input(self.id)
 
  70 # ordered as spiId, sckId, mosiId, misoId
 
  73 # ordered as uartId, txId, rxId