2015-10-31 11:54:48 +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
|
2015-10-31 11:54:48 +00:00
|
|
|
import PadArray as PA
|
|
|
|
|
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
class RowedFootprint(FootprintWizardBase.FootprintWizard):
|
2015-10-31 11:54:48 +00:00
|
|
|
|
|
|
|
def GenerateParameterList(self):
|
|
|
|
|
|
|
|
# defaults for a ZIP package
|
2017-01-03 15:01:47 +00:00
|
|
|
self.AddParam("Pads", "pad count", self.uInteger, 24)
|
|
|
|
self.AddParam("Pads", "line count", self.uInteger, 2)
|
2015-10-31 11:54:48 +00:00
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
self.AddParam("Body", "silkscreen inside", self.uBool, False)
|
|
|
|
self.AddParam("Body", "courtyard margin", self.uMM, 0.5, min_value=0.2)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def pads(self):
|
|
|
|
return self.parameters['Pads']
|
2015-10-31 11:54:48 +00:00
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
@property
|
|
|
|
def body(self):
|
|
|
|
return self.parameters['Body']
|
|
|
|
|
|
|
|
def CheckParameters(self):
|
|
|
|
# TODO - implement custom checks
|
|
|
|
pass
|
2015-10-31 11:54:48 +00:00
|
|
|
|
|
|
|
def BuildThisFootprint(self):
|
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
pad_count = self.pads['pad count']
|
|
|
|
pad_Vsize = self.pads['pad height']
|
|
|
|
pad_Hsize = self.pads['pad width']
|
|
|
|
line_pitch = self.pads['line spacing']
|
|
|
|
pad_pitch = self.pads['pitch']
|
|
|
|
line_count = self.pads['line count']
|
2015-10-31 11:54:48 +00:00
|
|
|
|
|
|
|
if line_count == 1:
|
|
|
|
singleline = True
|
|
|
|
else:
|
|
|
|
singleline = False
|
|
|
|
|
|
|
|
# add in the pads
|
|
|
|
pad = self.GetPad()
|
|
|
|
|
|
|
|
array = PA.PadZGridArray(pad, pad_count, line_count, line_pitch, pad_pitch)
|
|
|
|
array.AddPadsToModule(self.draw)
|
2017-01-03 15:01:47 +00:00
|
|
|
|
2015-10-31 11:54:48 +00:00
|
|
|
# draw the Silk Screen
|
|
|
|
pads_per_line = pad_count // line_count
|
|
|
|
row_length = pad_pitch * (pads_per_line - 1) # fenceposts
|
2017-01-03 15:01:47 +00:00
|
|
|
ssx_offset = pad_Hsize / 2 + self.body['outline x margin']
|
|
|
|
ssy_offset = pad_Vsize / 2 + self.body['outline y margin']
|
2015-10-31 11:54:48 +00:00
|
|
|
|
|
|
|
pin1posX = pad_pitch * (pad_count - 1) / 2
|
|
|
|
pin1posY = line_pitch * (line_count - 1) / 2
|
|
|
|
leftx = pin1posX + ssx_offset
|
|
|
|
lowy = pin1posY + ssy_offset
|
|
|
|
|
|
|
|
cornery = lowy
|
|
|
|
|
|
|
|
# body inside pads is possible only for 2 rows.
|
|
|
|
# for other values, there is no room
|
2016-02-11 15:02:37 +00:00
|
|
|
linew = self.draw.GetLineThickness()
|
2017-01-03 15:01:47 +00:00
|
|
|
if self.body['silkscreen inside'] and line_count == 2:
|
2015-10-31 11:54:48 +00:00
|
|
|
cornery = pin1posY - ssy_offset
|
|
|
|
if cornery < linew:
|
|
|
|
cornery = linew
|
|
|
|
|
2018-12-10 11:13:12 +00:00
|
|
|
thick = self.draw.GetLineThickness()
|
|
|
|
self.draw.SetLineThickness( pcbnew.FromMM( 0.12 ) ) #Default per KLC F5.1 as of 12/2018
|
2015-10-31 11:54:48 +00:00
|
|
|
self.DrawBox(leftx*2, cornery*2)
|
|
|
|
|
|
|
|
# Courtyard
|
2017-01-03 15:01:47 +00:00
|
|
|
cmarginx = self.body['courtyard margin']
|
|
|
|
cmarginy = cmarginx
|
2015-10-31 11:54:48 +00:00
|
|
|
self.draw.SetLayer(pcbnew.F_CrtYd)
|
2016-02-09 09:10:17 +00:00
|
|
|
sizex = (pin1posX + cmarginx) * 2 + pad_Hsize + thick
|
|
|
|
sizey = (pin1posY + cmarginy) * 2 + pad_Vsize + thick
|
2016-02-18 17:53:39 +00:00
|
|
|
# round size to nearest 0.1mm, rectangle will thus land on a 0.05mm grid
|
2017-01-03 15:01:47 +00:00
|
|
|
sizex = pcbnew.PutOnGridMM(sizex, 0.1)
|
|
|
|
sizey = pcbnew.PutOnGridMM(sizey, 0.1)
|
2016-02-18 17:53:39 +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))
|
2015-10-31 11:54:48 +00:00
|
|
|
self.draw.Box(0, 0, sizex, sizey)
|
2016-02-09 09:10:17 +00:00
|
|
|
# restore line thickness to previous value
|
2016-02-11 15:02:37 +00:00
|
|
|
self.draw.SetLineThickness(pcbnew.FromMM(thick))
|
2015-10-31 11:54:48 +00:00
|
|
|
|
|
|
|
#reference and value
|
|
|
|
text_size = self.GetTextSize() # IPC nominal
|
|
|
|
t_posy = lowy + text_size
|
|
|
|
|
|
|
|
self.draw.Value(0, t_posy, text_size)
|
|
|
|
self.draw.Reference(0, -t_posy, text_size)
|
|
|
|
|
2016-02-18 14:29:30 +00:00
|
|
|
# set SMD attribute
|
|
|
|
if self.GetName() == "ZIP":
|
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() == "ZOIC":
|
2020-11-14 12:38:44 +00:00
|
|
|
self.module.SetAttributes(pcbnew.PAD_ATTRIB_SMD)
|
2016-02-18 14:29:30 +00:00
|
|
|
|
2015-10-31 11:54:48 +00:00
|
|
|
def DrawBox(self, sizex, sizey):
|
|
|
|
|
|
|
|
# ----------
|
|
|
|
# | 2 4 6 8|
|
|
|
|
# |1 3 5 7 |
|
|
|
|
# \---------
|
|
|
|
setback = pcbnew.FromMM(1)
|
|
|
|
|
|
|
|
if setback > sizey/2:
|
|
|
|
setback = sizey/2
|
|
|
|
|
|
|
|
self.draw.BoxWithDiagonalAtCorner(0, 0, sizex, sizey, setback, self.draw.flipY)
|
|
|
|
|
|
|
|
|
|
|
|
class ZIPWizard(RowedFootprint):
|
|
|
|
|
|
|
|
def GetName(self):
|
|
|
|
return "ZIP"
|
|
|
|
|
|
|
|
def GetDescription(self):
|
|
|
|
return "N lines Zip Package Footprint Wizard"
|
|
|
|
|
|
|
|
def GenerateParameterList(self):
|
|
|
|
RowedFootprint.GenerateParameterList(self)
|
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
self.AddParam("Pads", "pitch", self.uMM, 1.27)
|
|
|
|
self.AddParam("Pads", "pad width", self.uMM, 1.2)
|
|
|
|
self.AddParam("Pads", "pad height", self.uMM, 2)
|
|
|
|
self.AddParam("Pads", "line spacing", self.uMM, 2.54)
|
|
|
|
self.AddParam("Pads", "drill size", self.uMM, 0.8)
|
|
|
|
self.AddParam("Body", 'outline x margin', self.uMM, 1)
|
|
|
|
self.AddParam("Body", 'outline y margin', self.uMM, 0.5)
|
2015-10-31 11:54:48 +00:00
|
|
|
|
|
|
|
def GetValue(self):
|
2017-01-03 15:01:47 +00:00
|
|
|
rows = self.pads['line count']
|
|
|
|
pad_cnt = self.pads['pad count']
|
2015-10-31 11:54:48 +00:00
|
|
|
|
|
|
|
if rows == 1:
|
|
|
|
name = "SIP"
|
|
|
|
elif rows == 2:
|
|
|
|
name = "ZIP"
|
|
|
|
else: # triple and up aren't really a thing, but call it something!
|
|
|
|
name = "xIP"
|
|
|
|
|
|
|
|
return "%s-%d" % (name, pad_cnt)
|
|
|
|
|
|
|
|
def GetPad(self):
|
2017-01-03 15:01:47 +00:00
|
|
|
pad_Vsize = self.pads['pad height']
|
|
|
|
pad_Hsize = self.pads['pad width']
|
|
|
|
drill = self.pads['drill size']
|
2015-10-31 11:54:48 +00:00
|
|
|
return PA.PadMaker(self.module).THPad(
|
|
|
|
pad_Vsize, pad_Hsize, drill, shape=pcbnew.PAD_SHAPE_OVAL)
|
|
|
|
|
|
|
|
ZIPWizard().register()
|
|
|
|
|
|
|
|
|
|
|
|
class ZOICWizard(RowedFootprint):
|
|
|
|
|
|
|
|
def GetName(self):
|
|
|
|
return "ZOIC"
|
|
|
|
|
|
|
|
def GetDescription(self):
|
|
|
|
return "ZOIC, etc, Footprint Wizard"
|
|
|
|
|
|
|
|
def GetValue(self):
|
2017-01-03 15:01:47 +00:00
|
|
|
return "%s-%d" % ("ZOIC-", self.pads['pad count'])
|
2015-10-31 11:54:48 +00:00
|
|
|
|
|
|
|
def GenerateParameterList(self):
|
|
|
|
RowedFootprint.GenerateParameterList(self)
|
|
|
|
|
|
|
|
#and override some of them
|
2017-01-03 15:01:47 +00:00
|
|
|
self.AddParam("Pads", "pitch", self.uMM, 0.6)
|
|
|
|
self.AddParam("Pads", "pad width", self.uMM, 0.6)
|
|
|
|
self.AddParam("Pads", "pad height", self.uMM, 1.8)
|
|
|
|
self.AddParam("Pads", "line spacing", self.uMM, 5.2)
|
2015-10-31 11:54:48 +00:00
|
|
|
|
2017-01-03 15:01:47 +00:00
|
|
|
self.AddParam("Body", "outline x margin", self.uMM, 0.5)
|
|
|
|
self.AddParam("Body", "outline y margin", self.uMM, 1)
|
2015-10-31 11:54:48 +00:00
|
|
|
|
|
|
|
def GetPad(self):
|
2017-01-03 15:01:47 +00:00
|
|
|
pad_Vsize = self.pads['pad height']
|
|
|
|
pad_Hsize = self.pads['pad width']
|
2015-10-31 11:54:48 +00:00
|
|
|
return PA.PadMaker(self.module).SMDPad(
|
|
|
|
pad_Vsize, pad_Hsize, shape=pcbnew.PAD_SHAPE_RECT)
|
|
|
|
|
|
|
|
ZOICWizard().register()
|