@@ -19,41 +19,61 @@ except OSError as e:
1919
2020print("starting keyboard %s (%s)" % (config["name"], config["id"]))
2121
22+ def pinValid(pin):
23+ if pin == "":
24+ return False
25+ if config["pinPrefix"] == "quickpin":
26+ pin = f'{eval(pin)}'
27+ if pin in [f'board.{alias}' for alias in dir(board)]:
28+ return True
29+ else:
30+ print(f'INVALID PIN FOUND {pin}')
31+ return False
2232
2333# Pin setup
2434def renderPin(pin):
35+ pinLabel = ''
2536 if config["pinPrefix"] == "gp":
26- return "board.GP" + pin
37+ pinLabel = "board.GP" + pin
2738 elif config["pinPrefix"] == "board":
28- return "board." + pin
39+ pinLabel = "board." + pin
2940 elif config["pinPrefix"] == "quickpin":
30- return "pins[" + pin + "]"
41+ pinLabel = "pins[" + pin + "]"
3142 else:
32- return pin
43+ pinLabel = pin
44+ if pinValid(pinLabel):
45+ return pinLabel
46+
3347
3448
3549colPinsArray = []
3650for i, item in enumerate(config["colPins"]):
3751 colPinsArray.append(renderPin(item))
52+ # Remove the 'None's from the list of pins
53+ colPinsArray = [pin for pin in colPinsArray if pin is not None]
3854colPins = ",".join(colPinsArray)
3955if len(colPinsArray) == 1:
4056 colPins = colPins + ","
4157
4258rowPinsArray = []
4359for i, item in enumerate(config["rowPins"]):
4460 rowPinsArray.append(renderPin(item))
61+ # Remove the 'None's from the list of pins
62+ rowPinsArray = [pin for pin in rowPinsArray if pin is not None]
4563rowPins = ",".join(rowPinsArray)
4664if len(rowPinsArray) == 1:
4765 rowPins = rowPins + ","
4866
4967pinsArray = []
5068for i, item in enumerate(config["directPins"]):
5169 pinsArray.append(renderPin(item))
70+ # Remove the 'None's from the list of pins
71+ pinsArray = [pin for pin in pinsArray if pin is not None]
5272pins = ",".join(pinsArray)
5373if len(pinsArray) == 1:
5474 pins = pins + ","
5575
56- rgbPin = config["rgbPin"]
76+ rgbPin = config["rgbPin"] if pinValid(config["rgbPin"]) else None
5777rgbNumLeds = config["rgbNumLeds"]
5878
5979matrixWiring = False
@@ -108,7 +128,7 @@ if config.get('splitPinB'):
108128 splitPinB = eval(renderPin(config['splitPinB']))
109129
110130vbusPin = None
111- if config.get('vbusPin'):
131+ if config.get('vbusPin') and config.get('splitSide') == 'vbus' and pinValid("board." + config['vbusPin']) :
112132 vbusPin = eval("board." + config['vbusPin'])
113133
114134# led pin without prefix for now
0 commit comments