Skip to content

Commit 00b865d

Browse files
authored
Merge pull request #17 from sparkfun/release_candidate
Add support for multiple logos - resolves #14
2 parents 5b026d3 + 001e4d8 commit 00b865d

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

SparkFunKiCadPanelizer/panelizer/panelizer.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
149149
# Any PCB_TEXT containing any of these keywords will be copied into the ordering instructions
150150
possibleExtras = ['clean', 'Clean', 'CLEAN', 'stackup', 'Stackup', 'STACKUP']
151151

152+
# Possible logos and their default mask and silkscreen colors: seen, mask, silk
153+
possibleLogos = {
154+
"SparkFun_Logo": [False, "Red", "White"],
155+
"SparkX_Logo": [False, "Black", "White"],
156+
"SparkPNT_Logo": [False, "Red", "White"],
157+
}
158+
152159
sysExit = -1 # -1 indicates sysExit has not (yet) been set. The code below will set this to 0, 1, 2.
153160
report = "\nSTART: " + datetime.now().isoformat() + "\n"
154161

@@ -457,8 +464,6 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
457464
if PANEL_X or PANEL_Y:
458465
report += "You can fit " + str(NUM_X) + " x " + str(NUM_Y) + " boards on the panel.\n"
459466

460-
sparkfunLogoSeen = False
461-
sparkxLogoSeen = False
462467
solderMask = None
463468
silkscreen = None
464469
copperLayers = "Layers: {}".format(board.GetCopperLayerCount()) # Should we trust the instructions or the tracks?!
@@ -508,10 +513,9 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
508513
newModules = []
509514
prodIDs = []
510515
for sourceModule in modules:
511-
if "SparkFun_Logo" in sourceModule.GetFPIDAsString():
512-
sparkfunLogoSeen = True
513-
if "SparkX_Logo" in sourceModule.GetFPIDAsString():
514-
sparkxLogoSeen = True
516+
for logo in possibleLogos.keys():
517+
if logo in sourceModule.GetFPIDAsString():
518+
possibleLogos[logo][0] = True # Set 'seen' to True
515519
pos = sourceModule.GetPosition() # Check if footprint is outside the bounding box
516520
if pos.x >= boardLeftEdge and pos.x <= boardRightEdge and \
517521
pos.y >= boardTopEdge and pos.y <= boardBottomEdge:
@@ -557,12 +561,11 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
557561
for module in newModules:
558562
board.Add(module)
559563

560-
if sparkfunLogoSeen:
561-
solderMask = "Solder Mask: Red"
562-
silkscreen = "Silkscreen: White"
563-
if sparkxLogoSeen:
564-
solderMask = "Solder Mask: Black"
565-
silkscreen = "Silkscreen: White"
564+
for logo in possibleLogos.keys():
565+
if possibleLogos[logo][0] == True: # if seen
566+
solderMask = "Solder Mask: " + possibleLogos[logo][1]
567+
silkscreen = "Silkscreen: " + possibleLogos[logo][2]
568+
break
566569

567570
# Array of zones
568571
modules = board.GetFootprints()

0 commit comments

Comments
 (0)