rename variable for readability
This commit is contained in:
parent
4672fe993d
commit
7956b73e2f
16
buttond.py
16
buttond.py
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue