Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple helper to compute sysfs GPIO numbers from PIN names on Pine64
#!/usr/bin/python3
import sys
import string
def convert(value):
value = value.upper()
alp = value[1]
idx = string.ascii_uppercase.index(alp)
num = int(value[2:], 10)
res = idx * 32 + num
return res
if __name__ == "__main__":
args = sys.argv[1:]
if not args:
print("Usage: %s <pin>" % sys.argv[0])
sys.exit(1)
print("%d" % convert(args[0]))
@marcushh777

This comment has been minimized.

Copy link

@marcushh777 marcushh777 commented Jun 21, 2016

hi, this does not run in Python3

... it does run in Python2 ... however.

@longsleep

This comment has been minimized.

Copy link
Owner Author

@longsleep longsleep commented Jun 21, 2016

@marcushh777 fixed in revision 3 thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.