diff --git a/buttond.py b/buttond.py index 72cda37..9f19fb5 100755 --- a/buttond.py +++ b/buttond.py @@ -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