Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
List all the pins in the board module, all aliases on the same line, sorted by name
import microcontroller,board
allpins = []
for pin in dir(microcontroller.pin):
if isinstance(getattr(microcontroller.pin, pin), microcontroller.Pin):
pins = []
for alias in dir(board):
if getattr(board, alias) is getattr(microcontroller.pin, pin):
pins.append("board.{}".format(alias))
pins.sort()
if len(pins)>0:
allpins.append(" ".join(pins))
allpins.sort()
for pins in allpins: print(pins)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment