From 2e07142707a126669b8edd6a8231b8a434b9710f Mon Sep 17 00:00:00 2001 From: Owen Date: Wed, 1 May 2024 16:20:15 +0000 Subject: [PATCH] improvements to output --- tools/list-pins.py | 28 ++++++++++++++++------------ tools/maps/MangoPi-MQ-Pro.py | 3 ++- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/tools/list-pins.py b/tools/list-pins.py index cb2cef1..b1b6ae2 100644 --- a/tools/list-pins.py +++ b/tools/list-pins.py @@ -31,15 +31,15 @@ for line in pinlist: state = pmux[6] + ' (' + pmux[4] + ':' + pmux[1] + ')' elif pmux[3] == 'GPIO': 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 width = [] -total = 33 +total = 33 # this includes all the 'fixed width' text for c in range(0, board.cols): wide = 0 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 width.append(wide) total += wide @@ -50,32 +50,36 @@ print('\n{}{}'.format(int((total-len(header))/2) * ' ', header)) # Output result. +print('Gpio Header:') +pincount = board.cols * board.rows # heading for p in range(0, board.cols): if p % 2 == 0: print(' {}func des pin '.format(' ' * (width[p] -4)), end='') else: print(' pin des func{} '.format(' ' * (width[p] - 4)), end='') +print() # gpio pins -print('\nGpio Header:')) -for l in range(0, len(board.gpio), board.cols): +gpiopin = 1 +for l in range(0, pincount, board.cols): for p in range(l, l + board.cols): if board.gpio[p][2] is None: board.gpio[p][3] = '' 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: - 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: - 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() # extras -print('\nOther pins of interest:')) -if len(board.gpio] > 40: - for p in board.gpio[29:]: - print(' o-- {:3} {:5} {}'.format(str(board.gpio[p][1]), board.gpio[p][2], board.gpio[p][3]), end='') +if len(board.gpio) > pincount: + print('\nOther gpio outputs of interest:') + for p in board.gpio[pincount:]: + print('-- {:5} - {}'.format(str(p[1]), p[2])) print('\nNotes:') for l in board.notes: diff --git a/tools/maps/MangoPi-MQ-Pro.py b/tools/maps/MangoPi-MQ-Pro.py index eeaa769..c87303f 100644 --- a/tools/maps/MangoPi-MQ-Pro.py +++ b/tools/maps/MangoPi-MQ-Pro.py @@ -12,7 +12,8 @@ ''' name = 'MangoPI MQ Pro GPIO header' -cols = 2 +cols = 2 # standard 40 +rows = 20 # pin connector gpio = [ # The first 40 entries are the 40pin GPIO connector [None, '3v3'], [None, '5v'],