Skip to content

Commit

Permalink
Add unique references for fiducials added by KiKit
Browse files Browse the repository at this point in the history
  • Loading branch information
yaqwsx committed Jun 27, 2023
1 parent d6b7294 commit cfe7fa1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions kikit/panelize.py
Expand Up @@ -1526,7 +1526,7 @@ def addNPTHole(self, position: VECTOR2I, diameter: KiLength,

def addFiducial(self, position: VECTOR2I, copperDiameter: KiLength,
openingDiameter: KiLength, bottom: bool = False,
paste: bool = False) -> None:
paste: bool = False, ref: Optional[str] = None) -> None:
"""
Add fiducial, i.e round copper pad with solder mask opening to the
position (`VECTOR2I`), with given copperDiameter and openingDiameter. By
Expand All @@ -1540,6 +1540,8 @@ def addFiducial(self, position: VECTOR2I, copperDiameter: KiLength,
# and KiCAD crashes.
self.board.Add(footprint)
footprint.SetPosition(position)
if ref is not None:
footprint.SetReference(ref)
for pad in footprint.Pads():
pad.SetSize(toKiCADPoint((copperDiameter, copperDiameter)))
pad.SetLocalSolderMaskMargin(int((openingDiameter - copperDiameter) / 2))
Expand Down Expand Up @@ -1574,9 +1576,11 @@ def addCornerFiducials(self, fidCount: int, horizontalOffset: KiLength,
The offsets are measured from the outer edges of the substrate.
"""
for pos in self.panelCorners(horizontalOffset, verticalOffset)[:fidCount]:
self.addFiducial(pos, copperDiameter, openingDiameter, False, paste)
self.addFiducial(pos, copperDiameter, openingDiameter, True, paste)
for i, pos in enumerate(self.panelCorners(horizontalOffset, verticalOffset)[:fidCount]):
self.addFiducial(pos, copperDiameter, openingDiameter, False,
paste, ref = f"KiKit_FID_T_{i+1}")
self.addFiducial(pos, copperDiameter, openingDiameter, True,
paste, ref = f"KiKit_FID_B_{i+1}")

def addCornerTooling(self, holeCount, horizontalOffset, verticalOffset,
diameter, paste=False):
Expand Down

0 comments on commit cfe7fa1

Please sign in to comment.