Skip to content

Commit 7beee95

Browse files
authored
Merge pull request #13 from parallacks/11-pog-on-boards-without-vbus-sense
11 pog on boards without vbus sense
2 parents c7894db + bb47a98 commit 7beee95

File tree

1 file changed

+26
-6
lines changed
  • src/main/pythontemplates

1 file changed

+26
-6
lines changed

src/main/pythontemplates/pog.ts

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,61 @@ except OSError as e:
1919
2020
print("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
2434
def 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
3549
colPinsArray = []
3650
for 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]
3854
colPins = ",".join(colPinsArray)
3955
if len(colPinsArray) == 1:
4056
colPins = colPins + ","
4157
4258
rowPinsArray = []
4359
for 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]
4563
rowPins = ",".join(rowPinsArray)
4664
if len(rowPinsArray) == 1:
4765
rowPins = rowPins + ","
4866
4967
pinsArray = []
5068
for 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]
5272
pins = ",".join(pinsArray)
5373
if len(pinsArray) == 1:
5474
pins = pins + ","
5575
56-
rgbPin = config["rgbPin"]
76+
rgbPin = config["rgbPin"] if pinValid(config["rgbPin"]) else None
5777
rgbNumLeds = config["rgbNumLeds"]
5878
5979
matrixWiring = False
@@ -108,7 +128,7 @@ if config.get('splitPinB'):
108128
splitPinB = eval(renderPin(config['splitPinB']))
109129
110130
vbusPin = 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

Comments
 (0)