def setup(self): for g in self.gpio_setup: gpio = g["gpio"] debug("Setup GPIO %d" % gpio) GPIO.setFunction(gpio, g["func"]) if g["value"] >= 0 and GPIO.getFunction(gpio) == GPIO.OUT: GPIO.digitalWrite(gpio, g["value"])
def close(self): for g in self.gpio_reset: gpio = g["gpio"] debug("Reset GPIO %d" % gpio) GPIO.setFunction(gpio, g["func"]) if g["value"] >= 0 and GPIO.getFunction(gpio) == GPIO.OUT: GPIO.digitalWrite(gpio, g["value"])
def __portWrite__(self, value): if len(self.export) < 54: for i in self.export: if GPIO.getFunction(i) == GPIO.OUT: GPIO.digitalWrite(i, (value >> i) & 1) else: raise Exception("Please limit exported GPIO to write integers")
def __digitalWrite__(self, channel, value): self.checkDigitalChannelExported(channel) self.checkPostingValueAllowed() GPIO.digitalWrite(channel, value)