Reversed pin configuration/mapping as name->number instead of number->name
This commit is contained in:
parent
133dd4570e
commit
ba1eca29fc
1 changed files with 8 additions and 8 deletions
|
@ -18,23 +18,23 @@ class GpioPlugin(Plugin):
|
||||||
|
|
||||||
def __init__(self, pins=None, *args, **kwargs):
|
def __init__(self, pins=None, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
:param pins: Configuration for the GPIO PINs as an pin_number -> name map.
|
:param pins: Configuration for the GPIO PINs as a name -> pin_number map.
|
||||||
:type pins: dict
|
:type pins: dict
|
||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
{
|
{
|
||||||
14: "LED_1",
|
"LED_1": 14,
|
||||||
15: "LED_2",
|
"LED_2": 15,
|
||||||
16: "MOTOR",
|
"MOTOR": 16,
|
||||||
17: "SENSOR"
|
"SENSOR": 17
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.pins_by_number = pins if pins else {}
|
self.pins_by_name = pins if pins else {}
|
||||||
self.pins_by_name = { name:number
|
self.pins_by_number = { number:name
|
||||||
for (number, name) in self.pins_by_number.items() }
|
for (name, number) in self.pins_by_name.items() }
|
||||||
|
|
||||||
def _get_pin_number(self, pin):
|
def _get_pin_number(self, pin):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue