Handle button correctly. get_hex refactored as hex getter.

This commit is contained in:
Valdur Kana 2022-03-11 20:06:40 +02:00
parent 0920df1fb0
commit f43cfcf131

View File

@ -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)