[Python, at least for now.]
Is there a standard way to translate between the various naming formats for RPi GPIO pins? I.e., given a pin identifier in one of these forms: "BOARDn"
, "WPIn"
, "GPIO*"
, (int) n
, and possibly "<function>", how can I derive the other forms?
I see that gpiozero
has methods to translate everything to BCM pin numbers, and function names to physical pin information, but I haven't found anything in any of the libraries I've examined so far that go any farther than that, much less a universal nomenclature-to-nomenclature translation.
Why I want this is irrelevant; my question is whether such functionality is already available somewhere I have yet to look.
[edit]
Example:
>>> from gpiozero.pins.data import *
>>> pii=pi_info()
>>> pii.physical_pin('GPIO4')
('J8', 7)
>>> pii.to_gpio('BOARD7')
4
>>> pii.to_gpio('GPIO4')
4
>>> pii.to_gpio('WPI7')
4
>>> pii.physical_pin('WPI7')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/gpiozero/pins/data.py", line 1268, in physical_pin
raise PinNoPins('no pins can be used for %s' % function)
gpiozero.exc.PinNoPins: no pins can be used for WPI7
The BCM pin number is the common destination. There don't appear to be any methods to translate the BCM pin number to the board number, or the wiringPi number, for example. What I'm seeking is 'what the the X name for pin Y' where X and Y are the various formats.