improvements to output

This commit is contained in:
Owen
2024-05-01 16:20:15 +00:00
parent 863b0e3e72
commit 2e07142707
2 changed files with 18 additions and 13 deletions
+16 -12
View File
@@ -31,15 +31,15 @@ for line in pinlist:
state = pmux[6] + ' (' + pmux[4] + ':' + pmux[1] + ')' state = pmux[6] + ' (' + pmux[4] + ':' + pmux[1] + ')'
elif pmux[3] == 'GPIO': elif pmux[3] == 'GPIO':
state = 'gpio (' + pmux[4] + ')' state = 'gpio (' + pmux[4] + ')'
board.gpio[muxindex.index(int(pmux[1]))][3] = state board.gpio[muxindex.index(int(pmux[1]))][2] = state
# work out column widths # work out column widths
width = [] width = []
total = 33 total = 33 # this includes all the 'fixed width' text
for c in range(0, board.cols): for c in range(0, board.cols):
wide = 0 wide = 0
for p in range(c, len(board.gpio), board.cols): for p in range(c, len(board.gpio), board.cols):
w = len(board.gpio[p][3]) w = len(board.gpio[p][2])
wide = w if w > wide else wide wide = w if w > wide else wide
width.append(wide) width.append(wide)
total += wide total += wide
@@ -50,32 +50,36 @@ print('\n{}{}'.format(int((total-len(header))/2) * ' ', header))
# Output result. # Output result.
print('Gpio Header:')
pincount = board.cols * board.rows
# heading # heading
for p in range(0, board.cols): for p in range(0, board.cols):
if p % 2 == 0: if p % 2 == 0:
print(' {}func des pin '.format(' ' * (width[p] -4)), end='') print(' {}func des pin '.format(' ' * (width[p] -4)), end='')
else: else:
print(' pin des func{} '.format(' ' * (width[p] - 4)), end='') print(' pin des func{} '.format(' ' * (width[p] - 4)), end='')
print()
# gpio pins # gpio pins
print('\nGpio Header:')) gpiopin = 1
for l in range(0, len(board.gpio), board.cols): for l in range(0, pincount, board.cols):
for p in range(l, l + board.cols): for p in range(l, l + board.cols):
if board.gpio[p][2] is None: if board.gpio[p][2] is None:
board.gpio[p][3] = '' board.gpio[p][3] = ''
board.gpio[p][2] = '' board.gpio[p][2] = ''
pad = (width[p - l] - len(board.gpio[p][3])) * ' ' pad = (width[p - l] - len(board.gpio[p][2])) * ' '
if p % 2 == 0: if p % 2 == 0:
print(' {}{} {:>5} {:>3} --o'.format(pad, board.gpio[p][3], board.gpio[p][2], str(board.gpio[p][1])), end='') print(' {}{} {:>5} {:>3} --o'.format(pad, board.gpio[p][2], str(board.gpio[p][1]), str(gpiopin)), end='')
else: else:
print(' o-- {:3} {:5} {}{} '.format(str(board.gpio[p][1]), board.gpio[p][2], board.gpio[p][3], pad), end='') print(' o-- {:3} {:5} {}{} '.format(str(gpiopin), str(board.gpio[p][1]), board.gpio[p][2], pad), end='')
gpiopin += 1
print() print()
# extras # extras
print('\nOther pins of interest:')) if len(board.gpio) > pincount:
if len(board.gpio] > 40: print('\nOther gpio outputs of interest:')
for p in board.gpio[29:]: for p in board.gpio[pincount:]:
print(' o-- {:3} {:5} {}'.format(str(board.gpio[p][1]), board.gpio[p][2], board.gpio[p][3]), end='') print('-- {:5} - {}'.format(str(p[1]), p[2]))
print('\nNotes:') print('\nNotes:')
for l in board.notes: for l in board.notes:
+2 -1
View File
@@ -12,7 +12,8 @@
''' '''
name = 'MangoPI MQ Pro GPIO header' name = 'MangoPI MQ Pro GPIO header'
cols = 2 cols = 2 # standard 40
rows = 20 # pin connector
gpio = [ gpio = [
# The first 40 entries are the 40pin GPIO connector # The first 40 entries are the 40pin GPIO connector
[None, '3v3'], [None, '5v'], [None, '3v3'], [None, '5v'],