8 A class to read Wiegand codes of an arbitrary length.
10 The code length and value are returned.
22 def callback(bits, code):
23 print("bits={} code={}".format(bits, code))
27 w = wiegand.decoder(pi, 14, 15, callback)
36 def __init__(self, pi, gpio_0, gpio_1, callback, bit_timeout=5):
39 Instantiate with the pi, gpio for 0 (green wire), the gpio for 1
40 (white wire), the callback function, and the bit timeout in
41 milliseconds which indicates the end of a code.
43 The callback is passed the code length in bits and the value.
65 def _cb(self, gpio, level, tick):
68 Accumulate bits until both gpios 0 and 1 timeout.
71 if level < pigpio.TIMEOUT:
109 Cancel the Wiegand decoder.
115 if __name__ ==
"__main__":
124 print(
"bits={} value={}".format(bits, value))