diff --git a/src/kicad/libs/NGFF.pretty/NGFF_A+E.kicad_mod b/src/kicad/libs/NGFF.pretty/NGFF_A+E.kicad_mod new file mode 100644 index 0000000..38fc6df --- /dev/null +++ b/src/kicad/libs/NGFF.pretty/NGFF_A+E.kicad_mod @@ -0,0 +1,82 @@ +(module NGFF_A+E (layer F.Cu) (tedit 0) + (fp_text reference REF** (at 0 4) (layer F.SilkS) + (effects (font (size 1 1) (thickness 0.15))) + ) + (fp_text value NGFF_A+E (at 0 2) (layer F.Fab) + (effects (font (size 1 1) (thickness 0.15))) + ) + (fp_line (start 7.225 0) (end 9.925 0) (layer Edge.Cuts) (width 0.05)) + (fp_line (start 3.225 0) (end 6.025 0) (layer Edge.Cuts) (width 0.05)) + (fp_line (start -9.925 0) (end 2.025 0) (layer Edge.Cuts) (width 0.05)) + (fp_line (start 10.425 -4) (end 11 -4) (layer Edge.Cuts) (width 0.05)) + (fp_arc (start 10.425 -3.5) (end 9.925 -3.5) (angle 90) (layer Edge.Cuts) (width 0.05)) + (fp_line (start 9.925 0) (end 9.925 -3.5) (layer Edge.Cuts) (width 0.05)) + (fp_line (start 7.225 -2.9) (end 7.225 0) (layer Edge.Cuts) (width 0.05)) + (fp_arc (start 6.625 -2.9) (end 6.025 -2.9) (angle 180) (layer Edge.Cuts) (width 0.05)) + (fp_line (start 6.025 0) (end 6.025 -2.9) (layer Edge.Cuts) (width 0.05)) + (fp_line (start 3.225 -2.9) (end 3.225 0) (layer Edge.Cuts) (width 0.05)) + (fp_arc (start 2.625 -2.9) (end 2.025 -2.9) (angle 180) (layer Edge.Cuts) (width 0.05)) + (fp_line (start 2.025 0) (end 2.025 -2.9) (layer Edge.Cuts) (width 0.05)) + (fp_line (start -9.925 -3.5) (end -9.925 0) (layer Edge.Cuts) (width 0.05)) + (fp_arc (start -10.425 -3.5) (end -10.425 -4) (angle 90) (layer Edge.Cuts) (width 0.05)) + (fp_line (start -11 -4) (end -10.425 -4) (layer Edge.Cuts) (width 0.05)) + (pad 75 smd rect (at -9.25 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 74 smd rect (at -9 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 73 smd rect (at -8.75 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 72 smd rect (at -8.5 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 71 smd rect (at -8.25 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 70 smd rect (at -8 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 69 smd rect (at -7.75 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 68 smd rect (at -7.5 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 67 smd rect (at -7.25 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 66 smd rect (at -7 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 65 smd rect (at -6.75 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 64 smd rect (at -6.5 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 63 smd rect (at -6.25 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 62 smd rect (at -6 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 61 smd rect (at -5.75 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 60 smd rect (at -5.5 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 59 smd rect (at -5.25 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 58 smd rect (at -5 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 57 smd rect (at -4.75 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 56 smd rect (at -4.5 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 55 smd rect (at -4.25 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 54 smd rect (at -4 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 53 smd rect (at -3.75 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 52 smd rect (at -3.5 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 51 smd rect (at -3.25 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 50 smd rect (at -3 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 49 smd rect (at -2.75 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 48 smd rect (at -2.5 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 47 smd rect (at -2.25 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 46 smd rect (at -2 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 45 smd rect (at -1.75 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 44 smd rect (at -1.5 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 43 smd rect (at -1.25 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 42 smd rect (at -1 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 41 smd rect (at -0.75 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 40 smd rect (at -0.5 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 39 smd rect (at -0.25 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 38 smd rect (at 0 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 37 smd rect (at 0.25 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 36 smd rect (at 0.5 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 35 smd rect (at 0.75 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 34 smd rect (at 1 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 33 smd rect (at 1.25 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 32 smd rect (at 1.5 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 23 smd rect (at 3.75 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 22 smd rect (at 4 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 21 smd rect (at 4.25 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 20 smd rect (at 4.5 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 19 smd rect (at 4.75 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 18 smd rect (at 5 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 17 smd rect (at 5.25 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 16 smd rect (at 5.5 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 7 smd rect (at 7.75 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 6 smd rect (at 8 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 5 smd rect (at 8.25 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 4 smd rect (at 8.5 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 3 smd rect (at 8.75 -1.275) (size 0.35 1.45) (layers F.Cu)) + (pad 2 smd rect (at 9 -1.525) (size 0.35 1.95) (layers B.Cu)) + (pad 1 smd rect (at 9.25 -1.275) (size 0.35 1.45) (layers F.Cu)) +) diff --git a/src/kicad/libs/ngff.py b/src/kicad/libs/ngff.py index 6ed179a..d1ac2ef 100644 --- a/src/kicad/libs/ngff.py +++ b/src/kicad/libs/ngff.py @@ -3,43 +3,29 @@ import FootprintWizardBase # Dimensions from PCIe M.2 Specification rev 1.0 ยง2.3.5.2. -keyingFirst = { +keying = { "A": { - "Q": 6.625, - "R": 1.50, - "S": 14.50, - "T": 1.00, - "U": 14.50, + "KeyCenter": 6.625, # Distance from the center of the footprint to the center of the key "PinMin": 8, "PinMax": 15, }, "B": { - "Q": 5.625, - "R": 2.50, - "S": 13.50, - "T": 2.00, - "U": 13.50, + "KeyCenter": 5.625, "PinMin": 12, "PinMax": 19, }, "E": { - "Q": 2.625, - "R": 5.50, - "S": 10.50, - "T": 5.00, - "U": 10.50, + "KeyCenter": 2.625, "PinMin": 24, "PinMax": 31, }, -} - -keyingSecond = { + "G": { + "KeyCenter": -1.125, + "PinMin": 39, + "PinMax": 46, + }, "M": { - "V": 6.125, - "W": 14.00, - "X": 2.50, - "Y": 1.00, - "Z": 14.50, + "KeyCenter": -6.125, "PinMin": 59, "PinMax": 66, }, @@ -93,11 +79,11 @@ def GenerateParameterList(self): def firstKey(self): first = self.GetParam("Keying", "First").value - return keyingFirst.get(first, None) + return keying.get(first, None) def secondKey(self): second = self.GetParam("Keying", "Second").value - return keyingSecond.get(second, None) + return keying.get(second, None) def omitPin(self, number): firstKey = self.firstKey() @@ -166,14 +152,22 @@ def Arc(self, cx, cy, sx, sy, a): def CheckParameters(self): first = self.GetParam("Keying", "First") second = self.GetParam("Keying", "Second") - if first.value and first.value not in keyingFirst: - msg = "Unknown first keying: %s (supported: %s)" % (first, ", ".join(sorted(keyingFirst.keys()))) + if first.value and first.value not in keying: + msg = "Unknown first keying: %s (supported: %s)" % (first, ", ".join(sorted(keying.keys()))) first.AddError(msg) - if second.value and second.value not in keyingSecond: - msg = "Unknown second keying: %s (supported: %s)" % (second, ", ".join(sorted(keyingSecond.keys()))) + if second.value and second.value not in keying: + msg = "Unknown second keying: %s (supported: %s)" % (second, ", ".join(sorted(keying.keys()))) second.AddError(msg) + # if second key is "earlier" than the first key, swap them + # otherwise, there's some funky stuff happening? + if first.value and second.value: + if ord(first.value) > ord(second.value): + f, s = first.value, second.value + second.SetValue(f) + first.SetValue(s) + def FilledBox(self, x1, y1, x2, y2): box = pcbnew.EDGE_MODULE(self.module) box.SetShape(pcbnew.S_POLYGON); @@ -190,7 +184,7 @@ def FilledBox(self, x1, y1, x2, y2): def drawSolderMaskOpening(self, x1, x2, height, layer): rectCenterX = pcbnew.FromMM(0.0) rectCenterY = -height / 2.0 - + box = self.FilledBox(x1, pcbnew.FromMM(0.0), x2, -height) box.SetLayer(layer) self.draw.module.Add(box) @@ -231,77 +225,36 @@ def BuildThisFootprint(self): draw.Line(topLeftArcEndX, topLeftArcEndY, bottomLeftX, bottomLeftY) - if self.secondKey(): - # Distance from the center of the footprint to the center of the key - V = pcbnew.FromMM(self.secondKey()["V"]) - - secondKeyBottomLeftX = centerX - V - keyDiameter / 2.0 - secondKeyBottomLeftY = centerY + KeyArcAngle = 1800 # decidegrees - draw.Line(bottomLeftX, bottomLeftY, secondKeyBottomLeftX, secondKeyBottomLeftY) + # small inline function for notch drawing + def draw_key(KeyCenter): + leftX = centerX + KeyCenter - keyDiameter / 2.0 + rightX = leftX + keyDiameter + topY = centerY - keyHeight + keyDiameter / 2.0 + # left line + draw.Line(leftX, centerY, leftX, topY) + # right line + draw.Line(rightX, centerY, rightX, topY) + # arc + self.Arc(KeyCenter, topY, leftX, topY, KeyArcAngle) - secondKeyTopLeftX = secondKeyBottomLeftX - secondKeyTopLeftY = secondKeyBottomLeftY - keyHeight + keyDiameter / 2.0 + # keys go from left to right and it's more comfortable to preserve this order + # so, leftmost (second) key first - draw.Line(secondKeyBottomLeftX, secondKeyBottomLeftY, secondKeyTopLeftX, secondKeyTopLeftY) + for key in [self.secondKey(), self.firstKey()]: + if key: + KeyCenter = pcbnew.FromMM(key["KeyCenter"]) + draw_key(KeyCenter) - secondKeyCenterX = secondKeyTopLeftX + keyDiameter / 2.0 - secondKeyCenterY = secondKeyTopLeftY - secondKeyArcAngle = 1800 # decidegrees - - self.Arc(secondKeyCenterX, secondKeyCenterY, secondKeyTopLeftX, secondKeyTopLeftY, secondKeyArcAngle) - - secondKeyTopRightX = secondKeyTopLeftX + keyDiameter - secondKeyTopRightY = secondKeyTopLeftY - - secondKeyBottomRightX = secondKeyTopRightX - secondKeyBottomRightY = centerY - - draw.Line(secondKeyTopRightX, secondKeyTopRightY, secondKeyBottomRightX, secondKeyBottomRightY) - draw.Line(secondKeyBottomRightX, secondKeyBottomRightY, centerX, centerY) - - bottomEndpoints += [secondKeyBottomLeftX, secondKeyBottomRightX] - else: - draw.Line(bottomLeftX, bottomLeftY, centerX, centerY) + leftX = centerX + KeyCenter - keyDiameter / 2.0 + rightX = leftX + keyDiameter - # TODO: Implement the second key. + bottomEndpoints += [leftX, rightX] bottomRightX = connectorTongueWidth / 2.0 bottomRightY = centerY - if self.firstKey(): - # Distance from the center of the footprint to the center of the key - Q = pcbnew.FromMM(self.firstKey()["Q"]) - - firstKeyBottomLeftX = centerX + Q - keyDiameter / 2.0 - firstKeyBottomLeftY = centerY - - draw.Line(centerX, centerY, firstKeyBottomLeftX, firstKeyBottomLeftY) - - firstKeyTopLeftX = firstKeyBottomLeftX - firstKeyTopLeftY = firstKeyBottomLeftY - keyHeight + keyDiameter / 2.0 - - draw.Line(firstKeyBottomLeftX, firstKeyBottomLeftY, firstKeyTopLeftX, firstKeyTopLeftY) - - firstKeyCenterX = firstKeyTopLeftX + keyDiameter / 2.0 - firstKeyCenterY = firstKeyTopLeftY - firstKeyArcAngle = 1800 # decidegrees - - self.Arc(firstKeyCenterX, firstKeyCenterY, firstKeyTopLeftX, firstKeyTopLeftY, firstKeyArcAngle) - - firstKeyTopRightX = firstKeyTopLeftX + keyDiameter - firstKeyTopRightY = firstKeyTopLeftY - - firstKeyBottomRightX = firstKeyTopRightX - firstKeyBottomRightY = centerY - - draw.Line(firstKeyTopRightX, firstKeyTopRightY, firstKeyBottomRightX, firstKeyBottomRightY) - draw.Line(firstKeyBottomRightX, firstKeyBottomRightY, bottomRightX, bottomRightY) - - bottomEndpoints += [firstKeyBottomLeftX, firstKeyBottomRightX] - else: - draw.Line(centerX, centerY, bottomRightX, bottomRightY) - topRightArcStartX = bottomRightX topRightArcStartY = bottomRightY - connectorHeight + connectorBaseArcRadius @@ -326,6 +279,7 @@ def BuildThisFootprint(self): for endpoints in zip(bottomEndpoints[0::2], bottomEndpoints[1::2]): self.drawSolderMaskOpening(endpoints[0], endpoints[1], topPadHeight, pcbnew.F_Mask) self.drawSolderMaskOpening(endpoints[0], endpoints[1], bottomPadHeight, pcbnew.B_Mask) + draw.Line(endpoints[0], centerY, endpoints[1], centerY) # drawing the bottom lines for padNumber in range(1, 76): pad = self.createPad(padNumber, str(padNumber))