22from __future__
import division
29 Useful construction functions for common types of pads, providing
30 sensible defaults
for common pads.
35 @param module: the module the pads will be part of
39 def THPad(self, Vsize, Hsize, drill, shape=pcbnew.PAD_SHAPE_OVAL,
42 A basic through-hole pad of the given size and shape
43 @param Vsize: the vertical size of the pad
44 @param Hsize: the horizontal size of the pad
45 @param drill: the drill diameter
46 @param shape: the shape of the pad
47 @param rot_degree: the pad rotation,
in degrees
52 pad.SetAttribute(pcbnew.PAD_ATTRIB_PTH)
53 pad.SetLayerSet(pad.PTHMask())
55 pad.SetOrientation(rot_degree*10)
61 A round though-hole pad. A shortcut for THPad()
62 @param size: pad diameter
63 @param drill: drill diameter
65 pad = self.THPad(size, size, drill, shape=pcbnew.PAD_SHAPE_CIRCLE)
70 A round non-plated though hole (NPTH)
72 @param drill: the drill diameter (equals the NPTH diameter)
76 pad.SetShape(pcbnew.PAD_SHAPE_CIRCLE)
77 pad.SetAttribute(pcbnew.PAD_ATTRIB_NPTH)
78 pad.SetLayerSet(pad.UnplatedHoleMask())
82 def SMDPad(self, Vsize, Hsize, shape=pcbnew.PAD_SHAPE_RECT, rot_degree=0):
84 Create a surface-mount pad of the given size and shape
85 @param Vsize: the vertical size of the pad
86 @param Hsize: the horizontal size of the pad
87 @param drill: the drill diameter
88 @param shape: the shape of the pad
89 @param rot_degree: the pad rotation,
in degrees
94 pad.SetAttribute(pcbnew.PAD_ATTRIB_SMD)
95 pad.SetLayerSet(pad.SMDMask())
96 pad.SetOrientation(rot_degree*10)
102 A round surface-mount pad. A shortcut for SMDPad()
103 @param size: pad diameter
105 pad = self.SMDPad(size, size, shape=pcbnew.PAD_SHAPE_CIRCLE)
111 A class to assist in creating repetitive grids of pads
113 Generally, PadArrays have an internal prototypical pad,
and copy this
114 for each pad
in the array. They can also have a special pad
for the
115 first pad,
and a custom function to name the pad.
117 Generally, PadArray
is used
as a base
class for more specific array
123 @param pad: the prototypical pad
135 Set a name for all the pins. If given, this overrides the
138 @param pinNames: the name to use
for all pins
144 If the array has a different first pad, this is the pad that
146 @param firstPad: the prototypical first pad
152 Set the numbering for the first pad
in the array
153 @param fpNum: the number
for the first pad
159 Add a pad to the array, under the same moodule as the main
161 @param pad: pad to add
163 self.pad.GetParent().Add(pad)
167 Get a pad in the array
with the given position
168 @param is_first_pad: use the special first pad
if there
is one
169 @param pos: the pad position
171 if (self.
firstPad and is_first_pad):
177 pad = pad.Duplicate()
185 Get the pad name from the naming function,
or the pre-set
186 pinNames parameter (set
with SetPinNames)
196 Implement this as needed
for each array type
198 raise NotImplementedError;
206 def __init__(self, pad, nx, ny, px, py, centre=pcbnew.wxPoint(0, 0)):
208 @param pad: the prototypical pad of the array
209 @param nx: number of pads
in x-direction
210 @param ny: number of pads
in y-direction
211 @param px: pitch
in x-direction
212 @param py: pitch
in y-direction
213 @param centre: array centre point
219 super(PadGridArray, self).
__init__(pad)
228 alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ"):
230 Utility function to generate an alphabetical name:
232 eg. 1 - A, 2 - B, 26 - AA, etc
234 @param aIndex: index of
'A': 0
for 0 - A
235 @param n: the pad index
236 @param alphabet: set of allowable chars
if not A-Z,
237 e.g. ABCDEFGHJKLMNPRTUVWY
for BGA
240 div, mod = divmod(n - aIndex, len(alphabet))
241 alpha = alphabet[mod]
250 Implementation of the naming function: right to left, top-to-bottom
252 @param x: the pad x index
253 @param y: the pad y index
260 Create the pads and add them to the module
in the correct positions
262 @param dc: the drawing context
265 pin1posX = self.centre.x - self.px * (self.nx - 1) / 2
266 pin1posY = self.centre.y - self.py * (self.ny - 1) / 2
268 for x
in range(0, self.
nx):
269 posX = pin1posX + (x * self.
px)
271 for y
in range(self.
ny):
272 posY = pin1posY + (self.
py * y)
273 pos = dc.TransformPoint(posX, posY)
274 pad = self.
GetPad(x == 0
and y == 0, pos)
281 A pad grid array with a fixed name, used
for things like thermal
287 Simply return the firstPadNum
296 A staggered pin array
299 def __init__(self, pad, pad_count, line_count, line_pitch,
300 pad_pitch, centre=pcbnew.wxPoint(0, 0)):
302 @param pad: the prototypical pad
303 @param pad_count: total pad count
304 @param line_count: number of staggered lines
305 @param line_pitch: distance between lines
306 @param pad_pitch: distance between pads
in a line
307 @param centre: array centre point
309 super(PadZGridArray, self).__init__(pad)
319 Naming just increased with pad index
in array
325 Create the pads and add them to the module
in the correct positions
327 @param dc: the drawing context
335 posX = pin1posX + (padnum * self.
pad_pitch)
338 pos = dc.TransformPoint(posX, posY)
339 pad = self.
GetPad(padnum == 0, pos)
340 pad.SetName(self.
GetName(padnum))
351 Shortcut cases for a single-row grid array. Can be used
for
352 constructing sections of larger footprints.
356 centre=pcbnew.wxPoint(0, 0)):
358 @param pad: the prototypical pad
359 @param n: number of pads
in array
360 @param pitch: distance between pad centres
361 @param isVertical: horizontal
or vertical array (can also use the
362 drawing contexts transforms
for more control)
363 @param centre: array centre
367 super(PadLineArray, self).
__init__(pad, 1, n, 0, pitch, centre)
369 super(PadLineArray, self).
__init__(pad, n, 1, pitch, 0, centre)
377 def __init__(self, pad, n, r, angle_offset=0, centre=pcbnew.wxPoint(0, 0),
378 clockwise=
True, padRotationEnable=
False, padRotationOffset=0):
380 @param pad: the prototypical pad
381 @param n: number of pads
in array
382 @param r: the circle radius
383 @param angle_offset: angle of the first pad
384 @param centre: array centre point
385 @param clockwise: array increases
in a clockwise direction
386 @param padRotationEnable: also rotate pads when placing
387 @param padRotationOffset: rotation of first pad
390 super(PadCircleArray, self).__init__(pad)
402 Naming around the circle, CW or CCW according to the clockwise flag
408 Create the pads and add them to the module
in the correct positions
410 @param dc: the drawing context
413 for pin
in range(0, self.
n):
419 pos_x = math.sin(angle * math.pi / 180) * self.
r
420 pos_y = -math.cos(angle * math.pi / 180) * self.
r
421 pos = dc.TransformPoint(pos_x, pos_y)
422 pad = self.
GetPad(pin == 0, pos)
426 pad.SetOrientation(padAngle*10)
433 Layout pads according to a custom array of [x,y] data
438 @param pad: the prototypical pad
439 @param array: the position data array
441 super(PadCustomArray, self).__init__(pad)
447 Simple increment along the given array
448 @param n: the pad index
in the array
454 Create the pads and add them to the module
in the correct positions
456 @param dc: the drawing context
459 for i
in range(len(self.
array)):
460 pos = dc.TransformPoint(self.
array[i][0], self.
array[i][1])
461 pad = self.
GetPad(i == 0, pos)
A pad grid array with a fixed name, used for things like thermal pads and via grids.
def NamingFunction(self, nx, ny)
Simply return the firstPadNum.
A class to assist in creating repetitive grids of pads.
def SetFirstPadType(self, firstPad)
If the array has a different first pad, this is the pad that is used.
def SetFirstPadInArray(self, fpNum)
Set the numbering for the first pad in the array.
def SetPinNames(self, pinNames)
Set a name for all the pins.
def GetPad(self, is_first_pad, pos)
Get a pad in the array with the given position.
def GetName(self, *args, **kwargs)
Get the pad name from the naming function, or the pre-set pinNames parameter (set with SetPinNames)
def NamingFunction(self, *args, **kwargs)
Implement this as needed for each array type.
def AddPad(self, pad)
Add a pad to the array, under the same moodule as the main prototype pad.
def NamingFunction(self, n)
Naming around the circle, CW or CCW according to the clockwise flag.
def __init__(self, pad, n, r, angle_offset=0, centre=pcbnew.wxPoint(0, 0), clockwise=True, padRotationEnable=False, padRotationOffset=0)
def AddPadsToModule(self, dc)
Create the pads and add them to the module in the correct positions.
Layout pads according to a custom array of [x,y] data.
def NamingFunction(self, n)
Simple increment along the given array.
def AddPadsToModule(self, dc)
Create the pads and add them to the module in the correct positions.
def __init__(self, pad, array)
def AlphaNameFromNumber(self, n, aIndex=1, alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ")
Utility function to generate an alphabetical name:
def NamingFunction(self, x, y)
Implementation of the naming function: right to left, top-to-bottom.
def AddPadsToModule(self, dc)
Create the pads and add them to the module in the correct positions.
def __init__(self, pad, nx, ny, px, py, centre=pcbnew.wxPoint(0, 0))
Shortcut cases for a single-row grid array.
def __init__(self, pad, n, pitch, isVertical, centre=pcbnew.wxPoint(0, 0))
Useful construction functions for common types of pads, providing sensible defaults for common pads.
def NPTHRoundPad(self, drill)
A round non-plated though hole (NPTH)
def SMDPad(self, Vsize, Hsize, shape=pcbnew.PAD_SHAPE_RECT, rot_degree=0)
def __init__(self, module)
def THRoundPad(self, size, drill)
A round though-hole pad.
def SMTRoundPad(self, size)
A round surface-mount pad.
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.
def AddPadsToModule(self, dc)
Create the pads and add them to the module in the correct positions.
def NamingFunction(self, pad_pos)
Naming just increased with pad index in array.
def __init__(self, pad, pad_count, line_count, line_pitch, pad_pitch, centre=pcbnew.wxPoint(0, 0))