2014-09-14 16:29:10 +00:00
|
|
|
# PadArray.py
|
|
|
|
#
|
|
|
|
# Copyright 2014 john <john@johndev>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
# MA 02110-1301, USA.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
from __future__ import division
|
|
|
|
|
|
|
|
import math
|
2014-04-23 16:36:31 +00:00
|
|
|
import pcbnew
|
|
|
|
|
2018-06-13 11:13:37 +00:00
|
|
|
class PadMaker(object):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
Useful construction functions for common types of pads, providing
|
|
|
|
sensible defaults for common pads.
|
2014-04-23 16:36:31 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, module):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
@param module: the module the pads will be part of
|
|
|
|
"""
|
2014-04-23 16:36:31 +00:00
|
|
|
self.module = module
|
|
|
|
|
2018-06-13 11:05:12 +00:00
|
|
|
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
|
|
|
|
"""
|
2014-04-23 16:36:31 +00:00
|
|
|
pad = pcbnew.D_PAD(self.module)
|
2015-10-31 11:54:48 +00:00
|
|
|
pad.SetSize(pcbnew.wxSize(Hsize, Vsize))
|
2014-04-23 16:36:31 +00:00
|
|
|
pad.SetShape(shape)
|
2020-10-09 18:48:13 +00:00
|
|
|
pad.SetAttribute(pcbnew.PAD_ATTRIB_PTH)
|
|
|
|
pad.SetLayerSet(pad.PTHMask())
|
2014-04-23 16:36:31 +00:00
|
|
|
pad.SetDrillSize(pcbnew.wxSize(drill, drill))
|
2015-10-31 11:54:48 +00:00
|
|
|
pad.SetOrientation(rot_degree*10) # rotation is in 0.1 degrees
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
return pad
|
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
def THRoundPad(self, size, drill):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
A round though-hole pad. A shortcut for THPad()
|
|
|
|
@param size: pad diameter
|
|
|
|
@param drill: drill diameter
|
|
|
|
"""
|
2015-08-23 19:40:33 +00:00
|
|
|
pad = self.THPad(size, size, drill, shape=pcbnew.PAD_SHAPE_CIRCLE)
|
2014-09-14 16:29:10 +00:00
|
|
|
return pad
|
|
|
|
|
|
|
|
def NPTHRoundPad(self, drill):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
A round non-plated though hole (NPTH)
|
|
|
|
|
|
|
|
@param drill: the drill diameter (equals the NPTH diameter)
|
|
|
|
"""
|
2014-09-14 16:29:10 +00:00
|
|
|
pad = pcbnew.D_PAD(self.module)
|
|
|
|
pad.SetSize(pcbnew.wxSize(drill, drill))
|
2015-08-23 19:40:33 +00:00
|
|
|
pad.SetShape(pcbnew.PAD_SHAPE_CIRCLE)
|
|
|
|
pad.SetAttribute(pcbnew.PAD_ATTRIB_HOLE_NOT_PLATED)
|
2014-09-14 16:29:10 +00:00
|
|
|
pad.SetLayerSet(pad.UnplatedHoleMask())
|
|
|
|
pad.SetDrillSize(pcbnew.wxSize(drill, drill))
|
|
|
|
return pad
|
|
|
|
|
2015-10-31 11:54:48 +00:00
|
|
|
def SMDPad(self, Vsize, Hsize, shape=pcbnew.PAD_SHAPE_RECT, rot_degree=0):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""
|
|
|
|
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
|
|
|
|
"""
|
2014-04-23 16:36:31 +00:00
|
|
|
pad = pcbnew.D_PAD(self.module)
|
2015-10-31 11:54:48 +00:00
|
|
|
pad.SetSize(pcbnew.wxSize(Hsize, Vsize))
|
2014-04-23 16:36:31 +00:00
|
|
|
pad.SetShape(shape)
|
2015-08-23 19:40:33 +00:00
|
|
|
pad.SetAttribute(pcbnew.PAD_ATTRIB_SMD)
|
2014-07-02 13:08:28 +00:00
|
|
|
pad.SetLayerSet(pad.SMDMask())
|
2015-10-31 11:54:48 +00:00
|
|
|
pad.SetOrientation(rot_degree*10) # rotation is in 0.1 degrees
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
return pad
|
|
|
|
|
|
|
|
def SMTRoundPad(self, size):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
A round surface-mount pad. A shortcut for SMDPad()
|
|
|
|
@param size: pad diameter
|
|
|
|
"""
|
2015-08-23 19:40:33 +00:00
|
|
|
pad = self.SMDPad(size, size, shape=pcbnew.PAD_SHAPE_CIRCLE)
|
2014-04-23 16:36:31 +00:00
|
|
|
return pad
|
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
|
2018-06-13 11:13:37 +00:00
|
|
|
class PadArray(object):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
A class to assist in creating repetitive grids of pads
|
|
|
|
|
|
|
|
Generally, PadArrays have an internal prototypical pad, and copy this
|
|
|
|
for each pad in the array. They can also have a special pad for the
|
|
|
|
first pad, and a custom function to name the pad.
|
|
|
|
|
|
|
|
Generally, PadArray is used as a base class for more specific array
|
|
|
|
types.
|
|
|
|
"""
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2018-06-13 11:13:37 +00:00
|
|
|
def __init__(self, pad):
|
|
|
|
"""!
|
|
|
|
@param pad: the prototypical pad
|
|
|
|
"""
|
2014-09-14 16:29:10 +00:00
|
|
|
self.firstPadNum = 1
|
|
|
|
self.pinNames = None
|
2018-06-13 11:13:37 +00:00
|
|
|
|
|
|
|
# this pad is more of a "context", we will use it as a source of
|
|
|
|
# pad data, but not actually add it
|
|
|
|
self.pad = pad
|
2014-09-14 16:29:10 +00:00
|
|
|
self.firstPad = None
|
|
|
|
|
|
|
|
def SetPinNames(self, pinNames):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
Set a name for all the pins. If given, this overrides the
|
|
|
|
naming function.
|
|
|
|
|
|
|
|
@param pinNames: the name to use for all pins
|
2014-09-14 16:29:10 +00:00
|
|
|
"""
|
|
|
|
self.pinNames = pinNames
|
|
|
|
|
|
|
|
def SetFirstPadType(self, firstPad):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
If the array has a different first pad, this is the pad that
|
|
|
|
is used
|
|
|
|
@param firstPad: the prototypical first pad
|
|
|
|
"""
|
2014-09-14 16:29:10 +00:00
|
|
|
self.firstPad = firstPad
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
def SetFirstPadInArray(self, fpNum):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
Set the numbering for the first pad in the array
|
|
|
|
@param fpNum: the number for the first pad
|
|
|
|
"""
|
2014-09-14 16:29:10 +00:00
|
|
|
self.firstPadNum = fpNum
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
def AddPad(self, pad):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
Add a pad to the array, under the same moodule as the main
|
|
|
|
prototype pad
|
|
|
|
@param pad: pad to add
|
|
|
|
"""
|
2014-04-23 16:36:31 +00:00
|
|
|
self.pad.GetParent().Add(pad)
|
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
def GetPad(self, is_first_pad, pos):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
Get a pad in the array with the given position
|
|
|
|
@param is_first_pad: use the special first pad if there is one
|
|
|
|
@param pos: the pad position
|
|
|
|
"""
|
2014-09-14 16:29:10 +00:00
|
|
|
if (self.firstPad and is_first_pad):
|
|
|
|
pad = self.firstPad
|
|
|
|
else:
|
|
|
|
pad = self.pad
|
|
|
|
|
|
|
|
# create a new pad with same characteristics
|
|
|
|
pad = pad.Duplicate()
|
|
|
|
pad.SetPos0(pos)
|
|
|
|
pad.SetPosition(pos)
|
|
|
|
|
|
|
|
return pad
|
|
|
|
|
|
|
|
def GetName(self, *args, **kwargs):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
Get the pad name from the naming function, or the pre-set
|
|
|
|
pinNames parameter (set with SetPinNames)
|
|
|
|
"""
|
2014-09-14 16:29:10 +00:00
|
|
|
|
|
|
|
if self.pinNames is None:
|
|
|
|
return self.NamingFunction(*args, **kwargs)
|
|
|
|
|
|
|
|
return self.pinNames
|
|
|
|
|
|
|
|
def NamingFunction(self, *args, **kwargs):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
2014-09-14 16:29:10 +00:00
|
|
|
Implement this as needed for each array type
|
|
|
|
"""
|
|
|
|
raise NotImplementedError;
|
|
|
|
|
|
|
|
|
2014-04-23 16:36:31 +00:00
|
|
|
class PadGridArray(PadArray):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
A basic grid of pads
|
|
|
|
"""
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
def __init__(self, pad, nx, ny, px, py, centre=pcbnew.wxPoint(0, 0)):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
@param pad: the prototypical pad of the array
|
|
|
|
@param nx: number of pads in x-direction
|
|
|
|
@param ny: number of pads in y-direction
|
|
|
|
@param px: pitch in x-direction
|
|
|
|
@param py: pitch in y-direction
|
|
|
|
@param centre: array centre point
|
|
|
|
"""
|
2020-09-04 02:57:04 +00:00
|
|
|
super(PadGridArray, self).__init__(pad)
|
2018-06-13 11:05:12 +00:00
|
|
|
|
2014-04-23 16:36:31 +00:00
|
|
|
self.nx = int(nx)
|
|
|
|
self.ny = int(ny)
|
|
|
|
self.px = px
|
|
|
|
self.py = py
|
2014-09-14 16:29:10 +00:00
|
|
|
self.centre = centre
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
def AlphaNameFromNumber(self, n, aIndex=1,
|
|
|
|
alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ"):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
Utility function to generate an alphabetical name:
|
|
|
|
|
|
|
|
eg. 1 - A, 2 - B, 26 - AA, etc
|
|
|
|
|
|
|
|
@param aIndex: index of 'A': 0 for 0 - A
|
|
|
|
@param n: the pad index
|
|
|
|
@param alphabet: set of allowable chars if not A-Z,
|
|
|
|
e.g. ABCDEFGHJKLMNPRTUVWY for BGA
|
|
|
|
"""
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2014-05-02 06:28:40 +00:00
|
|
|
div, mod = divmod(n - aIndex, len(alphabet))
|
|
|
|
alpha = alphabet[mod]
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
if div > 0:
|
2014-09-14 16:29:10 +00:00
|
|
|
return self.AlphaNameFromNumber(div, aIndex, alphabet) + alpha
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
return alpha
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
def NamingFunction(self, x, y):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
Implementation of the naming function: right to left, top-to-bottom
|
|
|
|
|
|
|
|
@param x: the pad x index
|
|
|
|
@param y: the pad y index
|
|
|
|
"""
|
2014-09-14 16:29:10 +00:00
|
|
|
return self.firstPadNum + (self.nx * y + x)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
#relocate the pad and add it as many times as we need
|
2014-09-14 16:29:10 +00:00
|
|
|
def AddPadsToModule(self, dc):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
Create the pads and add them to the module in the correct positions
|
|
|
|
|
|
|
|
@param dc: the drawing context
|
|
|
|
"""
|
2014-09-14 16:29:10 +00:00
|
|
|
|
|
|
|
pin1posX = self.centre.x - self.px * (self.nx - 1) / 2
|
|
|
|
pin1posY = self.centre.y - self.py * (self.ny - 1) / 2
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
for x in range(0, self.nx):
|
2014-09-14 16:29:10 +00:00
|
|
|
posX = pin1posX + (x * self.px)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
for y in range(self.ny):
|
|
|
|
posY = pin1posY + (self.py * y)
|
|
|
|
pos = dc.TransformPoint(posX, posY)
|
|
|
|
pad = self.GetPad(x == 0 and y == 0, pos)
|
2017-08-11 09:22:13 +00:00
|
|
|
pad.SetName(self.GetName(x,y))
|
2014-04-23 16:36:31 +00:00
|
|
|
self.AddPad(pad)
|
|
|
|
|
2016-02-24 08:45:34 +00:00
|
|
|
|
2018-06-13 11:05:12 +00:00
|
|
|
class EPADGridArray(PadGridArray):
|
|
|
|
"""!
|
|
|
|
A pad grid array with a fixed name, used for things like thermal
|
|
|
|
pads and via grids.
|
|
|
|
"""
|
2016-02-24 08:45:34 +00:00
|
|
|
|
2018-06-13 11:05:12 +00:00
|
|
|
def NamingFunction(self, nx, ny):
|
|
|
|
"""!
|
|
|
|
Simply return the firstPadNum
|
|
|
|
@param nx: not used
|
|
|
|
@param ny: not used
|
|
|
|
"""
|
|
|
|
return self.firstPadNum
|
2016-02-24 08:45:34 +00:00
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
|
2015-10-31 11:54:48 +00:00
|
|
|
class PadZGridArray(PadArray):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
A staggered pin array
|
|
|
|
"""
|
2015-10-31 11:54:48 +00:00
|
|
|
|
|
|
|
def __init__(self, pad, pad_count, line_count, line_pitch,
|
|
|
|
pad_pitch, centre=pcbnew.wxPoint(0, 0)):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
@param pad: the prototypical pad
|
|
|
|
@param pad_count: total pad count
|
|
|
|
@param line_count: number of staggered lines
|
|
|
|
@param line_pitch: distance between lines
|
|
|
|
@param pad_pitch: distance between pads in a line
|
|
|
|
@param centre: array centre point
|
|
|
|
"""
|
2020-09-04 02:57:04 +00:00
|
|
|
super(PadZGridArray, self).__init__(pad)
|
2018-06-13 11:13:37 +00:00
|
|
|
|
2015-10-31 11:54:48 +00:00
|
|
|
self.pad_count = int(pad_count)
|
|
|
|
self.line_count = int(line_count)
|
|
|
|
self.line_pitch = line_pitch
|
|
|
|
self.pad_pitch = pad_pitch
|
|
|
|
self.centre = centre
|
|
|
|
|
|
|
|
def NamingFunction(self, pad_pos):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
Naming just increased with pad index in array
|
|
|
|
"""
|
2015-10-31 11:54:48 +00:00
|
|
|
return self.firstPadNum + pad_pos
|
|
|
|
|
|
|
|
def AddPadsToModule(self, dc):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
Create the pads and add them to the module in the correct positions
|
|
|
|
|
|
|
|
@param dc: the drawing context
|
|
|
|
"""
|
2015-10-31 11:54:48 +00:00
|
|
|
|
|
|
|
pin1posX = self.centre.x - self.pad_pitch * (self.pad_count - 1) / 2
|
|
|
|
pin1posY = self.centre.y + self.line_pitch * (self.line_count - 1) / 2
|
|
|
|
line = 0
|
|
|
|
|
|
|
|
for padnum in range(0, self.pad_count):
|
|
|
|
posX = pin1posX + (padnum * self.pad_pitch)
|
|
|
|
posY = pin1posY - (self.line_pitch * line)
|
|
|
|
|
|
|
|
pos = dc.TransformPoint(posX, posY)
|
|
|
|
pad = self.GetPad(padnum == 0, pos)
|
2017-08-11 09:22:13 +00:00
|
|
|
pad.SetName(self.GetName(padnum))
|
2015-10-31 11:54:48 +00:00
|
|
|
self.AddPad(pad)
|
|
|
|
|
|
|
|
line += 1
|
|
|
|
|
|
|
|
if line >= self.line_count:
|
|
|
|
line = 0
|
|
|
|
|
2018-06-13 11:05:12 +00:00
|
|
|
|
2014-04-23 16:36:31 +00:00
|
|
|
class PadLineArray(PadGridArray):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
Shortcut cases for a single-row grid array. Can be used for
|
|
|
|
constructing sections of larger footprints.
|
|
|
|
"""
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
def __init__(self, pad, n, pitch, isVertical,
|
|
|
|
centre=pcbnew.wxPoint(0, 0)):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
@param pad: the prototypical pad
|
|
|
|
@param n: number of pads in array
|
|
|
|
@param pitch: distance between pad centres
|
|
|
|
@param isVertical: horizontal or vertical array (can also use the
|
|
|
|
drawing contexts transforms for more control)
|
|
|
|
@param centre: array centre
|
|
|
|
"""
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
if isVertical:
|
2020-09-04 02:57:04 +00:00
|
|
|
super(PadLineArray, self).__init__(pad, 1, n, 0, pitch, centre)
|
2014-04-23 16:36:31 +00:00
|
|
|
else:
|
2020-09-04 02:57:04 +00:00
|
|
|
super(PadLineArray, self).__init__(pad, n, 1, pitch, 0, centre)
|
2014-09-14 16:29:10 +00:00
|
|
|
|
2018-06-13 11:05:12 +00:00
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
class PadCircleArray(PadArray):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
Circular pad array
|
|
|
|
"""
|
2014-09-14 16:29:10 +00:00
|
|
|
|
|
|
|
def __init__(self, pad, n, r, angle_offset=0, centre=pcbnew.wxPoint(0, 0),
|
2018-06-13 11:05:12 +00:00
|
|
|
clockwise=True, padRotationEnable=False, padRotationOffset=0):
|
|
|
|
"""!
|
|
|
|
@param pad: the prototypical pad
|
|
|
|
@param n: number of pads in array
|
|
|
|
@param r: the circle radius
|
|
|
|
@param angle_offset: angle of the first pad
|
|
|
|
@param centre: array centre point
|
|
|
|
@param clockwise: array increases in a clockwise direction
|
|
|
|
@param padRotationEnable: also rotate pads when placing
|
|
|
|
@param padRotationOffset: rotation of first pad
|
|
|
|
"""
|
|
|
|
|
2020-09-04 02:57:04 +00:00
|
|
|
super(PadCircleArray, self).__init__(pad)
|
2018-06-13 11:13:37 +00:00
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
self.n = int(n)
|
|
|
|
self.r = r
|
|
|
|
self.angle_offset = angle_offset
|
|
|
|
self.centre = centre
|
|
|
|
self.clockwise = clockwise
|
2018-01-03 16:11:27 +00:00
|
|
|
self.padRotationEnable = padRotationEnable
|
|
|
|
self.padRotationOffset = padRotationOffset
|
2014-09-14 16:29:10 +00:00
|
|
|
|
|
|
|
def NamingFunction(self, n):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
Naming around the circle, CW or CCW according to the clockwise flag
|
|
|
|
"""
|
2014-09-14 16:29:10 +00:00
|
|
|
return str(self.firstPadNum + n)
|
|
|
|
|
|
|
|
def AddPadsToModule(self, dc):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
Create the pads and add them to the module in the correct positions
|
|
|
|
|
|
|
|
@param dc: the drawing context
|
|
|
|
"""
|
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
for pin in range(0, self.n):
|
|
|
|
angle = self.angle_offset + (360 / self.n) * pin
|
|
|
|
|
|
|
|
if not self.clockwise:
|
|
|
|
angle = -angle
|
|
|
|
|
|
|
|
pos_x = math.sin(angle * math.pi / 180) * self.r
|
|
|
|
pos_y = -math.cos(angle * math.pi / 180) * self.r
|
|
|
|
pos = dc.TransformPoint(pos_x, pos_y)
|
|
|
|
pad = self.GetPad(pin == 0, pos)
|
2018-01-03 16:11:27 +00:00
|
|
|
padAngle = self.padRotationOffset
|
|
|
|
if self.padRotationEnable:
|
|
|
|
padAngle -=angle
|
|
|
|
pad.SetOrientation(padAngle*10)
|
2017-08-11 09:22:13 +00:00
|
|
|
pad.SetName(self.GetName(pin))
|
2014-09-14 16:29:10 +00:00
|
|
|
self.AddPad(pad)
|
|
|
|
|
2018-06-13 11:05:12 +00:00
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
class PadCustomArray(PadArray):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
2014-09-14 16:29:10 +00:00
|
|
|
Layout pads according to a custom array of [x,y] data
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, pad, array):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
@param pad: the prototypical pad
|
|
|
|
@param array: the position data array
|
|
|
|
"""
|
2020-09-04 02:57:04 +00:00
|
|
|
super(PadCustomArray, self).__init__(pad)
|
2018-06-13 11:13:37 +00:00
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
self.array = array
|
|
|
|
|
|
|
|
def NamingFunction(self, n):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
Simple increment along the given array
|
|
|
|
@param n: the pad index in the array
|
|
|
|
"""
|
2014-09-14 16:29:10 +00:00
|
|
|
return str(self.firstPadNum + n)
|
|
|
|
|
|
|
|
def AddPadsToModule(self, dc):
|
2018-06-13 11:05:12 +00:00
|
|
|
"""!
|
|
|
|
Create the pads and add them to the module in the correct positions
|
|
|
|
|
|
|
|
@param dc: the drawing context
|
|
|
|
"""
|
2014-09-14 16:29:10 +00:00
|
|
|
|
|
|
|
for i in range(len(self.array)):
|
|
|
|
pos = dc.TransformPoint(self.array[i][0], self.array[i][1])
|
|
|
|
pad = self.GetPad(i == 0, pos)
|
2017-08-11 09:22:13 +00:00
|
|
|
pad.SetName(self.GetName(i))
|
2014-09-14 16:29:10 +00:00
|
|
|
self.AddPad(pad)
|