1
0
Fork 0

wrap the comment function

This commit is contained in:
Kevin Matz 2019-11-03 20:41:50 -05:00
parent 528be9090d
commit 25c65d7492
1 changed files with 7 additions and 2 deletions

View File

@ -24,6 +24,11 @@ from signal import pause
# from gpiozero import Device
# Device.pin_factory = MockFactory()
def activate(path):
comment(path)
# empty button directory
_buttons = {}
@ -41,8 +46,8 @@ for b in config.get('button', 'names').split(','):
# set up button on pin
_buttons[b] = Button(c.getint("pin", None))
# connect button callbacks to anonymous functions
_buttons[b].when_pressed = lambda: comment(closed)
_buttons[b].when_released = lambda: comment(opened)
_buttons[b].when_pressed = lambda: activate(closed)
_buttons[b].when_released = lambda: activate(opened)
except (KeyError, GPIODeviceError) as e:
print('Error configuring button', b, e)
continue