2014-04-23 16:36:31 +00:00
|
|
|
# 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 pcbnew
|
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
import FootprintWizardBase
|
2014-04-23 16:36:31 +00:00
|
|
|
import PadArray as PA
|
|
|
|
|
|
|
|
|
|
|
|
class RowedGridArray(PA.PadGridArray):
|
|
|
|
|
2018-06-13 18:16:01 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
2020-09-04 02:57:04 +00:00
|
|
|
super(RowedGridArray, self).__init__(*args, **kwargs)
|
2018-06-13 18:16:01 +00:00
|
|
|
|
2014-04-23 16:36:31 +00:00
|
|
|
def NamingFunction(self, x, y):
|
2015-10-31 11:54:48 +00:00
|
|
|
pad_cnt = self.nx*self.ny
|
|
|
|
|
|
|
|
if self.ny == 1:
|
|
|
|
return x+1
|
|
|
|
|
|
|
|
if (y % 2) == 0: # upper row, count down
|
|
|
|
return pad_cnt-x
|
|
|
|
else: # lower row, count up
|
|
|
|
return x+1
|
2014-09-14 16:29:10 +00:00
|
|
|
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
class RowedFootprint(FootprintWizardBase.FootprintWizard):
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2016-02-14 09:47:07 +00:00
|
|
|
pad_count_key = 'pad count'
|
2015-10-31 11:54:48 +00:00
|
|
|
row_count_key = 'row count'
|
|
|
|
row_spacing_key = 'row spacing'
|
|
|
|
pad_length_key = 'pad length'
|
|
|
|
pad_width_key = 'pad width'
|
|
|
|
pad_pitch_key = 'pad pitch'
|
|
|
|
|
|
|
|
silkscreen_inside_key = 'silk screen inside'
|
|
|
|
outline_x_margin_key = 'outline x margin'
|
|
|
|
outline_y_margin_key = 'outline y margin'
|
|
|
|
|
2014-04-23 16:36:31 +00:00
|
|
|
def GenerateParameterList(self):
|
|
|
|
# defaults for a DIP package
|
2017-01-03 15:01:47 +00:00
|
|
|
self.AddParam("Pads", self.pad_count_key, self.uInteger, 24)
|
|
|
|
self.AddParam("Pads", self.row_count_key, self.uInteger, 2, min_value=1, max_value=2)
|
2015-10-31 11:54:48 +00:00
|
|
|
|
|
|
|
self.AddParam("Body", self.silkscreen_inside_key, self.uBool, False)
|
|
|
|
self.AddParam("Body", self.outline_x_margin_key, self.uMM, 0.5)
|
|
|
|
self.AddParam("Body", self.outline_y_margin_key, self.uMM, 0.5)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
def CheckParameters(self):
|
2017-01-03 15:01:47 +00:00
|
|
|
self.CheckParam("Pads", self.pad_count_key, multiple=self.parameters['Pads'][self.row_count_key], info='Pads must be multiple of row count')
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
def BuildThisFootprint(self):
|
|
|
|
pads = self.parameters["Pads"]
|
2015-10-31 11:54:48 +00:00
|
|
|
body = self.parameters["Body"]
|
2017-01-03 15:01:47 +00:00
|
|
|
num_pads = pads[self.pad_count_key]
|
2015-10-31 11:54:48 +00:00
|
|
|
pad_length = pads[self.pad_length_key]
|
|
|
|
pad_width = pads[self.pad_width_key]
|
|
|
|
row_pitch = pads[self.row_spacing_key]
|
|
|
|
pad_pitch = pads[self.pad_pitch_key]
|
2017-01-03 15:01:47 +00:00
|
|
|
num_rows = pads[self.row_count_key]
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
pads_per_row = num_pads // num_rows
|
|
|
|
|
|
|
|
# add in the pads
|
|
|
|
pad = self.GetPad()
|
|
|
|
|
2015-10-31 11:54:48 +00:00
|
|
|
array = RowedGridArray(pad, pads_per_row, num_rows, pad_pitch, row_pitch)
|
2014-09-14 16:29:10 +00:00
|
|
|
array.AddPadsToModule(self.draw)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
# draw the Silk Screen
|
2015-10-31 11:54:48 +00:00
|
|
|
Hsize = pad_pitch * (num_pads / num_rows - 1)
|
|
|
|
Vsize = row_pitch * (num_rows - 1)
|
|
|
|
pin1_posY = -Vsize / 2
|
|
|
|
pin1_posX = -Hsize / 2
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2015-10-31 11:54:48 +00:00
|
|
|
pad_length = pads[self.pad_length_key]
|
|
|
|
pad_width = pads[self.pad_width_key]
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2015-10-31 11:54:48 +00:00
|
|
|
ssx_offset = -pad_width / 2 - body[self.outline_x_margin_key]
|
|
|
|
ssy_offset = -pad_length / 2 - body[self.outline_y_margin_key]
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
if body[self.silkscreen_inside_key]:
|
2015-10-31 11:54:48 +00:00
|
|
|
ssy_offset *= -1
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2015-10-31 11:54:48 +00:00
|
|
|
ssx = -pin1_posX - ssx_offset
|
|
|
|
ssy = -pin1_posY - ssy_offset
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2018-12-10 11:13:12 +00:00
|
|
|
cmargin = self.draw.GetLineThickness()
|
|
|
|
self.draw.SetLineThickness( pcbnew.FromMM( 0.12 ) ) #Default per KLC F5.1 as of 12/2018
|
2014-09-14 16:29:10 +00:00
|
|
|
self.DrawBox(ssx, ssy)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2016-02-09 09:10:17 +00:00
|
|
|
# Courtyard
|
|
|
|
self.draw.SetLayer(pcbnew.F_CrtYd)
|
2019-01-29 07:41:59 +00:00
|
|
|
cclearance = pcbnew.FromMM(0.25)
|
|
|
|
sizex = (-pin1_posX + cclearance) * 2 + pad_width
|
|
|
|
sizey = (-pin1_posY + cclearance) * 2 + pad_length
|
|
|
|
# round size to nearest 0.02mm, rectangle will thus land on a 0.01mm grid
|
|
|
|
sizex = pcbnew.PutOnGridMM(sizex, 0.02)
|
|
|
|
sizey = pcbnew.PutOnGridMM(sizey, 0.02)
|
2016-02-09 09:10:17 +00:00
|
|
|
# set courtyard line thickness to the one defined in KLC
|
2016-02-11 15:02:37 +00:00
|
|
|
self.draw.SetLineThickness(pcbnew.FromMM(0.05))
|
2016-02-09 09:10:17 +00:00
|
|
|
self.draw.Box(0, 0, sizex, sizey)
|
|
|
|
# restore line thickness to previous value
|
2016-02-11 15:02:37 +00:00
|
|
|
self.draw.SetLineThickness(pcbnew.FromMM(cmargin))
|
2016-02-14 09:47:07 +00:00
|
|
|
|
2014-04-23 16:36:31 +00:00
|
|
|
#reference and value
|
2015-10-29 17:35:52 +00:00
|
|
|
text_size = self.GetTextSize() # IPC nominal
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2015-10-31 11:54:48 +00:00
|
|
|
if num_rows == 1:
|
|
|
|
text_py = ssy + text_size
|
|
|
|
self.draw.Value(0, -text_py, text_size)
|
|
|
|
self.draw.Reference(0, text_py, text_size)
|
|
|
|
else:
|
|
|
|
text_px = ssx + text_size
|
|
|
|
# self.draw.Value(text_px, 0, text_size, orientation_degree=90)
|
|
|
|
self.draw.Value(0, 0, text_size)
|
|
|
|
self.draw.Reference(-text_px, 0, text_size, orientation_degree=90)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2016-02-18 14:29:30 +00:00
|
|
|
# set the attribute
|
|
|
|
if self.GetName() == "S-DIP":
|
2020-11-14 12:38:44 +00:00
|
|
|
self.module.SetAttributes(pcbnew.PAD_ATTRIB_PTH)
|
2016-02-18 14:29:30 +00:00
|
|
|
elif self.GetName() == "SOIC":
|
2020-11-14 12:38:44 +00:00
|
|
|
self.module.SetAttributes(pcbnew.PAD_ATTRIB_SMD)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
class SDIPWizard(RowedFootprint):
|
|
|
|
|
|
|
|
def GetName(self):
|
2015-08-23 12:44:56 +00:00
|
|
|
return "S-DIP"
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
def GetDescription(self):
|
|
|
|
return "Single/Dual Inline Package Footprint Wizard"
|
|
|
|
|
|
|
|
def GenerateParameterList(self):
|
|
|
|
RowedFootprint.GenerateParameterList(self)
|
|
|
|
|
2015-10-31 11:54:48 +00:00
|
|
|
self.AddParam("Pads", self.pad_pitch_key, self.uMM, 2.54)
|
|
|
|
self.AddParam("Pads", self.pad_width_key, self.uMM, 1.2)
|
|
|
|
self.AddParam("Pads", self.pad_length_key, self.uMM, 2)
|
|
|
|
self.AddParam("Pads", self.row_spacing_key, self.uMM, 7.52)
|
|
|
|
self.AddParam("Pads", "drill size", self.uMM, 0.8)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
def GetValue(self):
|
2015-10-31 11:54:48 +00:00
|
|
|
pads = self.parameters["Pads"]
|
2017-01-03 15:01:47 +00:00
|
|
|
rows = pads[self.row_count_key]
|
|
|
|
pad_count = pads[self.pad_count_key]
|
2015-10-31 11:54:48 +00:00
|
|
|
row_dist_mil = pcbnew.Iu2Mils(int(self.parameters["Pads"][self.row_spacing_key])) #int(self.parameters["Pads"][self.row_spacing_key] / 2.54 * 100)
|
|
|
|
pad_shape = ""
|
|
|
|
|
|
|
|
if pads[self.pad_width_key] != pads[self.pad_length_key]:
|
|
|
|
pad_shape = '_ELL'
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
if rows == 1:
|
2014-04-23 16:36:31 +00:00
|
|
|
name = "SIP"
|
2015-10-31 11:54:48 +00:00
|
|
|
return "%s-%d" % (name, pad_count)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2015-10-31 11:54:48 +00:00
|
|
|
name = "DIP"
|
|
|
|
return "%s-%d_%d%s" % (name, pad_count, row_dist_mil, pad_shape)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
def GetPad(self):
|
2015-10-31 11:54:48 +00:00
|
|
|
pad_length = self.parameters["Pads"][self.pad_length_key]
|
|
|
|
pad_width = self.parameters["Pads"][self.pad_width_key]
|
2014-04-23 16:36:31 +00:00
|
|
|
drill = self.parameters["Pads"]["drill size"]
|
2015-10-31 11:54:48 +00:00
|
|
|
shape = pcbnew.PAD_SHAPE_CIRCLE
|
|
|
|
|
|
|
|
if pad_length != pad_width:
|
|
|
|
shape = pcbnew.PAD_SHAPE_OVAL
|
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
return PA.PadMaker(self.module).THPad(
|
2015-10-31 11:54:48 +00:00
|
|
|
pad_length, pad_width, drill, shape=shape)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
def DrawBox(self, ssx, ssy):
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
if self.parameters["Pads"][self.row_count_key] == 2:
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
# ----------
|
|
|
|
# |8 7 6 5 |
|
|
|
|
# > |
|
|
|
|
# |1 2 3 4 |
|
|
|
|
# ----------
|
|
|
|
|
|
|
|
# draw the notch
|
2015-10-31 11:54:48 +00:00
|
|
|
notchWidth = ssy/1.5
|
2016-02-11 15:02:37 +00:00
|
|
|
notchHeight = self.draw.GetLineThickness()*3
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2015-10-31 11:54:48 +00:00
|
|
|
# NotchedBox draws the notch on top. Rotate the box 90 degrees
|
|
|
|
# to have it on the left
|
|
|
|
self.draw.NotchedBox(0, 0, ssy*2, ssx*2, notchWidth, notchHeight, -90)
|
2014-04-23 16:36:31 +00:00
|
|
|
else:
|
|
|
|
# -----------------
|
|
|
|
# |1|2 3 4 5 6 7 8|
|
|
|
|
# -----------------
|
2014-09-14 16:29:10 +00:00
|
|
|
self.draw.Box(0, 0, ssx*2, ssy*2)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
#line between pin1 and pin2
|
2015-10-31 11:54:48 +00:00
|
|
|
pad_pitch = self.parameters["Pads"][self.pad_pitch_key]
|
2017-01-03 15:01:47 +00:00
|
|
|
pad_cnt = self.parameters["Pads"][self.pad_count_key]
|
2015-10-31 11:54:48 +00:00
|
|
|
line_x = ( pad_cnt/2 - 1) * pad_pitch
|
|
|
|
self.draw.VLine(-line_x, -ssy, ssy * 2)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
return ssx, ssy
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
SDIPWizard().register()
|
|
|
|
|
|
|
|
|
|
|
|
class SOICWizard(RowedFootprint):
|
|
|
|
|
|
|
|
def GetName(self):
|
|
|
|
return "SOIC"
|
|
|
|
|
|
|
|
def GetDescription(self):
|
|
|
|
return "SOIC, MSOP, SSOP, TSSOP, etc, footprint wizard"
|
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
def GetValue(self):
|
2017-01-03 15:01:47 +00:00
|
|
|
pad_count = self.parameters["Pads"][self.pad_count_key]
|
2015-10-31 11:54:48 +00:00
|
|
|
return "%s-%d" % ("SOIC", pad_count)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
def GenerateParameterList(self):
|
|
|
|
RowedFootprint.GenerateParameterList(self)
|
|
|
|
|
|
|
|
#and override some of them
|
2015-10-31 11:54:48 +00:00
|
|
|
self.AddParam("Pads", self.pad_pitch_key, self.uMM, 1.27)
|
|
|
|
self.AddParam("Pads", self.pad_width_key, self.uMM, 0.6)
|
|
|
|
self.AddParam("Pads", self.pad_length_key, self.uMM, 2.2)
|
|
|
|
self.AddParam("Pads", self.row_spacing_key, self.uMM, 5.2)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
def GetPad(self):
|
2015-10-31 11:54:48 +00:00
|
|
|
pad_length = self.parameters["Pads"][self.pad_length_key]
|
|
|
|
pad_width = self.parameters["Pads"][self.pad_width_key]
|
2014-09-14 16:29:10 +00:00
|
|
|
return PA.PadMaker(self.module).SMDPad(
|
2015-10-31 11:54:48 +00:00
|
|
|
pad_length, pad_width, shape=pcbnew.PAD_SHAPE_RECT)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
2014-09-14 16:29:10 +00:00
|
|
|
def DrawBox(self, ssx, ssy):
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
# ----------
|
|
|
|
# |8 7 6 5 |
|
|
|
|
# |1 2 3 4 |
|
|
|
|
# \---------
|
|
|
|
|
2015-12-09 16:11:32 +00:00
|
|
|
setback = pcbnew.FromMM(0.8)
|
|
|
|
|
|
|
|
if setback > ssy:
|
|
|
|
setback = ssy
|
|
|
|
|
|
|
|
self.draw.BoxWithDiagonalAtCorner(0, 0, ssx*2, ssy*2, setback, self.draw.flipY)
|
2014-04-23 16:36:31 +00:00
|
|
|
|
|
|
|
SOICWizard().register()
|