def output(self, pin, state=-1): if not self.PINS.has_key(pin): sys.stderr.write("pin %s does not exist state %s\n" % (pin, state)) else: if not self.PINS[pin]['setup']: if self.PINS[pin]['input']: sys.stderr.write("pin %s set as an input pin\n" % (pin)) else: GPIO.setup(self.PINS[pin]['pin'], 0) if self.simulator and state: o = open("ipc/pin%s" % (pin), "w") o.close() if self.simulator and not state: try: os.remove("ipc/pin%s" % (pin)) except: pass if self.PINS[pin]['inverse']: if state == 1: state = 0 else: state = 1 GPIO.output(self.PINS[pin]['pin'], state) self.PINS[pin]['state'] = state
def output(self, pin, state=-1): if not self.PINS.has_key(pin): sys.stderr.write("pin %s does not exist\n" % (pin)) else: if not self.PINS[pin]['setup']: if self.PINS[pin]['input']: sys.stderr.write("pin %s set as an input pin\n" % (pin)) else: GPIO.setup(self.PINS[pin]['pin'], 0) if self.PINS[pin]['inverse']: if state == 1: state = 0 else: state = 1 GPIO.output(self.PINS[pin]['pin'], state) self.PINS[pin]['state'] = state
def turn_off(pin): GPIO.setup(pin, GPIO.OUT) GPIO.output(pin, GPIO.LOW)
def turn_on(pin): GPIO.setup(pin, GPIO.OUT) GPIO.output(pin, GPIO.HIGH)