1
0
Fork 0

rename variable for readability

This commit is contained in:
Kevin Matz 2019-11-17 10:58:21 -05:00
parent 4672fe993d
commit 7956b73e2f
1 changed files with 8 additions and 8 deletions

View File

@ -25,14 +25,14 @@ from signal import pause
# Device.pin_factory = MockFactory()
def _activate(path):
if path is None:
def _activate(macro):
if macro is None:
return
path = path.strip('\"').upper()
if path is "":
macro = macro.strip('\"').upper()
if macro is "":
return
print("doing macro ", path)
comment(path)
print("doing macro ", macro)
comment(macro)
# empty button directory
@ -55,9 +55,9 @@ for b in config.get('button', 'names').split(','):
_buttons[b] = Button(pin)
# connect button callbacks to anonymous functions
print('connecting GPIO', pin, '"closed" to macro', closed)
_buttons[b].when_pressed = lambda path=closed: _activate(path)
_buttons[b].when_pressed = lambda macro=closed: _activate(macro)
print('connecting GPIO', pin, '"opened" to macro', opened)
_buttons[b].when_released = lambda path=opened: _activate(path)
_buttons[b].when_released = lambda macro=opened: _activate(macro)
except (KeyError, GPIODeviceError) as e:
print('Error configuring button', b, e)