wrap the comment function
This commit is contained in:
parent
528be9090d
commit
25c65d7492
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue