1GPIO_BASE = 320
2
3def convertGpio(name):
4    offset = int(filter(str.isdigit, name))
5    port = filter(str.isalpha, name.upper())
6    a = ord(port[-1]) - ord('A')
7    if len(port) > 1:
8        a += 26
9    base = a * 8 + GPIO_BASE
10    return base + offset
11