Handle button correctly. get_hex refactored as hex getter.

master
Valdur Kana 11 months ago
parent 0920df1fb0
commit f43cfcf131
  1. 8
      wiegand.py

@ -56,7 +56,7 @@ class Decoder:
self._cb)
self.button_cb_h = self.pi.callback(self.button_pin,
pigpio.FALLING_EDGE,
self._cb)
self.button_cb)
def cut_empty(self, item):
if item[0:8] == "00000000":
@ -64,7 +64,8 @@ class Decoder:
else:
return item
def get_hex(self):
@property
def hex(self):
try:
items = self.items
if len(self.items) == 26:
@ -128,7 +129,7 @@ class Decoder:
self.in_code = False
if self.bits >= 26:
hex = self.get_hex()
hex = self.hex
if hex:
self.callback(hex)
else:
@ -139,6 +140,7 @@ class Decoder:
def button_cb(self, gpio_pin, level, tick):
print(f"button: gpio_pin:{gpio_pin}, level:{level}, tick:{tick}")
self.open_door()
def open_door(self):
self.pi.write(self.door_pin, 1)

Loading…
Cancel
Save