def wildcard(self, compact=False): if compact: f = "f" v = "v" else: f = "function" v = "value" values = {} print(self.export) for i in self.export: if compact: func = GPIO.getFunction(i) else: func = GPIO.getFunctionString(i) values[i] = {f: func, v: int(GPIO.digitalRead(i))} return values
def __digitalRead__(self, channel): self.checkDigitalChannelExported(channel) return GPIO.digitalRead(channel)
def __portRead__(self): value = 0 for i in self.export: value |= GPIO.digitalRead(i) << i return value
import _webiopi.GPIO import time GPIO = _webiopi.GPIO # GPIO, status, time data = [[num, 0, 0.0] for num in [17, 27, 22]] for n in data: print(n[0], n[1], n[2]) GPIO.setFunction(n[0], GPIO.IN) while True: for n in data: status = GPIO.digitalRead(n[0]) if n[1] == 0 and status: n[1] = 1 n[2] = time.time() elif n[1] == 1 and not status: n[1] = 2 elif n[1] == 2 and 0.2 < (time.time() - n[2]): n[1] = 0 print("%d clicked" % n[0])