Exemplo n.º 1
0
 def NPTHRoundPad(self, drill):
     pad = pcbnew.D_PAD(self.module)
     pad.SetSize(pcbnew.wxSize(drill, drill))
     pad.SetShape(pcbnew.PAD_SHAPE_CIRCLE)
     pad.SetAttribute(pcbnew.PAD_ATTRIB_HOLE_NOT_PLATED)
     pad.SetLayerSet(pad.UnplatedHoleMask())
     pad.SetDrillSize(pcbnew.wxSize(drill, drill))
     return pad
 def NPTHRoundPad(self, drill):
     pad = pcbnew.D_PAD(self.module)
     pad.SetSize(pcbnew.wxSize(drill, drill))
     pad.SetShape(pcbnew.PAD_SHAPE_CIRCLE)
     pad.SetAttribute(pcbnew.PAD_ATTRIB_HOLE_NOT_PLATED)
     pad.SetLayerSet(pad.UnplatedHoleMask())
     pad.SetDrillSize(pcbnew.wxSize(drill, drill))
     return pad
Exemplo n.º 3
0
def hole_module(board, size, drill_size, pos, net, pad_type="round"):
    pos = pcbnew.wxPoint(pos[0], pos[1])
    main_hole_size_wx = pcbnew.wxSize(size, size)
    main_hole_drill_size_wx = pcbnew.wxSize(drill_size, drill_size)
    module = pcbnew.MODULE(board)
    module.SetPosition(pos)
    hole_pad(board, module, main_hole_size_wx, main_hole_drill_size_wx, pos,
             net, pad_type)
    board.Add(module)
Exemplo n.º 4
0
    def THPad(self, Vsize, Hsize, drill, shape=pcbnew.PAD_SHAPE_OVAL, rot_degree = 0):
        pad = pcbnew.D_PAD(self.module)
        pad.SetSize(pcbnew.wxSize(Hsize, Vsize))
        pad.SetShape(shape)
        pad.SetAttribute(pcbnew.PAD_ATTRIB_STANDARD)
        pad.SetLayerSet(pad.StandardMask())
        pad.SetDrillSize(pcbnew.wxSize(drill, drill))
        pad.SetOrientation(rot_degree*10)   # rotation is in 0.1 degrees

        return pad
Exemplo n.º 5
0
    def THPad(self, Vsize, Hsize, drill, shape=pcbnew.PAD_SHAPE_OVAL, rot_degree = 0):
        pad = pcbnew.D_PAD(self.module)
        pad.SetSize(pcbnew.wxSize(Hsize, Vsize))
        pad.SetShape(shape)
        pad.SetAttribute(pcbnew.PAD_ATTRIB_STANDARD)
        pad.SetLayerSet(pad.StandardMask())
        pad.SetDrillSize(pcbnew.wxSize(drill, drill))
        pad.SetOrientation(rot_degree*10)   # rotation is in 0.1 degrees

        return pad
Exemplo n.º 6
0
 def addNPTHole(self, position, diameter):
     """
     Add a drilled non-plated hole to the position (`wxPoint`) with given
     diameter.
     """
     module = pcbnew.PCB_IO().FootprintLoad(KIKIT_LIB, "NPTH")
     module.SetPosition(position)
     for pad in module.Pads():
         pad.SetDrillSize(pcbnew.wxSize(diameter, diameter))
         pad.SetSize(pcbnew.wxSize(diameter, diameter))
     self.board.Add(module)
Exemplo n.º 7
0
    def ThermalVia(self, size, drill, shape=pcbnew.PAD_SHAPE_CIRCLE):
        pad = pcbnew.D_PAD(self.module)
        pad.SetSize(pcbnew.wxSize(size,size))

        pad.SetShape(shape)

        pad.SetAttribute(pcbnew.PAD_ATTRIB_THERMAL_VIA)
        pad.SetLayerSet(pad.ThermalVia())
        pad.SetDrillSize(pcbnew.wxSize(drill, drill))
        
        return pad
Exemplo n.º 8
0
    def THPad(self, w, l, drill, shape = pcbnew.PAD_OVAL):
        pad = pcbnew.D_PAD(self.module)

        pad.SetSize(pcbnew.wxSize(l, w))

        pad.SetShape(shape)

        pad.SetAttribute(pcbnew.PAD_STANDARD)
        pad.SetLayerMask(pcbnew.PAD_STANDARD_DEFAULT_LAYERS)
        pad.SetDrillSize(pcbnew.wxSize(drill, drill))

        return pad
Exemplo n.º 9
0
    def THPad(self, w, l, drill, shape=pcbnew.PAD_SHAPE_OVAL):
        pad = pcbnew.D_PAD(self.module)

        pad.SetSize(pcbnew.wxSize(l, w))

        pad.SetShape(shape)

        pad.SetAttribute(pcbnew.PAD_ATTRIB_STANDARD)
        pad.SetLayerSet(pad.StandardMask())
        pad.SetDrillSize(pcbnew.wxSize(drill, drill))

        return pad
Exemplo n.º 10
0
    def THPad(self, w, l, drill, shape = pcbnew.PAD_OVAL):
        pad = pcbnew.D_PAD(self.module)

        pad.SetSize(pcbnew.wxSize(l, w))

        pad.SetShape(shape)

        pad.SetAttribute(pcbnew.PAD_STANDARD)
        pad.SetLayerSet(pad.StandardMask())
        pad.SetDrillSize(pcbnew.wxSize(drill, drill))

        return pad
Exemplo n.º 11
0
    def NPTHRoundPad(self, drill):
        """!
        A round non-plated though hole (NPTH)

        @param drill: the drill diameter (equals the NPTH diameter)
        """
        pad = pcbnew.D_PAD(self.module)
        pad.SetSize(pcbnew.wxSize(drill, drill))
        pad.SetShape(pcbnew.PAD_SHAPE_CIRCLE)
        pad.SetAttribute(pcbnew.PAD_ATTRIB_HOLE_NOT_PLATED)
        pad.SetLayerSet(pad.UnplatedHoleMask())
        pad.SetDrillSize(pcbnew.wxSize(drill, drill))
        return pad
Exemplo n.º 12
0
    def BuildThisFootprint(self):

        pads = self.parameters["Pads"]

        rows = pads["*row count"]
        cols = pads["*column count"]
        pad_size = pads["pad size"]

        pad_size = pcbnew.wxSize(pad_size, pad_size)

        pad_pitch = pads["pad pitch"]

        # add in the pads
        pad = PA.PadMaker(self.module).SMTRoundPad(pads["pad size"])

        pin1_pos = pcbnew.wxPoint(-((cols - 1) * pad_pitch) / 2,
                                  -((rows - 1) * pad_pitch) / 2)

        array = BGAPadGridArray(pad, cols, rows, pad_pitch, pad_pitch)
        array.AddPadsToModule(self.draw)

        #box
        ssx = -pin1_pos.x + pads["outline x margin"]
        ssy = -pin1_pos.y + pads["outline y margin"]

        self.draw.BoxWithDiagonalAtCorner(0, 0, ssx*2, ssy*2,
                                          pads["outline x margin"])

        #reference and value
        text_size = pcbnew.FromMM(1.2)  # IPC nominal

        self.draw.Value(0, - ssy - text_size, text_size)
        self.draw.Reference(0, ssy + text_size, text_size)
Exemplo n.º 13
0
    def BuildThisFootprint(self):

        pads = self.parameters["Pads"]

        rows = pads["*row count"]
        cols = pads["*column count"]
        pad_size = pads["pad size"]

        pad_size = pcbnew.wxSize(pad_size, pad_size)

        pad_pitch = pads["pad pitch"]

        # add in the pads
        pad = PA.PadMaker(self.module).SMTRoundPad(pads["pad size"])

        pin1_pos = pcbnew.wxPoint(-((cols - 1) * pad_pitch) / 2,
                                  -((rows - 1) * pad_pitch) / 2)

        array = BGAPadGridArray(pad, cols, rows, pad_pitch, pad_pitch)
        array.AddPadsToModule(self.draw)

        #box
        ssx = -pin1_pos.x + pads["outline x margin"]
        ssy = -pin1_pos.y + pads["outline y margin"]

        self.draw.BoxWithDiagonalAtCorner(0, 0, ssx * 2, ssy * 2,
                                          pads["outline x margin"])

        #reference and value
        text_size = pcbnew.FromMM(1.2)  # IPC nominal

        self.draw.Value(0, -ssy - text_size, text_size)
        self.draw.Reference(0, ssy + text_size, text_size)
Exemplo n.º 14
0
def SetRefSize(SizeMM, ThicknessMM):
    board = pcbnew.GetBoard()

    for module in board.GetModules():
        module.Reference().SetTextSize(
            pcbnew.wxSize(pcbnew.FromMM(SizeMM), pcbnew.FromMM(SizeMM)))
        module.Reference().SetThickness(pcbnew.FromMM(ThicknessMM))
Exemplo n.º 15
0
def generate_text_hint(board, text, width, height, thickness, x, y):
    txt = pcbnew.TEXTE_PCB(board)
    txt.SetText(text)
    txt.SetPosition(pcbnew.wxPoint(int(x), int(y)))
    txt.SetHorizJustify(pcbnew.GR_TEXT_HJUSTIFY_CENTER)
    txt.SetTextSize(pcbnew.wxSize(int(width), int(height)))
    txt.SetThickness(int(thickness))
    return txt
Exemplo n.º 16
0
def draw_text(board, text, x, y):
    txtmod = pcbnew.TEXTE_PCB(board)
    txtmod.SetText(text)
    txtmod.SetPosition(pcbnew.wxPoint(int(x), int(y)))
    txtmod.SetHorizJustify(pcbnew.GR_TEXT_HJUSTIFY_CENTER)
    txtmod.SetTextSize(pcbnew.wxSize(0.75 * MM_TO_KC, 1 * MM_TO_KC))
    txtmod.SetThickness(int(0.1 * MM_TO_KC))
    txtmod.SetLayer(pcbnew.F_SilkS)
    board.Add(txtmod)
Exemplo n.º 17
0
def create_Text(pcb, txt, p, w, lyr):
    mytxt = pcbnew.TEXTE_PCB(pcb)
    mytxt.SetText(txt)
    mytxt.SetLayer(lyr)
    mytxt.SetPosition(p)
    mytxt.SetHorizJustify(pcbnew.GR_TEXT_HJUSTIFY_CENTER)
    mytxt.SetTextSize(pcbnew.wxSize(w,w))
    mytxt.SetThickness(int(w/4))
    pcb.Add(mytxt)
    def Value(self, x, y, size):
        """
        As for references, draw the module's value
        """
        text_size = pcbnew.wxSize(size, size)

        self.module.Value().SetPos0(self.TransformPoint(x, y))
        self.module.Value().SetTextPosition(self.module.Value().GetPos0())
        self.module.Value().SetSize(text_size)
    def SMDPad(self, Vsize, Hsize, shape=pcbnew.PAD_SHAPE_RECT, rot_degree=0):
        pad = pcbnew.D_PAD(self.module)
        pad.SetSize(pcbnew.wxSize(Hsize, Vsize))
        pad.SetShape(shape)
        pad.SetAttribute(pcbnew.PAD_ATTRIB_SMD)
        pad.SetLayerSet(pad.SMDMask())
        pad.SetOrientation(rot_degree*10)   # rotation is in 0.1 degrees

        return pad
Exemplo n.º 20
0
    def SMDPad(self, Vsize, Hsize, shape=pcbnew.PAD_SHAPE_RECT, rot_degree=0):
        pad = pcbnew.D_PAD(self.module)
        pad.SetSize(pcbnew.wxSize(Hsize, Vsize))
        pad.SetShape(shape)
        pad.SetAttribute(pcbnew.PAD_ATTRIB_SMD)
        pad.SetLayerSet(pad.SMDMask())
        pad.SetOrientation(rot_degree*10)   # rotation is in 0.1 degrees

        return pad
Exemplo n.º 21
0
    def THPad(self, Vsize, Hsize, drill, shape=pcbnew.PAD_SHAPE_OVAL,
              rot_degree = 0):
        """!
        A basic through-hole pad of the given size and shape
        @param Vsize: the vertical size of the pad
        @param Hsize: the horizontal size of the pad
        @param drill: the drill diameter
        @param shape: the shape of the pad
        @param rot_degree: the pad rotation, in degrees
        """
        pad = pcbnew.D_PAD(self.module)
        pad.SetSize(pcbnew.wxSize(Hsize, Vsize))
        pad.SetShape(shape)
        pad.SetAttribute(pcbnew.PAD_ATTRIB_STANDARD)
        pad.SetLayerSet(pad.StandardMask())
        pad.SetDrillSize(pcbnew.wxSize(drill, drill))
        pad.SetOrientation(rot_degree*10)   # rotation is in 0.1 degrees

        return pad
Exemplo n.º 22
0
    def TaperFootprint(self, center=pcbnew.wxPoint(0,0), angle_deg=0):
        self.module = pcbnew.MODULE(None)

        #                6
        # 5 +------------+
        #   |            |\
        #   |            | \ 7
        #   |            |  +---+ 0
        #   |            |  |   |
        #   |            |  +---+ 1
        #   |            | / 2
        #   |            |/
        # 4 +------------+
        #                3
        points = [(self.w2/2, -self.w2/2), (self.w2/2, self.w2/2), (-self.w2/2, self.w2/2), \
                  (-self.w2/2 - self.tlen, self.w1/2), (-(self.w1/2 + self.tlen + self.w2/2), self.w1/2), \
                  (-(self.w1/2 + self.tlen + self.w2/2), -self.w1/2), (-self.w2/2 - self.tlen, -self.w1/2), \
                  (-self.w2/2, -self.w2/2)]

        points = [pcbnew.wxPoint(*point) for point in points]

        # Custom pad for smaller W2 x W2 pad
        cs_pad = pcbnew.D_PAD(self.module)
        cs_pad.SetSize(pcbnew.wxSize(self.w2, self.w2))
        cs_pad.SetShape(pcbnew.PAD_SHAPE_CUSTOM)
        cs_pad.SetAnchorPadShape(pcbnew.PAD_SHAPE_RECT)
        cs_pad.SetAttribute(pcbnew.PAD_ATTRIB_SMD)
        cs_pad.SetLayerSet(pcbnew.LSET(pcbnew.F_Cu))
        cs_pad.AddPrimitive(points, 0)
        cs_pad.SetLocalClearance(1)
        cs_pad.SetNet(self.net)
        cs_pad.SetPadName("1")

        self.module.Add(cs_pad)
        self.module.Add(Layout.smdRectPad(self.module, pcbnew.wxSize(self.w1, self.w1), pcbnew.wxPoint(-(self.w1/2 + self.tlen + self.w2/2), 0), "1", angle_deg, self.net))

        # TODO: Address other layers...

        self.module.SetPosition(center)

        # Add to pcbnew
        pcbnew.GetBoard().Add(self.module)
        pcbnew.Refresh()
Exemplo n.º 23
0
    def SMDPad(self, w, l, shape=pcbnew.PAD_SHAPE_RECT):
        pad = pcbnew.D_PAD(self.module)
        pad.SetSize(pcbnew.wxSize(l, w))

        pad.SetShape(shape)

        pad.SetAttribute(pcbnew.PAD_ATTRIB_SMD)
        pad.SetLayerSet(pad.SMDMask())

        return pad
Exemplo n.º 24
0
    def SMDPad(self, w, l, shape = pcbnew.PAD_RECT):
        pad = pcbnew.D_PAD(self.module)
        pad.SetSize(pcbnew.wxSize(l, w))

        pad.SetShape(shape)

        pad.SetAttribute(pcbnew.PAD_SMD)
        pad.SetLayerMask(pcbnew.PAD_SMD_DEFAULT_LAYERS)

        return pad
Exemplo n.º 25
0
    def SMDPad(self, w, l, shape = pcbnew.PAD_RECT):
        pad = pcbnew.D_PAD(self.module)
        pad.SetSize(pcbnew.wxSize(l, w))

        pad.SetShape(shape)

        pad.SetAttribute(pcbnew.PAD_SMD)
        pad.SetLayerSet(pad.SMDMask())

        return pad
Exemplo n.º 26
0
def get_via_module(board, drill, diameter, net):
    n = 'VIA-{}-{}'.format(fmt(drill), fmt(diameter))

    # instantiate new module
    m = pcbnew.MODULE(board)
    m.SetReference('REF**')
    m.SetValue(n)
    m.SetLastEditTime(pcbnew.GetNewTimeStamp())

    # adjust reference and value display settings
    r = m.Reference()
    r.SetVisible(False)
    r.SetTextSize(pcbnew.wxSize(mm2kicad(0.3), mm2kicad(0.3)))
    r.SetThickness(mm2kicad(0.075))
    v = m.Value()
    v.SetVisible(False)
    v.SetTextSize(pcbnew.wxSize(mm2kicad(0.3), mm2kicad(0.3)))
    v.SetThickness(mm2kicad(0.075))
    #v.SetLayer() # TODO: Move value to F.Fab layer (F.SilkS is default)

    lib_id = pcbnew.LIB_ID(n)
    m.SetFPID(lib_id)

    # create through-hole pad
    pad = pcbnew.D_PAD(m)
    pad.SetPadName('1')
    pad.SetNet(net)
    pad.SetPosition(pcbnew.wxPoint(0, 0))

    pad.SetShape(pcbnew.PAD_SHAPE_CIRCLE)
    pad.SetSize(pcbnew.wxSize(diameter, diameter))

    pad.SetDrillShape(pcbnew.PAD_DRILL_SHAPE_CIRCLE)
    pad.SetDrillSize(pcbnew.wxSize(drill, drill))

    pad.SetLayerSet(pcbnew.LSET.AllCuMask())
    pad.SetZoneConnection(pcbnew.PAD_ZONE_CONN_FULL)

    # add pad to module
    m.Add(pad)

    return m
Exemplo n.º 27
0
    def Value(self, x, y, size, orientation_degree = 0):
        """
        As for references, draw the module's value
        """
        text_size = pcbnew.wxSize(size, size)

        self.module.Value().SetPos0(self.TransformPoint(x, y))
        self.module.Value().SetTextPosition(self.module.Value().GetPos0())
        self.module.Value().SetSize(text_size)
        self.module.Value().SetLayer(self.DefaultTextValueLayer())
        self.module.Value().SetOrientation(orientation_degree*10)   # internal angles are in 0.1 deg
    def Value(self, x, y, size, orientation_degree = 0):
        """
        As for references, draw the module's value
        """
        text_size = pcbnew.wxSize(size, size)

        self.module.Value().SetPos0(self.TransformPoint(x, y))
        self.module.Value().SetPosition(self.module.Value().GetPos0())
        self.module.Value().SetTextSize(text_size)
        self.module.Value().SetLayer(self.DefaultTextValueLayer())
        self.module.Value().SetTextAngle(orientation_degree*10)   # internal angles are in 0.1 deg
Exemplo n.º 29
0
 def build(self,
           board: pcbnew.BOARD,
           external_signals: dict[str, pcbnew.NETINFO_ITEM] = {},
           path: list[str] = []):
     o = pcbnew.PCB_TEXT(board)
     o.SetText(self.text)
     o.SetHorizJustify(pcbnew.GR_TEXT_HJUSTIFY_CENTER)
     o.SetTextSize(
         pcbnew.wxSize(pcbnew.FromMM(self.size), pcbnew.FromMM(self.size)))
     o.SetTextThickness(pcbnew.FromMM(self.size * self.thickness * 0.15))
     o.SetLayer(self.layer)
     set_pcb_position(o, self.pcbpos)
     board.Add(o)
Exemplo n.º 30
0
def DrawText(board,
             text_str,
             layer,
             pos,
             size=int(1.5 * pcbnew.IU_PER_MM),
             thickness=None,
             h_align=pcbnew.GR_TEXT_HJUSTIFY_CENTER):
    if thickness == None:
        thickness = int(size / 7.5)
    text = pcbnew.TEXTE_PCB(board)
    text.SetText(text_str)
    text.SetPosition(pcbnew.wxPoint(*pos))
    try:
        # this fails in version 4.0.x
        text.SetTextSize(pcbnew.wxSize(size, size))
    except AttributeError:
        # this fails in nightly 20171105 version
        text.SetSize(pcbnew.wxSize(size, size))
    text.SetThickness(thickness)
    text.SetHorizJustify(h_align)
    text.SetLayer(layer)
    board.Add(text)
    def Reference(self, x, y, size):
        """
        Draw the module's reference as the given point.

        The actual setting of the reference is not done in this drawing
        aid - that is up to the wizard
        """

        text_size = pcbnew.wxSize(size, size)

        self.module.Reference().SetPos0(pcbnew.wxPoint(x, y))
        self.module.Reference().SetTextPosition(self.module.Reference().GetPos0())
        self.module.Reference().SetSize(text_size)
Exemplo n.º 32
0
Arquivo: test.py Projeto: Pokour/kicad
def write_text():

    board = pcbnew.GetBoard()
    layertable = get_layertable()
    x = 0
    for y in range(0, 100 * SCALE, SCALE * 10):
        text = pcbnew.TEXTE_PCB(board)
        text.SetText("HOLA: %d, %d" % (x, y))
        text.SetPosition(pcbnew.wxPoint(x, y))
        text.SetTextSize(pcbnew.wxSize(SCALE * 8, SCALE * 8))
        text.SetThickness(SCALE * 1)
        text.SetLayer(layertable["F.SilkS"])
        board.Add(text)
    pcbnew.Refresh()
    def Reference(self, x, y, size):
        """
        Draw the module's reference as the given point.

        The actual setting of the reference is not done in this drawing
        aid - that is up to the wizard
        """

        text_size = pcbnew.wxSize(size, size)

        self.module.Reference().SetPos0(self.TransformPoint(x, y))
        self.module.Reference().SetTextPosition(
            self.module.Reference().GetPos0())
        self.module.Reference().SetSize(text_size)
Exemplo n.º 34
0
 def _drawSolderMaskOpening(self, sizex, sizey, radius):
     # Draw the solder mask opening
     pad = pcbnew.D_PAD(self.module)
     pad.SetSize(pcbnew.wxSize(sizex, sizey))
     #TODO: Add fancy radius, once I figure out where to set the radius...
     # pad.SetShape(pcbnew.PAD_SHAPE_ROUNDRECT)
     pad.SetShape(pcbnew.PAD_SHAPE_RECT)
     pad.SetAttribute(pcbnew.PAD_ATTRIB_SMD)
     layerset = pcbnew.LSET()
     layerset.AddLayer(pcbnew.F_Mask)
     pad.SetLayerSet( layerset )
     pad.SetLocalSolderMaskMargin( -1 )
     pad.SetPosition(pcbnew.wxPoint(0, 0))
     pad.SetPadName("")
     self.module.Add(pad)
    def Reference(self, x, y, size, orientation_degree = 0):
        """
        Draw the module's reference as the given point.

        The actual setting of the reference is not done in this drawing
        aid - that is up to the wizard
        """

        text_size = pcbnew.wxSize(size, size)

        self.module.Reference().SetPos0(self.TransformPoint(x, y))
        self.module.Reference().SetPosition(
            self.module.Reference().GetPos0())
        self.module.Reference().SetTextSize(text_size)
        self.module.Reference().SetTextAngle(orientation_degree*10)   # internal angles are in 0.1 deg
Exemplo n.º 36
0
    def Reference(self, x, y, size, orientation_degree = 0):
        """
        Draw the module's reference as the given point.

        The actual setting of the reference is not done in this drawing
        aid - that is up to the wizard
        """

        text_size = pcbnew.wxSize(size, size)

        self.module.Reference().SetPos0(self.TransformPoint(x, y))
        self.module.Reference().SetTextPosition(
            self.module.Reference().GetPos0())
        self.module.Reference().SetSize(text_size)
        self.module.Reference().SetOrientation(orientation_degree*10)   # internal angles are in 0.1 deg
Exemplo n.º 37
0
 def addFiducial(self, position, copperDiameter, openingDiameter, bottom=False):
     """
     Add fiducial, i.e round copper pad with solder mask opening to the position (`wxPoint`),
     with given copperDiameter and openingDiameter. By setting bottom to True, the fiducial
     is placed on bottom side.
     """
     module = pcbnew.PCB_IO().FootprintLoad(KIKIT_LIB, "Fiducial")
     module.SetPosition(position)
     if(bottom):
         module.Flip(position)
     for pad in module.Pads():
         pad.SetSize(pcbnew.wxSize(copperDiameter, copperDiameter))
         pad.SetLocalSolderMaskMargin(int((openingDiameter - copperDiameter) / 2))
         pad.SetLocalClearance(int((openingDiameter - copperDiameter) / 2))
     self.board.Add(module)
Exemplo n.º 38
0
    def BuildThisFootprint(self):

        pads = self.parameters["Pads"]

        rows = pads["*row count"]
        cols = pads["*column count"]
        pad_size = pads["pad size"]
        pad_size = pcbnew.wxSize(pad_size, pad_size)
        pad_pitch = pads["pad pitch"]

        # add in the pads
        pad = PA.PadMaker(self.module).SMTRoundPad(pads["pad size"])

        pin1_pos = pcbnew.wxPoint(-((cols - 1) * pad_pitch) / 2,
                                  -((rows - 1) * pad_pitch) / 2)

        array = BGAPadGridArray(pad, cols, rows, pad_pitch, pad_pitch)
        array.AddPadsToModule(self.draw)

        #box
        ssx = -pin1_pos.x + pads["outline x margin"]
        ssy = -pin1_pos.y + pads["outline y margin"]

        self.draw.BoxWithDiagonalAtCorner(0, 0, ssx*2, ssy*2,
                                          pads["outline x margin"])

        # Courtyard
        cmargin = self.draw.GetLineThickness()
        self.draw.SetLayer(pcbnew.F_CrtYd)
        sizex = (ssx + cmargin) * 2
        sizey = (ssy + cmargin) * 2
        # round size to nearest 0.1mm, rectangle will thus land on a 0.05mm grid
        sizex = self.PutOnGridMM(sizex, 0.1)
        sizey = self.PutOnGridMM(sizey, 0.1)
        # set courtyard line thickness to the one defined in KLC
        self.draw.SetLineThickness(pcbnew.FromMM(0.05))
        self.draw.Box(0, 0, sizex, sizey)
        # restore line thickness to previous value
        self.draw.SetLineThickness(pcbnew.FromMM(cmargin))

        #reference and value
        text_size = self.GetTextSize()  # IPC nominal
        ypos = ssy + text_size
        self.draw.Value(0, ypos, text_size)
        self.draw.Reference(0, -ypos, text_size)

        # set SMD attribute
        self.module.SetAttributes(pcbnew.MOD_CMS)
Exemplo n.º 39
0
 def _drawPixel(self, xposition, yposition):
     # build a rectangular pad: as a dot
     pad = pcbnew.D_PAD(self.module)
     pad.SetSize(pcbnew.wxSize(self.X, self.X))
     pad.SetShape(pcbnew.PAD_SHAPE_RECT)
     pad.SetAttribute(pcbnew.PAD_ATTRIB_SMD)
     layerset = pcbnew.LSET()
     if self.UseCu:
         layerset.AddLayer(pcbnew.F_Cu)
     if self.UseSilkS:
         layerset.AddLayer(pcbnew.F_SilkS)
     pad.SetLayerSet( layerset )
     pad.SetLocalSolderMaskMargin( -1 )
     pad.SetPosition(pcbnew.wxPoint(xposition,yposition))
     pad.SetPadName("")
     self.module.Add(pad)
    def Value(self, x, y, size, orientation_degree=0):
        """!
        As for references, draw the module's value

        @param x: the x position of the value
        @param y: the y position of the value
        @param size: the text size (in both directions)
        @param orientation_degree: text orientation in degrees
        """
        text_size = pcbnew.wxSize(size, size)

        self.module.Value().SetPos0(self.TransformPoint(x, y))
        self.module.Value().SetPosition(self.module.Value().GetPos0())
        self.module.Value().SetTextSize(text_size)
        self.module.Value().SetLayer(self.DefaultTextValueLayer())
        # internal angles are in 0.1 deg
        self.module.Value().SetTextAngle(orientation_degree * 10)
Exemplo n.º 41
0
    def Value(self, x, y, size, orientation_degree=0):
        """!
        As for references, draw the module's value

        @param x: the x position of the value
        @param y: the y position of the value
        @param size: the text size (in both directions)
        @param orientation_degree: text orientation in degrees
        """
        text_size = pcbnew.wxSize(size, size)

        self.module.Value().SetPos0(self.TransformPoint(x, y))
        self.module.Value().SetPosition(self.module.Value().GetPos0())
        self.module.Value().SetTextSize(text_size)
        self.module.Value().SetLayer(self.DefaultTextValueLayer())
        # internal angles are in 0.1 deg
        self.module.Value().SetTextAngle(orientation_degree * 10)
Exemplo n.º 42
0
    def SMDPad(self, Vsize, Hsize, shape=pcbnew.PAD_SHAPE_RECT, rot_degree=0):
        """
        Create a surface-mount pad of the given size and shape
        @param Vsize: the vertical size of the pad
        @param Hsize: the horizontal size of the pad
        @param drill: the drill diameter
        @param shape: the shape of the pad
        @param rot_degree: the pad rotation, in degrees
        """
        pad = pcbnew.D_PAD(self.module)
        pad.SetSize(pcbnew.wxSize(Hsize, Vsize))
        pad.SetShape(shape)
        pad.SetAttribute(pcbnew.PAD_ATTRIB_SMD)
        pad.SetLayerSet(pad.SMDMask())
        pad.SetOrientation(rot_degree*10)   # rotation is in 0.1 degrees

        return pad
Exemplo n.º 43
0
 def _drawPixel(self, xposition, yposition):
     # build a rectangular pad as a dot on copper layer,
     # and a polygon (a square) on silkscreen
     if self.UseCu:
         pad = pcbnew.D_PAD(self.module)
         pad.SetSize(pcbnew.wxSize(self.X, self.X))
         pad.SetPosition(pcbnew.wxPoint(xposition,yposition))
         pad.SetShape(pcbnew.PAD_SHAPE_RECT)
         pad.SetAttribute(pcbnew.PAD_ATTRIB_SMD)
         pad.SetName("")
         layerset = pcbnew.LSET()
         layerset.AddLayer(pcbnew.F_Cu)
         layerset.AddLayer(pcbnew.F_Mask)
         pad.SetLayerSet( layerset )
         self.module.Add(pad)
     if self.UseSilkS:
         polygon=self.drawSquareArea(pcbnew.F_SilkS, self.X, xposition, yposition)
         self.module.Add(polygon)
Exemplo n.º 44
0
    def get_modules_bounding_box(modules):
        # get the pivot bounding box
        bounding_box = modules[0].mod.GetFootprintRect()
        top = bounding_box.GetTop()
        bottom = bounding_box.GetBottom()
        left = bounding_box.GetLeft()
        right = bounding_box.GetRight()
        for mod in modules:
            mod_box = mod.mod.GetFootprintRect()
            top = min(top, mod_box.GetTop())
            bottom = max(bottom, mod_box.GetBottom())
            left = min(left, mod_box.GetLeft())
            right = max(right, mod_box.GetRight())

        position = pcbnew.wxPoint(left, top)
        size = pcbnew.wxSize(right - left, bottom - top)
        bounding_box = pcbnew.EDA_RECT(position, size)
        return bounding_box
    def Reference(self, x, y, size, orientation_degree=0):
        """!
        Draw the module's reference as the given point.

        The actual setting of the reference is not done in this drawing
        aid - that is up to the wizard

        @param x: the x position of the reference
        @param y: the y position of the reference
        @param size: the text size (in both directions)
        @param orientation_degree: text orientation in degrees
        """

        text_size = pcbnew.wxSize(size, size)

        self.module.Reference().SetPos0(self.TransformPoint(x, y))
        self.module.Reference().SetPosition(
            self.module.Reference().GetPos0())
        self.module.Reference().SetTextSize(text_size)
        # internal angles are in 0.1 deg
        self.module.Reference().SetTextAngle(orientation_degree * 10)
    def BuildThisFootprint(self):

        pads = self.parameters["Pads"]

        rows = pads["*row count"]
        cols = pads["*column count"]
        pad_size = pads["pad size"]
        pad_size = pcbnew.wxSize(pad_size, pad_size)
        pad_pitch = pads["pad pitch"]

        # add in the pads
        pad = PA.PadMaker(self.module).SMTRoundPad(pads["pad size"])

        pin1_pos = pcbnew.wxPoint(-((cols - 1) * pad_pitch) / 2,
                                  -((rows - 1) * pad_pitch) / 2)

        array = BGAPadGridArray(pad, cols, rows, pad_pitch, pad_pitch)
        array.AddPadsToModule(self.draw)

        #box
        ssx = -pin1_pos.x + pads["outline x margin"]
        ssy = -pin1_pos.y + pads["outline y margin"]

        self.draw.BoxWithDiagonalAtCorner(0, 0, ssx*2, ssy*2,
                                          pads["outline x margin"])

        # Courtyard
        cmargin = self.draw.GetLineTickness()
        self.draw.SetLayer(pcbnew.F_CrtYd)
        sizex = (ssx + cmargin) * 2
        sizey = (ssy + cmargin) * 2
        self.draw.Box(0, 0, sizex, sizey)

        #reference and value
        text_size = self.GetTextSize()  # IPC nominal
        ypos = ssy + text_size
        self.draw.Value(0, ypos, text_size)
        self.draw.Reference(0, -ypos, text_size)
    def BuildThisFootprint(self):
        p = self.parameters
        pad_count       = int(p["Pads"]["*n"])
        pad_width       = p["Pads"]["width"]
        pad_height      = p["Pads"]["height"]
        pad_pitch       = p["Pads"]["pitch"]
        shl_width       = p["Shield"]["width"]
        shl_height      = p["Shield"]["height"]
        shl_to_pad      = p["Shield"]["shield_to_pad"]
        shl_from_top    = p["Shield"]["from_top"]

        offsetX         = pad_pitch * ( pad_count-1 ) / 2
        size_pad = pcbnew.wxSize( pad_width, pad_height )
        size_shld = pcbnew.wxSize(shl_width, shl_height)
        size_text = pcbnew.FromMM( 0.8 )

        textposy = pad_height/2 + pcbnew.FromMM(1)
        self.draw.Value( 0, textposy, size_text )

        textposy = textposy + pcbnew.FromMM( 1.2 )
        self.draw.Reference( 0, textposy, size_text )

        # create a pad array and add it to the module
        for n in range ( 0, pad_count ):
            xpos = pad_pitch*n - offsetX
            pad = self.smdRectPad(self.module,size_pad, pcbnew.wxPoint(xpos,0),str(n+1))
            self.module.Add(pad)


        # Mechanical shield pads: left pad and right pad
        xpos = -shl_to_pad-offsetX
        pad_s0_pos = pcbnew.wxPoint(xpos,shl_from_top)
        pad_s0 = self.smdRectPad(self.module, size_shld, pad_s0_pos, "0")
        xpos = (pad_count-1) * pad_pitch+shl_to_pad - offsetX
        pad_s1_pos = pcbnew.wxPoint(xpos,shl_from_top)
        pad_s1 = self.smdRectPad(self.module, size_shld, pad_s1_pos, "0")

        self.module.Add(pad_s0)
        self.module.Add(pad_s1)

        #add outline
        outline = pcbnew.EDGE_MODULE(self.module)
        linewidth = pcbnew.FromMM(0.2)
        outline.SetWidth(linewidth)
        margin = pcbnew.FromMM(0.2)

        # upper line
        posy = -pad_height/2 - linewidth/2 - margin
        xstart = - pad_pitch*0.5-offsetX
        xend = pad_pitch * pad_count + xstart;
        outline.SetStartEnd( pcbnew.wxPoint(xstart, posy), pcbnew.wxPoint( xend, posy) )
        outline.SetLayer(pcbnew.F_SilkS)               #default: not needed
        outline.SetShape(pcbnew.S_SEGMENT)
        self.module.Add(outline)

        # lower line
        outline1 = outline.Duplicate()      #copy all settings from outline
        posy = pad_height/2 + linewidth/2 + margin
        outline1.SetStartEnd(pcbnew.wxPoint(xstart, posy), pcbnew.wxPoint( xend, posy))
        self.module.Add(outline1)

        # around left mechanical pad (the outline around right pad is mirrored/y axix)
        outline2 = outline.Duplicate()  # vertical segment
        yend = pad_s0_pos.y + shl_height/2 + margin
        outline2.SetStartEnd(pcbnew.wxPoint(xstart, posy), pcbnew.wxPoint( xstart, yend))
        self.module.Add(outline2)
        outline2_d = pcbnew.EDGE_MODULE(self.module)  # right pad side
        outline2_d.Copy(outline2)
        outline2_d.SetStartEnd(pcbnew.wxPoint(-xstart, posy), pcbnew.wxPoint( -xstart, yend))
        self.module.Add(outline2_d)

        outline3 = outline.Duplicate()  # horizontal segment below the pad
        posy = yend
        xend = pad_s0_pos.x - (shl_width/2 + linewidth + margin*2)
        outline3.SetStartEnd(pcbnew.wxPoint(xstart, posy), pcbnew.wxPoint( xend, posy))
        self.module.Add(outline3)
        outline3_d = pcbnew.EDGE_MODULE(self.module)  # right pad side
        outline3_d.Copy(outline3)
        outline3_d.SetStartEnd(pcbnew.wxPoint(-xstart, posy), pcbnew.wxPoint( -xend, yend))
        self.module.Add(outline3_d)

        outline4 = outline.Duplicate()  # vertical segment at left of the pad
        xstart = xend
        yend = posy - (shl_height + linewidth + margin*2)
        outline4.SetStartEnd(pcbnew.wxPoint(xstart, posy), pcbnew.wxPoint( xend, yend))
        self.module.Add(outline4)
        outline4_d = outline.Duplicate()  # right pad side
        outline4_d.SetStartEnd(pcbnew.wxPoint(-xstart, posy), pcbnew.wxPoint( -xend, yend))
        self.module.Add(outline4_d)

        outline5 = outline.Duplicate()  # horizontal segment above the pad
        xstart = xend
        xend = - pad_pitch*0.5-offsetX
        posy = yend
        outline5.SetStartEnd(pcbnew.wxPoint(xstart, posy), pcbnew.wxPoint( xend, yend))
        self.module.Add(outline5)
        outline5_d = outline.Duplicate()  # right pad side
        outline5_d.SetStartEnd(pcbnew.wxPoint(-xstart, posy), pcbnew.wxPoint( -xend, yend))
        self.module.Add(outline5_d)

        outline6 = outline.Duplicate()  # vertical segment above the pad
        xstart = xend
        yend = -pad_height/2 - linewidth/2 - margin
        outline6.SetStartEnd(pcbnew.wxPoint(xstart, posy), pcbnew.wxPoint( xend, yend))
        self.module.Add(outline6)
        outline6_d = outline.Duplicate()  # right pad side
        outline6_d.SetStartEnd(pcbnew.wxPoint(-xstart, posy), pcbnew.wxPoint( -xend, yend))
        self.module.Add(outline6_d)
Exemplo n.º 48
0
    def BuildFootprint(self):
        if self.has_errors():
            print "Cannot build footprint: Parameters have errors:"
            print self.parameter_errors
            return

        print "Building new QFP footprint with the following parameters:"
        self.print_parameter_table()

        self.module = pcbnew.MODULE(None) # create a new module

        pads = self.parameters
        num_pads = int(pads["Pads"]["*n"])
        pad_width = pads["Pads"]["width"]
        pad_length = pads["Pads"]["length"]
        pad_pitch = pads["Pads"]["pitch"]
        pad_horizontal_pitch = pads["Pads"]["horizontal pitch"]
        pad_vertical_pitch = pads["Pads"]["vertical pitch"]

        package_width = pads["Package"]["width"]
        package_height = pads["Package"]["height"]

        side_length = pad_pitch * ((num_pads / 4) - 1)

        offsetX = pad_pitch * ((num_pads / 4) - 1) / 2
        text_size = pcbnew.wxSize(pcbnew.FromMM(0.8), pcbnew.FromMM(0.8))

        self.module.SetReference("QFP %d" % int(num_pads))
        self.module.Reference().SetPos0(pcbnew.wxPoint(0, pcbnew.FromMM(-0.8)))
        self.module.Reference().SetTextPosition(self.module.Reference().GetPos0())
        self.module.Reference().SetSize(text_size)

        self.module.SetValue("U**")
        self.module.Value().SetPos0(pcbnew.wxPoint(0, pcbnew.FromMM(+0.8)))
        self.module.Value().SetTextPosition(self.module.Value().GetPos0())
        self.module.Value().SetSize(text_size)

        fpid = pcbnew.FPID(self.module.GetReference())   #the name in library
        self.module.SetFPID( fpid )

        pad_size_left_right = pcbnew.wxSize(pad_length, pad_width)
        pad_size_bottom_top = pcbnew.wxSize(pad_width, pad_length)

        for cur_pad in range(0, num_pads):
            side = int(cur_pad / (num_pads / 4)) # 0 -> left, 1 -> bottom, 2 -> right, 3 -> top

            if side == 0 or side == 2:
                pad_size = pad_size_left_right

                pad_pos_x = -(pad_horizontal_pitch / 2)
                pad_pos_y = (cur_pad % (num_pads / 4)) * pad_pitch - (side_length / 2)

                if side == 2:
                    pad_pos_x = -pad_pos_x
                    pad_pos_y = -pad_pos_y

            else:
                pad_size = pad_size_bottom_top

                pad_pos_x = (cur_pad % (num_pads / 4)) * pad_pitch - (side_length / 2)
                pad_pos_y = -(pad_vertical_pitch / 2)

                if side == 1:
                    pad_pos_y = -pad_pos_y
                else:
                    pad_pos_x = -pad_pos_x

            pad_pos = pcbnew.wxPoint(pad_pos_x, pad_pos_y)

            pad = self.smd_rect_pad(self.module, pad_size, pad_pos, str(cur_pad + 1))

            self.module.Add(pad)

        half_package_width = package_width / 2
        half_package_height = package_height / 2

        package_pad_height_offset = abs(package_height - side_length) / 2 - pad_pitch
        package_pad_width_offset = abs(package_width - side_length) / 2 - pad_pitch

        # Bottom Left Edge, vertical line
        outline = pcbnew.EDGE_MODULE(self.module)
        outline.SetWidth(pcbnew.FromMM(0.2))
        outline.SetLayer(pcbnew.SILKSCREEN_N_FRONT)
        outline.SetShape(pcbnew.S_SEGMENT)
        start = pcbnew.wxPoint(-half_package_width, half_package_height - package_pad_height_offset)
        end = pcbnew.wxPoint(-half_package_width, half_package_height)
        outline.SetStartEnd(start, end)
        self.module.Add(outline)

        # Bottom Left Edge, horizontal line
        outline = pcbnew.EDGE_MODULE(self.module)
        outline.SetWidth(pcbnew.FromMM(0.2))
        outline.SetLayer(pcbnew.SILKSCREEN_N_FRONT)
        outline.SetShape(pcbnew.S_SEGMENT)
        start = pcbnew.wxPoint(-half_package_width, half_package_height)
        end = pcbnew.wxPoint(-half_package_width + package_pad_width_offset, half_package_height)
        outline.SetStartEnd(start, end)
        self.module.Add(outline)

        # Bottom Right Edge, vertical line
        outline = pcbnew.EDGE_MODULE(self.module)
        outline.SetWidth(pcbnew.FromMM(0.2))
        outline.SetLayer(pcbnew.SILKSCREEN_N_FRONT)
        outline.SetShape(pcbnew.S_SEGMENT)
        start = pcbnew.wxPoint(half_package_width, half_package_height - package_pad_height_offset)
        end = pcbnew.wxPoint(half_package_width, half_package_height)
        outline.SetStartEnd(start, end)
        self.module.Add(outline)

        # Bottom Right Edge, horizontal line
        outline = pcbnew.EDGE_MODULE(self.module)
        outline.SetWidth(pcbnew.FromMM(0.2))
        outline.SetLayer(pcbnew.SILKSCREEN_N_FRONT)
        outline.SetShape(pcbnew.S_SEGMENT)
        start = pcbnew.wxPoint(half_package_width, half_package_height)
        end = pcbnew.wxPoint(half_package_width - package_pad_width_offset, half_package_height)
        outline.SetStartEnd(start, end)
        self.module.Add(outline)

        # Top Right Edge, vertical line
        outline = pcbnew.EDGE_MODULE(self.module)
        outline.SetWidth(pcbnew.FromMM(0.2))
        outline.SetLayer(pcbnew.SILKSCREEN_N_FRONT)
        outline.SetShape(pcbnew.S_SEGMENT)
        start = pcbnew.wxPoint(half_package_width, -half_package_height + package_pad_height_offset)
        end = pcbnew.wxPoint(half_package_width, -half_package_height)
        outline.SetStartEnd(start, end)
        self.module.Add(outline)

        # Top Right Edge, horizontal line
        outline = pcbnew.EDGE_MODULE(self.module)
        outline.SetWidth(pcbnew.FromMM(0.2))
        outline.SetLayer(pcbnew.SILKSCREEN_N_FRONT)
        outline.SetShape(pcbnew.S_SEGMENT)
        start = pcbnew.wxPoint(half_package_width, -half_package_height)
        end = pcbnew.wxPoint(half_package_width - package_pad_width_offset, -half_package_height)
        outline.SetStartEnd(start, end)
        self.module.Add(outline)

        # Top Left Edge, straight line
        outline = pcbnew.EDGE_MODULE(self.module)
        outline.SetWidth(pcbnew.FromMM(0.2))
        outline.SetLayer(pcbnew.SILKSCREEN_N_FRONT)
        outline.SetShape(pcbnew.S_SEGMENT)
        start = pcbnew.wxPoint(-half_package_width, -half_package_height + package_pad_height_offset)
        end = pcbnew.wxPoint(-half_package_width + package_pad_width_offset, -half_package_height)
        outline.SetStartEnd(start, end)
        self.module.Add(outline)
Exemplo n.º 49
0
    def BuildThisFootprint(self):
        p = self.parameters
        pad_count       = int(p["Pads"]["n"])
        pad_width       = p["Pads"]["width"]
        pad_height      = p["Pads"]["height"]
        pad_pitch       = p["Pads"]["pitch"]
        shl_width       = p["Shield"]["width"]
        shl_height      = p["Shield"]["height"]
        shl_to_pad      = p["Shield"]["shield_to_pad"]
        shl_from_top    = p["Shield"]["from_top"]

        offsetX         = pad_pitch * ( pad_count-1 ) / 2
        size_pad = pcbnew.wxSize( pad_width, pad_height )
        size_shld = pcbnew.wxSize(shl_width, shl_height)
        size_text = self.GetTextSize()  # IPC nominal

        # Gives a position and size to ref and value texts:
        textposy = pad_height/2 + pcbnew.FromMM(1) + self.GetTextThickness()
        angle_degree = 0.0
        self.draw.Reference( 0, textposy, size_text, angle_degree )

        textposy = textposy + size_text + self.GetTextThickness()
        self.draw.Value( 0, textposy, size_text )

        # create a pad array and add it to the module
        for n in range ( 0, pad_count ):
            xpos = pad_pitch*n - offsetX
            pad = self.smdRectPad(self.module,size_pad, pcbnew.wxPoint(xpos,0),str(n+1))
            self.module.Add(pad)


        # Mechanical shield pads: left pad and right pad
        xpos = -shl_to_pad-offsetX
        pad_s0_pos = pcbnew.wxPoint(xpos,shl_from_top)
        pad_s0 = self.smdRectPad(self.module, size_shld, pad_s0_pos, "0")
        xpos = (pad_count-1) * pad_pitch+shl_to_pad - offsetX
        pad_s1_pos = pcbnew.wxPoint(xpos,shl_from_top)
        pad_s1 = self.smdRectPad(self.module, size_shld, pad_s1_pos, "0")

        self.module.Add(pad_s0)
        self.module.Add(pad_s1)

        # add footprint outline
        self.draw.SetLineThickness( pcbnew.FromMM( 0.12 ) ) #Default per KLC F5.1 as of 12/2018
        linewidth = self.draw.GetLineThickness()
        margin = linewidth

        # upper line
        posy = -pad_height/2 - linewidth/2 - margin
        xstart = - pad_pitch*0.5-offsetX
        xend = pad_pitch * pad_count + xstart;
        min_y = posy
        max_y = posy
        self.draw.Line( xstart, posy, xend, posy )

        # lower line
        posy = pad_height/2 + linewidth/2 + margin
        max_y = max( max_y, posy )
        self.draw.Line(xstart, posy, xend, posy)

        # around left mechanical pad (the outline around right pad is mirrored/y axix)
        yend = pad_s0_pos.y + shl_height/2 + margin
        max_y = max( max_y, yend )
        self.draw.Line(xstart, posy, xstart, yend)
        self.draw.Line(-xstart, posy, -xstart, yend)

        posy = yend
        xend = pad_s0_pos.x - (shl_width/2 + linewidth + margin*2)
        max_x = -xend
        self.draw.Line(xstart, posy, xend, posy)

        # right pad side
        self.draw.Line(-xstart, posy, -xend, yend)

        # set SMD attribute
        self.module.SetAttributes(pcbnew.MOD_CMS)

        # vertical segment at left of the pad
        xstart = xend
        yend = posy - (shl_height + linewidth + margin*2)
        self.draw.Line(xstart, posy, xend, yend)

        # right pad side
        self.draw.Line(-xstart, posy, -xend, yend)
        max_y = max( max_y, posy )
        min_y = min( min_y, yend )

        # horizontal segment above the pad
        xstart = xend
        xend = - pad_pitch*0.5-offsetX
        posy = yend
        self.draw.Line(xstart, posy, xend, yend)

        # right pad side
        self.draw.Line(-xstart, posy,-xend, yend)

        # vertical segment above the pad
        xstart = xend
        yend = -pad_height/2 - linewidth/2 - margin
        min_y = min( min_y, yend )
        self.draw.Line(xstart, posy, xend, yend)

        # right pad side
        self.draw.Line(-xstart, posy, -xend, yend)
        
        # Courtyard
        self.draw.SetLayer(pcbnew.F_CrtYd)
        max_x = max_x + linewidth + margin
        min_y = min_y - linewidth - margin
        max_y = max_y + linewidth + margin 
        
        # round size to nearest 0.1mm, rectangle will thus land on a 0.05mm grid
        max_x = pcbnew.PutOnGridMM(max_x, 0.05)
        max_y = pcbnew.PutOnGridMM(max_y, 0.05)
        min_y = pcbnew.PutOnGridMM(min_y, 0.05)
        
        # set courtyard line thickness to the one defined in KLC
        self.draw.SetLineThickness(pcbnew.FromMM(0.05))
        self.draw.Line( -max_x, min_y, max_x, min_y )
        self.draw.Line( max_x, min_y, max_x, max_y )
        self.draw.Line( -max_x, max_y, max_x, max_y )
        self.draw.Line( -max_x, min_y, -max_x, max_y )
    def BuildThisFootprint(self):
        p = self.parameters
        pad_count    = int(p["Pads"]["*n"])
        pad_width    = p["Pads"]["width"]
        pad_height   = p["Pads"]["height"]
        pad_pitch    = p["Pads"]["pitch"]
        shl_width    = p["Shield"]["width"]
        shl_height   = p["Shield"]["height"]
        shl_to_pad   = p["Shield"]["shield_to_pad"]
        shl_from_top = p["Shield"]["from_top"]

        offsetX = pad_pitch * (pad_count-1) / 2
        size_pad = pcbnew.wxSize(pad_width, pad_height)
        size_shld = pcbnew.wxSize(shl_width, shl_height)
        size_text = self.GetTextSize()  # IPC nominal

        # Gives a position and size to ref and value texts:
        textposy = pad_height/2 + pcbnew.FromMM(1) + self.GetTextThickness()
        self.draw.Reference(0, textposy, size_text)

        textposy = textposy + size_text + self.GetTextThickness()
        self.draw.Value(0, textposy, size_text)

        # create a pad array and add it to the module
        for n in xrange(0, pad_count):
            xpos = pad_pitch*n - offsetX
            pad = self.smdRectPad(self.module, size_pad,
                                  pcbnew.wxPoint(xpos, 0), str(n+1))
            self.module.Add(pad)


        # Mechanical shield pads: left pad and right pad
        xpos = -shl_to_pad-offsetX
        pad_s0_pos = pcbnew.wxPoint(xpos, shl_from_top)
        pad_s0 = self.smdRectPad(self.module, size_shld, pad_s0_pos, "0")
        xpos = (pad_count-1) * pad_pitch+shl_to_pad - offsetX
        pad_s1_pos = pcbnew.wxPoint(xpos, shl_from_top)
        pad_s1 = self.smdRectPad(self.module, size_shld, pad_s1_pos, "0")

        self.module.Add(pad_s0)
        self.module.Add(pad_s1)

        # add footprint outline
        linewidth = self.draw.GetLineTickness()
        margin = linewidth

        # upper line
        posy = -pad_height/2 - linewidth/2 - margin
        xstart = -pad_pitch*0.5-offsetX
        xend = pad_pitch * pad_count + xstart
        self.draw.Line(xstart, posy, xend, posy)

        # lower line
        posy = pad_height/2 + linewidth/2 + margin
        self.draw.Line(xstart, posy, xend, posy)

        # around left mechanical pad (the outline around right pad is mirrored/y axix)
        yend = pad_s0_pos.y + shl_height/2 + margin
        self.draw.Line(xstart, posy, xstart, yend)
        self.draw.Line(-xstart, posy, -xstart, yend)

        posy = yend
        xend = pad_s0_pos.x - (shl_width/2 + linewidth + margin*2)
        self.draw.Line(xstart, posy, xend, posy)

        # right pad side
        self.draw.Line(-xstart, posy, -xend, yend)

        # vertical segment at left of the pad
        xstart = xend
        yend = posy - (shl_height + linewidth + margin*2)
        self.draw.Line(xstart, posy, xend, yend)

        # right pad side
        self.draw.Line(-xstart, posy, -xend, yend)

        # horizontal segment above the pad
        xstart = xend
        xend = -pad_pitch*0.5-offsetX
        posy = yend
        self.draw.Line(xstart, posy, xend, yend)

        # right pad side
        self.draw.Line(-xstart, posy, -xend, yend)

        # vertical segment above the pad
        xstart = xend
        yend = -pad_height/2 - linewidth/2 - margin
        self.draw.Line(xstart, posy, xend, yend)

        # right pad side
        self.draw.Line(-xstart, posy, -xend, yend)
Exemplo n.º 51
0
    def BuildThisFootprint(self):

        pads = self.parameters["Pads"]

        rows = pads["rows"]
        cols = pads["columns"]
        pad_size = pads["size"]
        pad_size = pcbnew.wxSize(pad_size, pad_size)
        pad_pitch = pads["pitch"]

        # add in the pads
        pad = PA.PadMaker(self.module).SMTRoundPad(pads["size"])

        pin1_pos = pcbnew.wxPoint(-((cols - 1) * pad_pitch) / 2,
                                  -((rows - 1) * pad_pitch) / 2)

        array = BGAPadGridArray(pad, cols, rows, pad_pitch, pad_pitch)
        array.AddPadsToModule(self.draw)

        # Draw box outline on F.Fab layer
        self.draw.SetLayer(pcbnew.F_Fab)
        ssx = self.parameters['Package']['width'] / 2
        ssy = self.parameters['Package']['length'] / 2

        # Bevel should be 1mm nominal but we'll allow smaller values
        if pcbnew.ToMM(ssx) < 1:
            bevel = ssx
        else:
            bevel = pcbnew.FromMM(1)

        # Box with 1mm bevel as per IPC7351C
        self.draw.SetLineThickness( pcbnew.FromMM( 0.1 ) ) #Default per KLC F5.2 as of 12/2018
        self.draw.BoxWithDiagonalAtCorner(0, 0, ssx*2, ssy*2, bevel)

        # Add IPC markings to F_Silk layer
        self.draw.SetLayer( pcbnew.F_SilkS )
        self.draw.SetLineThickness( pcbnew.FromMM( 0.12 ) ) #Default per KLC F5.1 as of 12/2018
        offset = self.draw.GetLineThickness()
        len_x  = 0.5 * ssx
        len_y  = 0.5 * ssy

        edge = [
            [ ssx + offset - len_x, -ssy - offset],
            [ ssx + offset, -ssy - offset],
            [ ssx + offset, -ssy - offset + len_y],
               ]

        # Draw three square edges
        self.draw.Polyline(edge)
        self.draw.Polyline(edge, mirrorY=0)
        self.draw.Polyline(edge, mirrorX=0, mirrorY=0)

        # Draw pin-1 marker
        bevel += offset
        pin1 = [
            [ -ssx - offset + len_x, -ssy - offset],
            [ -ssx - offset + bevel, -ssy - offset],
            [ -ssx - offset, -ssy - offset + bevel],
            [ -ssx - offset, -ssy - offset + len_y],
                ]

        # Remove lines if the package is too small
        if bevel > len_x:
            pin1 = pin1[1:]

        if bevel > len_y:
            pin1 = pin1[:-1]

        self.draw.Polyline(pin1)

        # Draw a circle in the bevel void
        self.draw.Circle( -ssx, -ssy, pcbnew.FromMM(0.2), filled=True)

        # Courtyard
        cmargin = self.parameters['Package']['margin']
        self.draw.SetLayer(pcbnew.F_CrtYd)
        sizex = (ssx + cmargin) * 2
        sizey = (ssy + cmargin) * 2

        # round size to nearest 0.1mm, rectangle will thus land on a 0.05mm grid
        sizex = pcbnew.PutOnGridMM(sizex, 0.1)
        sizey = pcbnew.PutOnGridMM(sizey, 0.1)

        # set courtyard line thickness to the one defined in KLC
        self.draw.SetLineThickness(pcbnew.FromMM(0.05))
        self.draw.Box(0, 0, sizex, sizey)
        # restore line thickness to previous value
        self.draw.SetLineThickness(pcbnew.FromMM(cmargin))

        #reference and value
        text_size = self.GetTextSize()  # IPC nominal
        ypos = ssy + text_size
        self.draw.Value(0, ypos, text_size)
        self.draw.Reference(0, -ypos, text_size)

        # set SMD attribute
        self.module.SetAttributes(pcbnew.MOD_CMS)