From 25c65d7492a406177646733184dc596b32493e99 Mon Sep 17 00:00:00 2001 From: Kevin Matz Date: Sun, 3 Nov 2019 20:41:50 -0500 Subject: [PATCH] wrap the comment function --- buttond.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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